-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
45 lines (36 loc) · 1.7 KB
/
build.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
'''Defining class Build, which contains all doors, stairs and walls'''
from dialogs import ShopDialog
from item import Item
LIB = {(5, 3, 19): ((5, 2), 'cross'),
(9, 0, 12): ((10, 0), 'merchant'),
(9, 10, 16): ((10, 10), 'st_water'),
(8, 1, 41): ((9, 1), 'pro_witch_trigger2'),
(10, 1, 41): ((9, 1), 'pro_witch_trigger2')}
class Build(Item):
def interact(self, prot):
if self._name in ('hidden_door', 'background'):
entry = LIB.get(
(prot.get_value('i'), prot.get_value('j'), self._floor.num))
if entry:
prot.get_value('floor').set_floor(*entry[0], entry[1])
if prot.get_value('floor').num == 41 and not prot.get_value('magic_defense'):
prot.add_value("hp", -200)
else:
super().interact(prot)
elif self._name == 'hidden_wall':
prot.get_value('floor').set_floor(*self.get_position(), 'wall')
elif self._name == 'upstairs':
prot.set_value('floor', prot.get_value('tower').next_floor())
prot.move_to(
*prot.get_value('floor').get_item('downstairs') or (5, 10))
elif self._name == 'downstairs':
prot.set_value('floor', prot.get_value('tower').previous_floor())
prot.move_to(*prot.get_value('floor').get_item('upstairs'))
elif self._name in ('yellow_door', 'blue_door', 'red_door'):
if eval('prot._' + self._name[:-4] + 'key'):
exec('prot._' + self._name[:-4] + 'key' + '-=1')
super().interact(prot)
else:
print('need key!')
elif self._name == 'shop_mid':
ShopDialog(prot)