Files
3DChess/app/src/main/java/chess/controller/commands/GetPieceAtCommand.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

37 lines
772 B
Java

package chess.controller.commands;
import chess.controller.Command;
import chess.controller.event.GameListener;
import chess.model.Coordinate;
import chess.model.Game;
import chess.model.Piece;
/**
* Command to check the possible moves for a given piece.
*/
public class GetPieceAtCommand extends Command{
private final Coordinate pieceCoords;
private Piece piece;
public GetPieceAtCommand(Coordinate pieceCoords) {
this.pieceCoords = pieceCoords;
this.piece = null;
}
@Override
public CommandResult execute(Game game, GameListener outputSystem) {
if (!pieceCoords.isValid())
return CommandResult.NotAllowed;
this.piece = game.getBoard().pieceAt(pieceCoords);
return CommandResult.NotMoved;
}
public Piece getPiece() {
return piece;
}
}