From dab2ea78c67a97a4219a4671cb29b417ea05fcbe Mon Sep 17 00:00:00 2001
From: Nao Pross <naopross@thearcway.org>
Date: Tue, 20 Nov 2018 18:20:36 +0100
Subject: Add currentMap to Game, waitStateChange now returns the new state

---
 src/subconscious/Game.java                | 9 ++++++++-
 src/subconscious/graphics/GameWindow.java | 4 ++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/subconscious/Game.java b/src/subconscious/Game.java
index dc7d109..7fd8b33 100644
--- a/src/subconscious/Game.java
+++ b/src/subconscious/Game.java
@@ -24,6 +24,7 @@ public class Game {
 
     private ArrayList<Actor> actors;
     private ArrayList<Map> maps;
+    private Map currentMap;
 
     public Game() {
         this.setState(State.MENU);
@@ -39,6 +40,10 @@ public class Game {
         this.setState(State.DREAM);
     }
 
+    public Map getCurrentMap() {
+        return currentMap;
+    }
+
     /* methods to manage the state */
     public void setState(State state) {
         if (this.state == state)
@@ -52,9 +57,11 @@ public class Game {
         return this.state;
     }
 
-    public void waitStateChange() {
+    public State waitStateChange() {
         while (!this.stateChanged);
         this.stateChanged = false;
+
+        return this.state;
     }
 
     /* accessors */
diff --git a/src/subconscious/graphics/GameWindow.java b/src/subconscious/graphics/GameWindow.java
index ce99df5..19f8ce1 100644
--- a/src/subconscious/graphics/GameWindow.java
+++ b/src/subconscious/graphics/GameWindow.java
@@ -88,9 +88,9 @@ public class GameWindow extends JFrame implements ActionListener {
 	// ovserver of this.game
 	private void loop() {
 		while (this.game.isRunning()) {
-			this.game.waitStateChange();
+			Game.State newState = this.game.waitStateChange();
 
-			switch (this.game.getState()) {
+			switch (newState) {
 			case MENU:
 				this.loadMenu();
 				break;
-- 
cgit v1.2.1