--- /dev/null
+""" Keep 'em charged and they'll never let you down. """
+
+
+class BatteryManager(object):
+ """ Manages a battery. """
+
+ def __init__(self, gamestate):
+ self._state = gamestate.station["battery"]
+
+ @property
+ def current(self):
+ return self._state["current"]
+
+ @current.setter
+ def current(self, value):
+ self._state["current"] = min(max(0, value), self.max)
+
+ @property
+ def max(self):
+ return self._state["max"]
+
+ @max.setter
+ def max(self, value):
+ self._state["max"] = max(0, value)
+
+ @property
+ def recharge(self):
+ return self._state["recharge"]
+
+ @recharge.setter
+ def recharge(self, value):
+ self._state["recharge"] = max(0, value)
+
+ def apply_recharge(self):
+ self.current += self.recharge
+ print self.current