-
Notifications
You must be signed in to change notification settings - Fork 1
/
stage.py
78 lines (57 loc) · 1.93 KB
/
stage.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from mushyutils import swatch
class Stage(object):
__slots__ = ("objects", "title", "body", "brushes")
def __init__(self):
self.brushes = {}
self.objects = {}
self.title = ""
self.body = ""
def paintSceneTitle(self, title):
self.title = title
def paintSceneBody(self, body):
self.body = body
def viewScene(self):
ret = ""
if self.title == "" and self.body == "":
ret = ""
if self.title != "" and self.body != "":
ret = ret + self.title + "\n" + self.body
elif self.title == "":
ret = ret + self.body
elif self.body == "":
ret = ret + self.title
if len(self.objects) == 0:
return ret
ret = ret + "\nYou see a few items of interest:\n"
for item in self.objects:
ret = ret + " " + item + "\n"
return ret
def paintObject(self, identifier, description):
self.objects[identifier.lower()] = description
def viewObject(self, identifier):
if identifier.lower() in self.objects:
return self.objects[identifier.lower()]
return ""
def eraseObject(self, identifier):
if identifier.lower() in self.objects:
del self.objects[identifier.lower()]
def wipeScene(self):
self.title = ""
self.body = ""
def wipeObjects(self):
self.objects.clear()
def _initBrush(self, entity):
if not entity in self.brushes:
self.brushes[entity] = "white"
def setBrush(self, entity, color):
self._initBrush(entity)
if color in swatch:
self.brushes[entity] = color
else:
self.brushes[entity] = "white"
def resetBrush(self, entity):
self._initBrush(entity)
self.brushes[entity] = "white"
def getBrush(self, entity):
self._initBrush(entity)
return self.brushes[entity]