From: Simon Cross Date: Sat, 10 Sep 2016 14:47:56 +0000 (+0200) Subject: Add end day. X-Git-Tag: tabakrolletjie-v1.0.0~92 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=11531f629a3ab04fbd2b470cd46ff7bef0405b18;p=tabakrolletjie.git Add end day. --- diff --git a/tabakrolletjie/scenes/day.py b/tabakrolletjie/scenes/day.py index 968f241..aff92a6 100644 --- a/tabakrolletjie/scenes/day.py +++ b/tabakrolletjie/scenes/day.py @@ -10,6 +10,7 @@ import pymunk import pymunk.pygame_util from .base import BaseScene +from ..battery import BatteryManager from ..lights import LightManager, light_fitting_by_type from ..obstacles import ObstacleManager from ..events import SceneChangeEvent @@ -31,6 +32,7 @@ class DayScene(BaseScene): self._toolbar_font = loader.load_font(FONTS['sans'], size=20) self._obstacles = ObstacleManager(self._space, gamestate) self._lights = LightManager(self._space, gamestate) + self._battery = BatteryManager(gamestate) self._turnips = [] self._seeds = gamestate.seeds self._harvested = gamestate.harvested @@ -109,6 +111,11 @@ class DayScene(BaseScene): turnip_data = [turnip.serialize() for turnip in self._turnips] gamestate.turnips = turnip_data + def end_day(self, gamestate): + self._battery.apply_recharge() + from .night import NightScene + SceneChangeEvent.post(scene=NightScene()) + @debug_timer("day.render") def render(self, surface, gamestate): surface.blit(self._soil, (0, 0)) @@ -203,8 +210,7 @@ class DayScene(BaseScene): from .menu import MenuScene SceneChangeEvent.post(scene=MenuScene()) elif ev.key == pgl.K_e: - from .night import NightScene - SceneChangeEvent.post(scene=NightScene()) + self.end_day(gamestate) elif ev.key == pgl.K_SPACE: self._paused = not self._paused elif ev.type == pgl.MOUSEBUTTONDOWN: @@ -218,8 +224,7 @@ class DayScene(BaseScene): self._tool = None self._clear_light_toolbar() elif tool.name == 'start night': - from .night import NightScene - SceneChangeEvent.post(scene=NightScene()) + self.end_day(gamestate) elif tool.name == 'exit': from .menu import MenuScene SceneChangeEvent.post(scene=MenuScene())