From: Simon Cross Date: Sat, 10 Sep 2016 16:01:10 +0000 (+0200) Subject: Change turnip target to a property. X-Git-Tag: tabakrolletjie-v1.0.0~79 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=7e9fe5eb24342f9f5a6421e1c424aab596010dd0;p=tabakrolletjie.git Change turnip target to a property. --- diff --git a/tabakrolletjie/gamestate.py b/tabakrolletjie/gamestate.py index 219edfb..9fe4fc8 100644 --- a/tabakrolletjie/gamestate.py +++ b/tabakrolletjie/gamestate.py @@ -29,8 +29,9 @@ class GameState(object): def seeds(self): 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"] + "seeds" in self._state["station"]["config"]): + self._state["seeds"] = ( + self._state["station"]["config"]["seeds"]) else: self._state["seeds"] = 0 return self._state["seeds"] @@ -48,5 +49,6 @@ class GameState(object): def get_spawn_positions(self): return self._state["station"]["config"]["spawn positions"] - def get_target(self): + @property + def turnip_target(self): return self._state["station"]["config"]["turnip target"] diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 485952e..0a08152 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -51,7 +51,7 @@ class DayScene(BaseScene): self._game_over_text = [] if gamestate.seeds == 0 and len(self._turnips) == 0: self._draw_you_lose(gamestate) - elif gamestate.harvested >= gamestate.get_target(): + elif gamestate.harvested >= gamestate.turnip_target: self._draw_you_win(gamestate) def _draw_you_lose(self, gamestate): @@ -301,7 +301,7 @@ class DayScene(BaseScene): def _update_infobar(self, gamestate): line1 = ("Day %d: Goal: %d Turnips. Turnips harvested: %d" % ( - gamestate.days, gamestate.get_target(), gamestate.harvested)) + gamestate.days, gamestate.turnip_target, gamestate.harvested)) line1_img = self._infobar_font.render(line1, True, (255, 255, 255)) line2 = ("Turnip Stocks: Seeds: %s. Planted: %d. Battery: %d/%d" % ( gamestate.seeds, len(self._turnips), self._battery.current,