1 """ Keep 'em charged and they'll never let you down. """
4 class BatteryManager(object):
5 """ Manages a battery. """
7 def __init__(self, gamestate):
8 self._state = gamestate.station["battery"]
12 return self._state["current"]
15 def current(self, value):
16 self._state["current"] = min(max(0, value), self.max)
20 return self._state["max"]
24 self._state["max"] = max(0, value)
28 return self._state["recharge"]
31 def recharge(self, value):
32 self._state["recharge"] = max(0, value)
34 def apply_recharge(self):
35 self.current += self.recharge