refactor: move promote to chessboard
This commit is contained in:
@@ -20,11 +20,11 @@ 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;
|
||||
|
||||
final ChessBoard board = game.getBoard();
|
||||
|
||||
// we must promote the pending pawn before
|
||||
if (board.pawnShouldBePromoted())
|
||||
return CommandResult.NotAllowed;
|
||||
|
||||
if (bigCastling && !board.canBigCastle(game.getPlayerTurn()))
|
||||
return CommandResult.NotAllowed;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class MoveCommand extends PlayerCommand {
|
||||
final ChessBoard board = game.getBoard();
|
||||
|
||||
// we must promote the pending pawn before
|
||||
if (game.pawnShouldBePromoted())
|
||||
if (board.pawnShouldBePromoted())
|
||||
return CommandResult.NotAllowed;
|
||||
|
||||
Piece piece = board.pieceAt(move.getStart());
|
||||
@@ -50,7 +50,7 @@ public class MoveCommand extends PlayerCommand {
|
||||
return CommandResult.NotAllowed;
|
||||
}
|
||||
|
||||
if (game.pawnShouldBePromoted())
|
||||
if (board.pawnShouldBePromoted())
|
||||
return CommandResult.ActionNeeded;
|
||||
|
||||
board.setLastMove(this.move);
|
||||
@@ -71,7 +71,7 @@ public class MoveCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
private void tryPromote(Game game, OutputSystem outputSystem) {
|
||||
Coordinate pawnPos = game.pawnPromotePosition();
|
||||
Coordinate pawnPos = game.getBoard().pawnPromotePosition();
|
||||
|
||||
if (pawnPos == null)
|
||||
return;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PromoteCommand extends PlayerCommand {
|
||||
public CommandResult execute(Game game, OutputSystem outputSystem) {
|
||||
final ChessBoard board = game.getBoard();
|
||||
|
||||
this.pieceCoords = game.pawnPromotePosition();
|
||||
this.pieceCoords = board.pawnPromotePosition();
|
||||
|
||||
if (this.pieceCoords == null)
|
||||
return CommandResult.NotAllowed;
|
||||
|
||||
Reference in New Issue
Block a user