From 16fe7e1215bfe5f7d7fa8906dbbfcad9b033956c Mon Sep 17 00:00:00 2001
From: Alan <alanjfogel@gmail.com>
Date: Fri, 31 Jan 2025 13:33:22 -0600
Subject: [PATCH] Added base rook movements

---
 .godot/editor/editor_layout.cfg       |  4 ++--
 .godot/editor/script_editor_cache.cfg | 10 +++++-----
 scripts/Rook.gd                       | 26 +++++++++++++++++---------
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg
index 3e10ccc..3eb99a4 100644
--- a/.godot/editor/editor_layout.cfg
+++ b/.godot/editor/editor_layout.cfg
@@ -27,7 +27,7 @@ dock_5="Inspector,Node,History"
 
 open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/explosion.tscn", "res://scenes/Pawn.tscn", "res://scenes/Rook.tscn")
 current_scene="res://scenes/Pawn.tscn"
-center_split_offset=-288
+center_split_offset=-320
 selected_default_debugger_tab_idx=0
 selected_main_editor_idx=2
 selected_bottom_panel_item=0
@@ -35,7 +35,7 @@ selected_bottom_panel_item=0
 [ScriptEditor]
 
 open_scripts=["res://scripts/game.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "res://scripts/Rook.gd"]
-selected_script="res://scripts/game.gd"
+selected_script="res://scripts/Rook.gd"
 open_help=[]
 script_split_offset=70
 list_split_offset=0
diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg
index d607173..d7d2ae4 100644
--- a/.godot/editor/script_editor_cache.cfg
+++ b/.godot/editor/script_editor_cache.cfg
@@ -7,7 +7,7 @@ state={
 "folded_lines": Array[int]([]),
 "h_scroll_position": 0,
 "row": 122,
-"scroll_position": 107.0,
+"scroll_position": 95.0,
 "selection": false,
 "syntax_highlighter": "GDScript"
 }
@@ -31,7 +31,7 @@ state={
 state={
 "bookmarks": PackedInt32Array(),
 "breakpoints": PackedInt32Array(),
-"column": 14,
+"column": 0,
 "folded_lines": Array[int]([]),
 "h_scroll_position": 0,
 "row": 10,
@@ -45,11 +45,11 @@ state={
 state={
 "bookmarks": PackedInt32Array(),
 "breakpoints": PackedInt32Array(),
-"column": 0,
+"column": 36,
 "folded_lines": Array[int]([]),
 "h_scroll_position": 0,
-"row": 16,
-"scroll_position": 6.0,
+"row": 52,
+"scroll_position": 39.0,
 "selection": false,
 "syntax_highlighter": "GDScript"
 }
diff --git a/scripts/Rook.gd b/scripts/Rook.gd
index 4947a56..e39a922 100644
--- a/scripts/Rook.gd
+++ b/scripts/Rook.gd
@@ -2,19 +2,23 @@ extends Piece
 
 class_name Rook
 
+enum Upgrade {
+	DIAGONAL_MOVE_ONE,
+}
+
 func _init(is_white: bool, position: Vector2):
 	super._init(is_white, position)
 
 func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
-	var valid_moves = []
+	var valid_moves: Array[Vector2] = []
 	var x = pos.x
 	var y = pos.y
 
 	# Check moves to the right
 	for i in range(x + 1, 8):
-		if board_state[i][y] == 0:
+		if board_state[i][y] == null:
 			valid_moves.append(Vector2(i, y))
-		elif board_state[i][y].is_white != is_white:
+		elif board_state[i][y] != null and not board_state[i][y].is_white:
 			valid_moves.append(Vector2(i, y))
 			break
 		else:
@@ -22,9 +26,9 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
 
 	# Check moves to the left
 	for i in range(x - 1, -1, -1):
-		if board_state[i][y] == 0:
+		if board_state[i][y] == null:
 			valid_moves.append(Vector2(i, y))
-		elif board_state[i][y].is_white != is_white:
+		elif board_state[i][y] != null and not board_state[i][y].is_white:
 			valid_moves.append(Vector2(i, y))
 			break
 		else:
@@ -32,9 +36,11 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
 
 	# Check moves upwards
 	for i in range(y - 1, -1, -1):
-		if board_state[x][i] == 0:
+		# Check if the square is empty
+		if board_state[x][i] == null:
 			valid_moves.append(Vector2(x, i))
-		elif board_state[x][i].is_white != is_white:
+		# Check if the square has an enemy piece
+		elif board_state[x][i] != null and not board_state[x][i].is_white:
 			valid_moves.append(Vector2(x, i))
 			break
 		else:
@@ -42,9 +48,11 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
 
 	# Check moves downwards
 	for i in range(y + 1, 8):
-		if board_state[x][i] == 0:
+		# Check if the square is empty
+		if board_state[x][i] == null:
 			valid_moves.append(Vector2(x, i))
-		elif board_state[x][i].is_white != is_white:
+		# Check if the square has an enemy piece
+		elif board_state[x][i] != null and not board_state[x][i].is_white:
 			valid_moves.append(Vector2(x, i))
 			break
 		else:
-- 
GitLab