working
This commit is contained in:
@@ -19,7 +19,7 @@ public class CommandExecutor {
|
||||
public CommandExecutor(Game game) {
|
||||
this(game, new GameDispatcher());
|
||||
}
|
||||
|
||||
|
||||
public CommandExecutor(Game game, GameDispatcher dispatcher) {
|
||||
this.game = game;
|
||||
this.dispatcher = dispatcher;
|
||||
@@ -52,18 +52,21 @@ public class CommandExecutor {
|
||||
return;
|
||||
|
||||
case Moved:
|
||||
boolean notifyPlayerTurn = true;
|
||||
this.dispatcher.onBoardUpdate();
|
||||
if (checkGameStatus()) {
|
||||
this.dispatcher.onGameEnd();
|
||||
notifyPlayerTurn = false;
|
||||
}
|
||||
switchPlayerTurn(command instanceof UndoCommand);
|
||||
switchPlayerTurn(command instanceof UndoCommand, notifyPlayerTurn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void switchPlayerTurn(boolean undone) {
|
||||
private void switchPlayerTurn(boolean undone, boolean notifyPlayerTurn) {
|
||||
this.game.switchPlayerTurn();
|
||||
this.dispatcher.onPlayerTurn(this.game.getPlayerTurn(), undone);
|
||||
if (notifyPlayerTurn)
|
||||
this.dispatcher.onPlayerTurn(this.game.getPlayerTurn(), undone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user