diff --git a/app/src/main/java/chess/io/commands/CastlingCommand.java b/app/src/main/java/chess/io/commands/CastlingCommand.java index 132c76b..13cca93 100644 --- a/app/src/main/java/chess/io/commands/CastlingCommand.java +++ b/app/src/main/java/chess/io/commands/CastlingCommand.java @@ -4,10 +4,14 @@ import chess.io.OutputSystem; import chess.io.PlayerCommand; import chess.model.Game; -public class CastlingCommand extends PlayerCommand{ +public class CastlingCommand extends PlayerCommand { @Override public CommandResult execute(Game game, OutputSystem outputSystem) { + // we must promote the pending pawn before + if (game.pawnShouldBePromoted()) + return CommandResult.NotAllowed; + return CommandResult.NotAllowed; } @@ -16,5 +20,5 @@ public class CastlingCommand extends PlayerCommand{ // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'undo'"); } - + } diff --git a/app/src/main/java/chess/io/commands/GrandCastlingCommand.java b/app/src/main/java/chess/io/commands/GrandCastlingCommand.java index 12e9a31..19b9289 100644 --- a/app/src/main/java/chess/io/commands/GrandCastlingCommand.java +++ b/app/src/main/java/chess/io/commands/GrandCastlingCommand.java @@ -8,6 +8,10 @@ public class GrandCastlingCommand extends PlayerCommand { @Override public CommandResult execute(Game game, OutputSystem outputSystem) { + // we must promote the pending pawn before + if (game.pawnShouldBePromoted()) + return CommandResult.NotAllowed; + return CommandResult.NotAllowed; }