From fcd903ed420793e35a3e783570a6794f9f1f0aa3 Mon Sep 17 00:00:00 2001 From: Daniel Prado Date: Thu, 15 Aug 2024 21:30:15 -0300 Subject: [PATCH] FIX: promotion bug - undesired check If a black king is sitting on row 8 and a paw is promoted to a bishop, and there's no piece between these two, the unfixed code would evaluate to a check. This commit fix this bug. --- .gitignore | 1 + src/chess/ChessMatch.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index af3aedd..591c0bd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ hs_err_pid* # Eclipse .settings/ +/bin/ diff --git a/src/chess/ChessMatch.java b/src/chess/ChessMatch.java index 4fe88b9..40e9021 100644 --- a/src/chess/ChessMatch.java +++ b/src/chess/ChessMatch.java @@ -133,6 +133,8 @@ public ChessPiece replacePromotedPiece(String type) { board.placePiece(newPiece, pos); piecesOnTheBoard.add(newPiece); + check = (testCheck(opponent(newPiece.getColor()))) ? true : false; + return newPiece; }