diff --git a/pyalapin/engine/engine.py b/pyalapin/engine/engine.py index 8e959aa..bdf26e2 100644 --- a/pyalapin/engine/engine.py +++ b/pyalapin/engine/engine.py @@ -968,7 +968,9 @@ class Game: game_status = [] - def __init__(self, player1=None, player2=None, automatic_draw=True, ai=False, save_pgn=False): + def __init__( + self, player1=None, player2=None, automatic_draw=True, ai=False, save_pgn=False + ): """Initialization of the cell. Parameters diff --git a/pyalapin/engine/move.py b/pyalapin/engine/move.py index 5a7deea..c2d5261 100644 --- a/pyalapin/engine/move.py +++ b/pyalapin/engine/move.py @@ -124,12 +124,20 @@ def to_pgn(self): if self.killed_piece is not None: start = "x" elif self.is_castling: - if (self.moved_piece.is_white() and self.end.y == 1) or (not self.moved_piece.is_white() and self.end.y == 6): + if (self.moved_piece.is_white() and self.end.y == 1) or ( + not self.moved_piece.is_white() and self.end.y == 6 + ): piece = "O-O-O" start = "" end = "" - king = self.board.white_king if not self.player.white_side else self.board.black_king - if self.board.get_cell(king.x, king.y).is_threatened(board=self.board, threaten_color=not self.player.white_side): + king = ( + self.board.white_king + if not self.player.white_side + else self.board.black_king + ) + if self.board.get_cell(king.x, king.y).is_threatened( + board=self.board, threaten_color=not self.player.white_side + ): end += "+" print(piece, start, end) diff --git a/tests/unit_test/engine_test.py b/tests/unit_test/engine_test.py index 69fb78e..810b3e2 100644 --- a/tests/unit_test/engine_test.py +++ b/tests/unit_test/engine_test.py @@ -149,6 +149,5 @@ def test_pgn(): game.move_from_coordinates(game.player2, 6, 5, 4, 5) game.move_from_coordinates(game.player1, 0, 3, 4, 7) game.move_from_coordinates(game.player2, 6, 6, 5, 6) - - assert game.to_pgn() == "1.e4 f5 2.Qh5+ g6" + assert game.to_pgn() == "1.e4 f5 2.Qh5+ g6"