Browse Source

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 2 months ago
parent
commit
bef929df9f
2 changed files with 12 additions and 0 deletions
  1. +2
    -0
      app/actors/GameActor.java
  2. +10
    -0
      app/structures/GameState.java

+ 2
- 0
app/actors/GameActor.java View File

@@ -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 View File

@@ -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…
Cancel
Save