Update TODO.
[tabakrolletjie.git] / tabakrolletjie / gamestate.py
1 """ The game state. """
2
3
4 class GameState(object):
5     def __init__(self):
6         self._state = {
7             "station": None,
8             "turnips": [],
9             "seeds": None,
10         }
11         self.harvested = 0
12         self.eaten = 0
13         self.days = 0
14         self.resistances = {}
15
16     @property
17     def station(self):
18         return self._state["station"]
19
20     @property
21     def turnips(self):
22         return self._state["turnips"]
23
24     @turnips.setter
25     def turnips(self, turnip_list):
26         self._state["turnips"] = turnip_list
27
28     @property
29     def seeds(self):
30         if self._state["seeds"] is None:
31             if (self._state["station"] and
32                     "seeds" in self._state["station"]["config"]):
33                 self._state["seeds"] = (
34                     self._state["station"]["config"]["seeds"])
35             else:
36                 self._state["seeds"] = 0
37         return self._state["seeds"]
38
39     @seeds.setter
40     def seeds(self, value):
41         self._state['seeds'] = value
42
43     def set_station(self, station):
44         self._state["station"] = station
45         self._state["turnips"] = []
46         self._state["seeds"] = None
47         self.resistances = {}
48
49     def get_spawn_positions(self):
50         return self._state["station"]["config"]["spawn positions"]
51
52     @property
53     def turnip_target(self):
54         return self._state["station"]["config"]["turnip target"]
55
56     def update_lights(self, lights):
57         self._state["station"]["lights"] = lights.serialize_lights()