add move preconditions
This commit is contained in:
@@ -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'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user