forked from OoTRandomizer/OoT-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Region.py
129 lines (97 loc) · 4.24 KB
/
Region.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from enum import Enum, unique
@unique
class RegionType(Enum):
Overworld = 1
Interior = 2
Dungeon = 3
Grotto = 4
@property
def is_indoors(self):
"""Shorthand for checking if Interior or Dungeon"""
return self in (RegionType.Interior, RegionType.Dungeon, RegionType.Grotto)
# Pretends to be an enum, but when the values are raw ints, it's much faster
class TimeOfDay(object):
NONE = 0
DAY = 1
DAMPE = 2
ALL = DAY | DAMPE
class Region(object):
def __init__(self, name, type=RegionType.Overworld):
self.name = name
self.type = type
self.entrances = []
self.exits = []
self.locations = []
self.dungeon = None
self.world = None
self.hint_name = None
self.price = None
self.world = None
self.time_passes = False
self.provides_time = TimeOfDay.NONE
self.scene = None
def copy(self, new_world):
new_region = Region(self.name, self.type)
new_region.world = new_world
new_region.price = self.price
new_region.hint_name = self.hint_name
new_region.time_passes = self.time_passes
new_region.provides_time = self.provides_time
new_region.scene = self.scene
if self.dungeon:
new_region.dungeon = self.dungeon.name
new_region.locations = [location.copy(new_region) for location in self.locations]
new_region.exits = [exit.copy(new_region) for exit in self.exits]
return new_region
@property
def hint(self):
from Hints import HintArea
if self.hint_name is not None:
return HintArea[self.hint_name]
if self.dungeon:
return self.dungeon.hint
def can_fill(self, item, manual=False):
from Hints import HintArea
is_self_dungeon_restricted = False
is_dungeon_restricted = False
is_overworld_restricted = False
if item.map or item.compass:
is_self_dungeon_restricted = self.world.settings.shuffle_mapcompass in ['dungeon', 'vanilla']
is_dungeon_restricted = self.world.settings.shuffle_mapcompass == 'any_dungeon'
is_overworld_restricted = self.world.settings.shuffle_mapcompass == 'overworld'
elif item.type == 'SmallKey':
is_self_dungeon_restricted = self.world.settings.shuffle_smallkeys in ['dungeon', 'vanilla']
is_dungeon_restricted = self.world.settings.shuffle_smallkeys == 'any_dungeon'
is_overworld_restricted = self.world.settings.shuffle_smallkeys == 'overworld'
elif item.type == 'HideoutSmallKey':
is_dungeon_restricted = self.world.settings.shuffle_hideoutkeys == 'any_dungeon'
is_overworld_restricted = self.world.settings.shuffle_hideoutkeys == 'overworld'
elif item.type == 'BossKey':
is_self_dungeon_restricted = self.world.settings.shuffle_bosskeys in ['dungeon', 'vanilla']
is_dungeon_restricted = self.world.settings.shuffle_bosskeys == 'any_dungeon'
is_overworld_restricted = self.world.settings.shuffle_bosskeys == 'overworld'
elif item.type == 'GanonBossKey':
is_self_dungeon_restricted = self.world.settings.shuffle_ganon_bosskey in ['dungeon', 'vanilla']
is_dungeon_restricted = self.world.settings.shuffle_ganon_bosskey == 'any_dungeon'
is_overworld_restricted = self.world.settings.shuffle_ganon_bosskey == 'overworld'
if is_self_dungeon_restricted and not manual:
hint_area = HintArea.at(self)
return hint_area.is_dungeon and hint_area.is_dungeon_item(item) and item.world.id == self.world.id
if is_dungeon_restricted and not manual:
return HintArea.at(self).is_dungeon
if is_overworld_restricted and not manual:
return not HintArea.at(self).is_dungeon
if item.name == 'Triforce Piece':
return item.world.id == self.world.id
return True
def get_scene(self):
if self.scene:
return self.scene
elif self.dungeon:
return self.dungeon.name
else:
return None
def __str__(self):
return str(self.__unicode__())
def __unicode__(self):
return '%s' % self.name