add CommandResult.NeedsAction
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package chess.io;
|
||||
|
||||
import chess.io.Command.CommandResult;
|
||||
import chess.io.commands.MoveCommand;
|
||||
import chess.model.Game;
|
||||
import chess.model.Game.GameStatus;
|
||||
|
||||
@@ -29,21 +28,21 @@ public class CommandExecutor {
|
||||
}
|
||||
|
||||
private void processResult(Command command, CommandResult result) {
|
||||
if (result != CommandResult.Moved)
|
||||
return;
|
||||
|
||||
if (command instanceof MoveCommand move) {
|
||||
boolean needsPromote = this.game.pawnShouldBePromoted();
|
||||
if (needsPromote)
|
||||
this.outputSystem.promotePawn(move.getMove().getFinish());
|
||||
|
||||
if (checkGameStatus())
|
||||
switch (result) {
|
||||
case NotAllowed:
|
||||
case NotMoved:
|
||||
return;
|
||||
|
||||
if(!needsPromote)
|
||||
case ActionNeeded:
|
||||
this.outputSystem.updateDisplay();
|
||||
return;
|
||||
|
||||
case Moved:
|
||||
if (checkGameStatus())
|
||||
return;
|
||||
switchPlayerTurn();
|
||||
} else if (command instanceof PlayerCommand) {
|
||||
switchPlayerTurn();
|
||||
this.outputSystem.updateDisplay();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ public class CommandExecutor {
|
||||
case Check:
|
||||
this.outputSystem.kingIsInCheck();
|
||||
return false;
|
||||
|
||||
|
||||
case CheckMate:
|
||||
this.outputSystem.kingIsInMat();
|
||||
this.outputSystem.winnerIs(this.game.getPlayerTurn());
|
||||
|
||||
Reference in New Issue
Block a user