|
@@ -20,7 +20,19 @@ public class EndTurnClicked implements EventProcessor{ |
|
|
|
|
|
|
|
|
@Override
|
|
|
@Override
|
|
|
public void processEvent(ActorRef out, GameState gameState, JsonNode message) {
|
|
|
public void processEvent(ActorRef out, GameState gameState, JsonNode message) {
|
|
|
|
|
|
|
|
|
|
|
|
// see if we have a "player" field in the message to indicate AI player:
|
|
|
|
|
|
String player = (message.has("player")) ? message.get("player").asText() : "human";
|
|
|
|
|
|
// now we check if the game thinks it is the player who clicked end turn's actual turn:
|
|
|
|
|
|
if (gameState.currentPlayer == 1 && player.equals("human")) {
|
|
|
|
|
|
System.out.println("Player 1 clicked end turn");
|
|
|
|
|
|
gameState.currentPlayer = 2;
|
|
|
|
|
|
// hand off control to AI player:
|
|
|
|
|
|
gameState.aiPlayer.takeTurn(out, gameState);
|
|
|
|
|
|
System.out.println(String.format("%s", message.toString()));
|
|
|
|
|
|
} else if (gameState.currentPlayer == 2 && player.equals("AI")) {
|
|
|
|
|
|
System.out.println("Player 2 clicked end turn");
|
|
|
|
|
|
gameState.currentPlayer = 1;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|