Selaa lähdekoodia

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 kuukautta sitten
vanhempi
commit
bef929df9f
2 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. +2
    -0
      app/actors/GameActor.java
  2. +10
    -0
      app/structures/GameState.java

+ 2
- 0
app/actors/GameActor.java Näytä tiedosto

@@ -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 Näytä tiedosto

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

Ladataan…
Peruuta
Tallenna