From: adrianna Date: Sat, 10 Sep 2016 14:54:36 +0000 (+0200) Subject: clear turnips on level load; invalidate seeds on level load; less magical seeds property X-Git-Tag: tabakrolletjie-v1.0.0~85 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=0af42efcd7671a3980261c05890aa2f5c0ca2c9b;p=tabakrolletjie.git clear turnips on level load; invalidate seeds on level load; less magical seeds property --- 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"]