Change turnip target to a property.
authorSimon Cross <hodgestar@gmail.com>
Sat, 10 Sep 2016 16:01:10 +0000 (18:01 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 10 Sep 2016 16:01:10 +0000 (18:01 +0200)
tabakrolletjie/gamestate.py
tabakrolletjie/scenes/day.py

index 219edfb3f5c87c0a21411c3c1023f04a1c12b2f9..9fe4fc85d3557ea0d991a48e664c3627b0912bf3 100644 (file)
@@ -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"]
index 485952e9b19f5c19a3a7a8f9310247f6df9eff91..0a08152f1334384c48f9967e5b5443ed502aeebc 100644 (file)
@@ -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,