fix console promote

This commit is contained in:
2025-04-15 18:31:09 +02:00
parent 1a038a3de1
commit ae0e76a452
5 changed files with 108 additions and 59 deletions

View File

@@ -21,7 +21,7 @@ public class CastlingCommand extends PlayerCommand {
@Override
public CommandResult execute(Game game, GameListener outputSystem) {
final ChessBoard board = game.getBoard();
// we must promote the pending pawn before
if (board.pawnShouldBePromoted())
return CommandResult.NotAllowed;
@@ -39,7 +39,7 @@ public class CastlingCommand extends PlayerCommand {
int kingEndX = bigCastling ? 2 : 6;
int colorLine = game.getPlayerTurn() == Color.White ? 7 : 0;
Coordinate kingCoords = new Coordinate(kingBeginX, colorLine);
Coordinate rookCoords = new Coordinate(rookBeginX, colorLine);
@@ -52,6 +52,10 @@ public class CastlingCommand extends PlayerCommand {
return CommandResult.Moved;
}
public boolean isBigCastling() {
return bigCastling;
}
@Override
protected CommandResult undoImpl(Game game, GameListener outputSystem) {
game.getBoard().undoMove(this.kingMove, null);