Explorar el Código

feat: move GameActor reference into AIPlayer

This avoid the ugly hack of keeping a referenec in GameState
rdh-local-prototype-endturn
Rob Hallam hace 9 meses
padre
commit
7686cdd652
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. +8
    -2
      app/structures/basic/AIPlayer.java

+ 8
- 2
app/structures/basic/AIPlayer.java Ver fichero

@@ -8,13 +8,20 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import actors.GameActor;
import akka.actor.ActorRef;

public class AIPlayer extends Player {
private GameActor gameActor;

public AIPlayer() {
super();
}

public AIPlayer(GameActor gameActor) {
super();
this.gameActor = gameActor;
}
public void takeTurn(ActorRef out, GameState gameState) {
// addPlayer2Notification
BasicCommands.addPlayer2Notification(out, "My turn!", 2);
@@ -30,11 +37,10 @@ public class AIPlayer extends Player {
((ObjectNode) message).put("player", "AI");
// then send it to the GameActor:
try {
gameState.gameActor.processMessage("endturnclicked", message);
this.gameActor.processMessage("endturnclicked", message);
} catch (Exception e) {
e.printStackTrace();
}
// gameState.gameActor.receive(message);

}



Cargando…
Cancelar
Guardar