From 0af42efcd7671a3980261c05890aa2f5c0ca2c9b Mon Sep 17 00:00:00 2001 From: adrianna Date: Sat, 10 Sep 2016 16:54:36 +0200 Subject: [PATCH] clear turnips on level load; invalidate seeds on level load; less magical seeds property --- tabakrolletjie/gamestate.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tabakrolletjie/gamestate.py b/tabakrolletjie/gamestate.py index 8d74d81..27762a6 100644 --- a/tabakrolletjie/gamestate.py +++ b/tabakrolletjie/gamestate.py @@ -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"] -- 2.34.1