Update TODO.
[tabakrolletjie.git] / tabakrolletjie / battery.py
1 """ Keep 'em charged and they'll never let you down. """
2
3
4 class BatteryManager(object):
5     """ Manages a battery. """
6
7     def __init__(self, gamestate):
8         self._state = gamestate.station["battery"]
9
10     @property
11     def current(self):
12         return self._state["current"]
13
14     @current.setter
15     def current(self, value):
16         self._state["current"] = min(max(0, value), self.max)
17
18     @property
19     def max(self):
20         return self._state["max"]
21
22     @max.setter
23     def max(self, value):
24         self._state["max"] = max(0, value)
25
26     @property
27     def recharge(self):
28         return self._state["recharge"]
29
30     @recharge.setter
31     def recharge(self, value):
32         self._state["recharge"] = max(0, value)
33
34     def apply_recharge(self):
35         self.current += self.recharge