Skip to content

Commit

Permalink
FIX: promotion bug - undesired check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dfeprado committed Aug 16, 2024
1 parent 0b1fcdb commit fcd903e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ hs_err_pid*

# Eclipse
.settings/
/bin/
2 changes: 2 additions & 0 deletions src/chess/ChessMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fcd903e

Please sign in to comment.