fix undo draw check

This commit is contained in:
2025-04-14 11:02:35 +02:00
parent 07016be5d8
commit 91678a42b2
4 changed files with 33 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ public class MoveCommand extends PlayerCommand {
case Moved:
outputSystem.onMove(this.move);
game.saveTraitPiecesPos();
return result;
case ActionNeeded:
@@ -83,6 +84,7 @@ public class MoveCommand extends PlayerCommand {
protected CommandResult undoImpl(Game game, GameListener outputSystem) {
final ChessBoard board = game.getBoard();
game.undoTraitPiecesPos();
board.undoMove(move, deadPiece);
return CommandResult.Moved;
}

View File

@@ -48,7 +48,7 @@ public class NewGameCommand extends Command {
board.pieceComes(new Queen(Color.White), new Coordinate(3, Coordinate.VALUE_MAX - 1));
board.pieceComes(new King(Color.White), new Coordinate(4, Coordinate.VALUE_MAX - 1));
game.resetPlayerTurn();
game.reset();
outputSystem.onGameStart();
outputSystem.onPlayerTurn(game.getPlayerTurn());

View File

@@ -85,6 +85,8 @@ public class PromoteCommand extends PlayerCommand {
assert promoted != null;
game.undoTraitPiecesPos();
board.pieceComes(this.oldPawn, this.pieceCoords);
game.getLastAction().undo(game, outputSystem);