extends Piece class_name Bishop enum Upgrade { MOVE_CARDINAL_ONE, } func _init(is_white: bool, position: Vector2): super._init(is_white, position) # Testing upgrades upgrades.append(Upgrade.MOVE_CARDINAL_ONE) func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]: var valid_moves: Array[Vector2] = [] var x = pos.x var y = pos.y # Check moves in the top-right diagonal for i in range(1, 8): if x + i < 8 and y - i >= 0: if board_state[x + i][y - i] == null: valid_moves.append(Vector2(x + i, y - i)) elif not board_state[x + i][y - i].is_white: valid_moves.append(Vector2(x + i, y - i)) break else: break else: break # Check moves in the top-left diagonal for i in range(1, 8): if x - i >= 0 and y - i >= 0: if board_state[x - i][y - i] == null: valid_moves.append(Vector2(x - i, y - i)) elif not board_state[x - i][y - i].is_white: valid_moves.append(Vector2(x - i, y - i)) break else: break else: break # Check moves in the bottom-right diagonal for i in range(1, 8): if x + i < 8 and y + i < 8: if board_state[x + i][y + i] == null: valid_moves.append(Vector2(x + i, y + i)) elif not board_state[x + i][y + i].is_white: valid_moves.append(Vector2(x + i, y + i)) break else: break else: break # Check moves in the bottom-left diagonal for i in range(1, 8): if x - i >= 0 and y + i < 8: if board_state[x - i][y + i] == null: valid_moves.append(Vector2(x - i, y + i)) elif not board_state[x - i][y + i].is_white: valid_moves.append(Vector2(x - i, y + i)) break else: break else: break # Check for MOVE_CARDINAL_ONE upgrade if Upgrade.MOVE_CARDINAL_ONE in upgrades: # Check cardinal moves (one space) if x > 0 and (board_state[x - 1][y] == null or not board_state[x - 1][y].is_white): valid_moves.append(Vector2(x - 1, y)) if x < 7 and (board_state[x + 1][y] == null or not board_state[x + 1][y].is_white): valid_moves.append(Vector2(x + 1, y)) if y > 0 and (board_state[x][y - 1] == null or not board_state[x][y - 1].is_white): valid_moves.append(Vector2(x, y - 1)) if y < 7 and (board_state[x][y + 1] == null or not board_state[x][y + 1].is_white): valid_moves.append(Vector2(x, y + 1)) return valid_moves