add general ai
This commit is contained in:
@@ -57,14 +57,14 @@ public class CommandExecutor {
|
||||
this.dispatcher.onGameEnd();
|
||||
return;
|
||||
}
|
||||
switchPlayerTurn();
|
||||
switchPlayerTurn(command instanceof UndoCommand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void switchPlayerTurn() {
|
||||
private void switchPlayerTurn(boolean undone) {
|
||||
this.game.switchPlayerTurn();
|
||||
this.dispatcher.onPlayerTurn(this.game.getPlayerTurn());
|
||||
this.dispatcher.onPlayerTurn(this.game.getPlayerTurn(), undone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public class NewGameCommand extends Command {
|
||||
game.reset();
|
||||
|
||||
outputSystem.onGameStart();
|
||||
outputSystem.onPlayerTurn(game.getPlayerTurn());
|
||||
outputSystem.onPlayerTurn(game.getPlayerTurn(), false);
|
||||
|
||||
return CommandResult.NotMoved;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EmptyGameDispatcher extends GameDispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTurn(Color color) {
|
||||
public void onPlayerTurn(Color color, boolean undone) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,7 @@ import chess.model.Move;
|
||||
public abstract class GameAdaptator implements GameListener {
|
||||
|
||||
@Override
|
||||
public void onPlayerTurn(Color color) {}
|
||||
public void onPlayerTurn(Color color, boolean undone) {}
|
||||
|
||||
@Override
|
||||
public void onWin(Color color) {}
|
||||
|
||||
@@ -29,8 +29,8 @@ public class GameDispatcher implements GameListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTurn(Color color) {
|
||||
asyncForEachCall((l) -> l.onPlayerTurn(color));
|
||||
public void onPlayerTurn(Color color, boolean undone) {
|
||||
asyncForEachCall((l) -> l.onPlayerTurn(color, undone));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,8 +56,9 @@ public interface GameListener {
|
||||
/**
|
||||
* Invoked when it's the player turn
|
||||
* @param color the color of the player who should play
|
||||
* @param undone true if it's a result of an undo command
|
||||
*/
|
||||
void onPlayerTurn(Color color);
|
||||
void onPlayerTurn(Color color, boolean undone);
|
||||
|
||||
/**
|
||||
* Invoked when a pawn should be promoted
|
||||
|
||||
Reference in New Issue
Block a user