extends "res://Piece.gd" #TODO en passant func setup(): kind = KIND.PAWN var sprite2d = get_node("Sprite2D") if team == TEAM.WHITE: sprite2d.region_rect = Rect2(234, 8, 26, 34) elif team == TEAM.BLACK: sprite2d.region_rect = Rect2(234, 53, 26, 33) func check_move(destination: Vector2i) -> bool: var enemy_exists = false var board_state = get_board_state() if board_state.has(destination): if board_state[destination].team == team: return false else: enemy_exists = true var dx = abs(destination.x - grid_pos.x) var dy = abs(destination.y - grid_pos.y) var forward = dx == 0 and dy == 1 and not enemy_exists var diag = dx == 1 and dy == 1 and enemy_exists var correct_direction = false if team == TEAM.WHITE: correct_direction = destination.y - grid_pos.y < 0 elif team == TEAM.BLACK: correct_direction = destination.y - grid_pos.y > 0 if not enemy_exists and correct_direction and dy == 2: var white_row = team == TEAM.WHITE and grid_pos.y == 6 var black_row = team == TEAM.BLACK and grid_pos.y == 1 return path_empty(destination) and (white_row or black_row) return correct_direction and (forward or diag)