Display power usage per hour.
[tabakrolletjie.git] / tabakrolletjie / scenes / night.py
index e4cc73384b9c433f61755cfd16fe73a35226770f..580d140a6941475cfeefc1f295e2b51ec82312b7 100644 (file)
@@ -18,13 +18,13 @@ from ..transforms import Overlay
 from ..turnip import Turnip
 from ..widgets import ImageButton
 from ..constants import (
-    NIGHT_LENGTH, NIGHT_LENGTH_HOURS, DEBUG, FONTS, SCREEN_SIZE, FPS)
+    NIGHT_LENGTH, NIGHT_HOURS_PER_TICK, DEBUG, FONTS,
+    SCREEN_SIZE, FPS)
 
 
 class NightScene(BaseScene):
 
     DARKNESS = Overlay(colour=(0, 0, 0, 150))
-    HOURS_PER_TICK = float(NIGHT_LENGTH_HOURS) / NIGHT_LENGTH
 
     def enter(self, gamestate):
         self._space = pymunk.Space()
@@ -69,11 +69,13 @@ class NightScene(BaseScene):
 
     @property
     def power_usage(self):
-        return int(self._lights.total_power_usage())
+        power = self._lights.total_power_usage()
+        power = power / (FPS * NIGHT_HOURS_PER_TICK)
+        return int(round(power))
 
     def remaining_hours(self):
         return int(round(
-            (NIGHT_LENGTH - self._total_ticks) * self.HOURS_PER_TICK))
+            (NIGHT_LENGTH - self._total_ticks) * NIGHT_HOURS_PER_TICK))
 
     @debug_timer("night.render")
     def render(self, surface, gamestate):