promote gui

This commit is contained in:
2025-04-03 22:06:34 +02:00
parent 927ba129f6
commit 0d72e015f1
5 changed files with 91 additions and 15 deletions

View File

@@ -24,6 +24,10 @@ public class MoveCommand extends Command {
public CommandResult execute(Game game, OutputSystem outputSystem) {
final ChessBoard board = game.getBoard();
// we must promote the pending pawn before
if (game.pawnShouldBePromoted())
return CommandResult.NotAllowed;
Piece piece = board.pieceAt(move.getStart());
if (piece == null)
return CommandResult.NotAllowed;

View File

@@ -49,7 +49,7 @@ public class PromoteCommand extends Command {
board.pieceLeaves(this.pieceCoords);
board.pieceComes(createPiece(this.promoteType, pawn.getColor()), this.pieceCoords);
return CommandResult.NotMoved;
return CommandResult.Moved;
}
private Piece createPiece(PromoteType promoteType, Color color) {