瀏覽代碼

feat: give GameState a reference to GameActor

Can use this on AI turns etc to send messages back to frontend
rdh-local-prototype-endturn
Rob Hallam 9 月之前
父節點
當前提交
bef929df9f
共有 2 個檔案被更改,包括 12 行新增0 行删除
  1. +2
    -0
      app/actors/GameActor.java
  2. +10
    -0
      app/structures/GameState.java

+ 2
- 0
app/actors/GameActor.java 查看文件

@@ -64,6 +64,8 @@ public class GameActor extends AbstractActor {
// Initalize a new game state object
gameState = new GameState();
// #hack: give the game state a reference to the game actor so AIPlayer can send messages
gameState.gameActor = this;
// Get the list of image files to pre-load the UI with
Set<String> images = ImageListForPreLoad.getImageListForPreLoad();


+ 10
- 0
app/structures/GameState.java 查看文件

@@ -1,5 +1,8 @@
package structures;
import actors.GameActor;
import structures.basic.AIPlayer;
/**
* This class can be used to hold information about the on-going game.
* Its created with the GameActor.
@@ -13,5 +16,12 @@ public class GameState {
public boolean gameInitalised = false;
public boolean something = false;
public int currentPlayer = 1;
public AIPlayer aiPlayer = new AIPlayer();
// bit of a hack but include a reference to the GameActor so AIPlayer can send messages to it
public GameActor gameActor;
}

Loading…
取消
儲存