From 03c964b9ab0f5161c95932ea6e1a8291675ea47c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 19:11:32 +0100 Subject: [PATCH] :art: Format Python code with psf/black (#33) Co-authored-by: VincentAuriau --- pyalapin/engine/engine.py | 4 +++- pyalapin/engine/move.py | 14 +++++++++++--- tests/unit_test/engine_test.py | 3 +-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pyalapin/engine/engine.py b/pyalapin/engine/engine.py index 5e8e94d..e4a7057 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"