Files
3DChess/app/src/main/java/chess/controller/commands/GetAllowedCastlingsCommand.java
2025-04-14 10:34:54 +02:00

38 lines
844 B
Java

package chess.controller.commands;
import chess.controller.Command;
import chess.controller.event.GameListener;
import chess.model.Game;
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;
}
}