From 11531f629a3ab04fbd2b470cd46ff7bef0405b18 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 10 Sep 2016 16:47:56 +0200 Subject: [PATCH] Add end day. --- tabakrolletjie/scenes/day.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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()) -- 2.34.1