Skip to content
Snippets Groups Projects
Commit db4c7ba0 authored by Alan's avatar Alan
Browse files

Added upgrade for rook

parent 16fe7e12
No related branches found
No related tags found
1 merge request!1Refactoring game.gd to split up move validation to individual pieces, added...
......@@ -45,11 +45,15 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 36,
"column": 0,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 52,
"scroll_position": 39.0,
"selection": false,
"row": 10,
"scroll_position": 0.0,
"selection": true,
"selection_from_column": 0,
"selection_from_line": 10,
"selection_to_column": 43,
"selection_to_line": 10,
"syntax_highlighter": "GDScript"
}
......@@ -7,8 +7,8 @@ enum Upgrade { DOUBLE_MOVE, DIAGONAL_MOVE }
func _init(is_white: bool, position: Vector2):
super._init(is_white, position)
# Testing upgrades
upgrades.append(Upgrade.DOUBLE_MOVE)
upgrades.append(Upgrade.DIAGONAL_MOVE)
# upgrades.append(Upgrade.DOUBLE_MOVE)
# upgrades.append(Upgrade.DIAGONAL_MOVE)
func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
......
......@@ -8,6 +8,8 @@ enum Upgrade {
func _init(is_white: bool, position: Vector2):
super._init(is_white, position)
# Testing upgrades
# upgrades.append(Upgrade.DIAGONAL_MOVE_ONE)
func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
var valid_moves: Array[Vector2] = []
......@@ -57,5 +59,16 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
break
else:
break
# Check for DIAGONAL_MOVE_ONE upgrade
if Upgrade.DIAGONAL_MOVE_ONE in upgrades:
if x > 0 and y > 0 and (board_state[x - 1][y - 1] == null or not board_state[x - 1][y - 1].is_white):
valid_moves.append(Vector2(x - 1, y - 1))
if x < 7 and y > 0 and (board_state[x + 1][y - 1] == null or not board_state[x + 1][y - 1].is_white):
valid_moves.append(Vector2(x + 1, y - 1))
if x > 0 and y < 7 and (board_state[x - 1][y + 1] == null or not board_state[x - 1][y + 1].is_white):
valid_moves.append(Vector2(x - 1, y + 1))
if x < 7 and y < 7 and (board_state[x + 1][y + 1] == null or not board_state[x + 1][y + 1].is_white):
valid_moves.append(Vector2(x + 1, y + 1))
return valid_moves
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment