Files
3DChess/app/src/main/java/chess/controller/commands/GetAllowedCastlingsCommand.java
fl.du.pr Grens 97950403a5
All checks were successful
Linux arm64 / Build (push) Successful in 33s
class documentation - a shitload of it
2025-05-18 20:08:22 +02:00

41 lines
895 B
Java

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;
}
}