clear turnips on level load; invalidate seeds on level load; less magical seeds property
authoradrianna <adrianna.pinska@gmail.com>
Sat, 10 Sep 2016 14:54:36 +0000 (16:54 +0200)
committeradrianna <adrianna.pinska@gmail.com>
Sat, 10 Sep 2016 14:54:44 +0000 (16:54 +0200)
tabakrolletjie/gamestate.py

index 8d74d8106fcfc39e6199512903d09dc452a99744..27762a6d7e086c3dae50bff4226cfe4ee085708a 100644 (file)
@@ -6,6 +6,7 @@ class GameState(object):
         self._state = {
             "station": None,
             "turnips": [],
+            "seeds": None,
         }
         self.harvested = 0
         self.eaten = 0
@@ -25,13 +26,13 @@ class GameState(object):
 
     @property
     def seeds(self):
-        if 'seeds' in self._state:
-            return self._state['seeds']
-        elif (self._state["station"] and
-                'seeds' in self._state["station"]["config"]):
-            self._state['seeds'] = self._state["station"]["config"]["seeds"]
-            return self._state['seeds']
-        return 0
+        if self._state["seeds"] is None:
+            if (self._state["station"] and
+                        "seeds" in self._state["station"]["config"]):
+                self._state["seeds"] = self._state["station"]["config"]["seeds"]
+            else:
+                self._state["seeds"] = 0
+        return self._state["seeds"]
 
     @seeds.setter
     def seeds(self, value):
@@ -39,6 +40,8 @@ class GameState(object):
 
     def set_station(self, station):
         self._state["station"] = station
+        self._state["turnips"] = []
+        self._state["seeds"] = None
 
     def get_spawn_positions(self):
         return self._state["station"]["config"]["spawn positions"]