소스 검색

feat: move GameActor reference into AIPlayer

This avoid the ugly hack of keeping a referenec in GameState
rdh-local-prototype-endturn
Rob Hallam 9 달 전
부모
커밋
7686cdd652
1개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. +8
    -2
      app/structures/basic/AIPlayer.java

+ 8
- 2
app/structures/basic/AIPlayer.java 파일 보기

@@ -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);

}



불러오는 중...
취소
저장