package chess.controller.commands; import chess.controller.Command; import chess.controller.event.GameListener; import chess.model.Game; /** * Command to check the possible Castling. */ public class GetAllowedCastlingsCommand extends Command{ public enum CastlingResult { None, Small, Big, Both; } private CastlingResult castlingResult; public GetAllowedCastlingsCommand() {} @Override public CommandResult execute(Game game, GameListener outputSystem) { boolean canSmallCastle = game.getBoard().canSmallCastle(game.getPlayerTurn()); boolean canBigCastle = game.getBoard().canBigCastle(game.getPlayerTurn()); int result = 0; if (canSmallCastle) result += 1; if (canBigCastle) result += 2; this.castlingResult = CastlingResult.values()[result]; return CommandResult.NotMoved; } public CastlingResult getCastlingResult() { return castlingResult; } }