Exemplo n.º 1
0
    def get_attacking_squares(self, player=None):
        if not player:
            player = self.current_player
        pieces = self.get_pieces(player)
        attacking_squares = set()
        for piece_position in pieces:
            x, y = piece_position
            if self.board[x][y].type == "p":
                direction = -1 if self.board[x][y].color == "W" else +1
                if self.within_boundaries(x + direction, y - 1):
                    attacking_squares.add((x + direction, y - 1))
                if self.within_boundaries(x + direction, y + 1):
                    attacking_squares.add((x + direction, y + 1))
            else:
                attacking_squares.update(Piece.attack(self, piece_position))

        return attacking_squares