forked from OoTRandomizer/OoT-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dungeon.py
56 lines (38 loc) · 1.51 KB
/
Dungeon.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
class Dungeon(object):
def __init__(self, world, name, hint, boss_key, small_keys, dungeon_items):
def to_array(obj):
if obj == None:
return []
if isinstance(obj, list):
return obj
else:
return [obj]
self.world = world
self.name = name
self.hint = hint
self.regions = []
self.boss_key = to_array(boss_key)
self.small_keys = to_array(small_keys)
self.dungeon_items = to_array(dungeon_items)
for region in world.regions:
if region.dungeon == self.name:
region.dungeon = self
self.regions.append(region)
def copy(self, new_world):
new_boss_key = [item.copy(new_world) for item in self.boss_key]
new_small_keys = [item.copy(new_world) for item in self.small_keys]
new_dungeon_items = [item.copy(new_world) for item in self.dungeon_items]
new_dungeon = Dungeon(new_world, self.name, self.hint, new_boss_key, new_small_keys, new_dungeon_items)
return new_dungeon
@property
def keys(self):
return self.small_keys + self.boss_key
@property
def all_items(self):
return self.dungeon_items + self.keys
def is_dungeon_item(self, item):
return item.name in [dungeon_item.name for dungeon_item in self.all_items]
def __str__(self):
return str(self.__unicode__())
def __unicode__(self):
return '%s' % self.name