-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.py
44 lines (33 loc) · 1.05 KB
/
state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""UI state."""
class State():
"""UI state."""
def __init__(self):
self._colour = 'black'
self._mode = 'normal'
self._solution = None
# Access state
def colour(self):
"""Return current colour."""
return self._colour
def mode(self):
"""Return current mode."""
return self._mode
def solution(self):
"""Return index of current solution branch."""
return self._solution
# Change state
def swap_colour(self):
"""Change colour: black <-> white."""
self._colour = {'white': 'black',
'black': 'white'}[self._colour]
def cycle_mode(self):
"""Cycle mode: normal -> paint -> erase -> normal."""
self._mode = {'normal': 'paint',
'paint': 'erase',
'erase': 'normal'}[self._mode]
def set_mode(self, mode):
"""Set mode."""
self._mode = mode
def set_solution(self, solution):
"""Set solution index."""
self._solution = solution