mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
core: rip out RegionType and rework Region class (#814)
This commit is contained in:
@@ -949,24 +949,9 @@ class CollectionState():
|
||||
self.stale[item.player] = True
|
||||
|
||||
|
||||
@unique
|
||||
class RegionType(IntEnum):
|
||||
Generic = 0
|
||||
LightWorld = 1
|
||||
DarkWorld = 2
|
||||
Cave = 3 # Also includes Houses
|
||||
Dungeon = 4
|
||||
|
||||
@property
|
||||
def is_indoors(self) -> bool:
|
||||
"""Shorthand for checking if Cave or Dungeon"""
|
||||
return self in (RegionType.Cave, RegionType.Dungeon)
|
||||
|
||||
|
||||
class Region:
|
||||
name: str
|
||||
type: RegionType
|
||||
hint_text: str
|
||||
_hint_text: str
|
||||
player: int
|
||||
multiworld: Optional[MultiWorld]
|
||||
entrances: List[Entrance]
|
||||
@@ -980,14 +965,13 @@ class Region:
|
||||
is_light_world: bool = False
|
||||
is_dark_world: bool = False
|
||||
|
||||
def __init__(self, name: str, type_: RegionType, hint: str, player: int, world: Optional[MultiWorld] = None):
|
||||
def __init__(self, name: str, player: int, multiworld: MultiWorld, hint: Optional[str] = None):
|
||||
self.name = name
|
||||
self.type = type_
|
||||
self.entrances = []
|
||||
self.exits = []
|
||||
self.locations = []
|
||||
self.multiworld = world
|
||||
self.hint_text = hint
|
||||
self.multiworld = multiworld
|
||||
self._hint_text = hint
|
||||
self.player = player
|
||||
|
||||
def can_reach(self, state: CollectionState) -> bool:
|
||||
@@ -1003,6 +987,10 @@ class Region:
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def hint_text(self) -> str:
|
||||
return self._hint_text if self._hint_text else self.name
|
||||
|
||||
def get_connecting_entrance(self, is_main_entrance: typing.Callable[[Entrance], bool]) -> Entrance:
|
||||
for entrance in self.entrances:
|
||||
if is_main_entrance(entrance):
|
||||
@@ -1289,6 +1277,7 @@ class Spoiler():
|
||||
[('player', player), ('entrance', entrance), ('exit', exit_), ('direction', direction)])
|
||||
|
||||
def parse_data(self):
|
||||
from worlds.alttp.SubClasses import LTTPRegionType
|
||||
self.medallions = OrderedDict()
|
||||
for player in self.multiworld.get_game_players("A Link to the Past"):
|
||||
self.medallions[f'Misery Mire ({self.multiworld.get_player_name(player)})'] = \
|
||||
@@ -1298,23 +1287,31 @@ class Spoiler():
|
||||
|
||||
self.locations = OrderedDict()
|
||||
listed_locations = set()
|
||||
lw_locations = []
|
||||
dw_locations = []
|
||||
cave_locations = []
|
||||
for loc in self.multiworld.get_locations():
|
||||
if loc.game == "A Link to the Past":
|
||||
if loc not in listed_locations and loc.parent_region and \
|
||||
loc.parent_region.type == LTTPRegionType.LightWorld and loc.show_in_spoiler:
|
||||
lw_locations.append(loc)
|
||||
elif loc not in listed_locations and loc.parent_region and \
|
||||
loc.parent_region.type == LTTPRegionType.DarkWorld and loc.show_in_spoiler:
|
||||
dw_locations.append(loc)
|
||||
elif loc not in listed_locations and loc.parent_region and \
|
||||
loc.parent_region.type == LTTPRegionType.Cave and loc.show_in_spoiler:
|
||||
cave_locations.append(loc)
|
||||
|
||||
lw_locations = [loc for loc in self.multiworld.get_locations() if
|
||||
loc not in listed_locations and loc.parent_region and loc.parent_region.type == RegionType.LightWorld and loc.show_in_spoiler]
|
||||
self.locations['Light World'] = OrderedDict(
|
||||
[(str(location), str(location.item) if location.item is not None else 'Nothing') for location in
|
||||
lw_locations])
|
||||
listed_locations.update(lw_locations)
|
||||
|
||||
dw_locations = [loc for loc in self.multiworld.get_locations() if
|
||||
loc not in listed_locations and loc.parent_region and loc.parent_region.type == RegionType.DarkWorld and loc.show_in_spoiler]
|
||||
self.locations['Dark World'] = OrderedDict(
|
||||
[(str(location), str(location.item) if location.item is not None else 'Nothing') for location in
|
||||
dw_locations])
|
||||
listed_locations.update(dw_locations)
|
||||
|
||||
cave_locations = [loc for loc in self.multiworld.get_locations() if
|
||||
loc not in listed_locations and loc.parent_region and loc.parent_region.type == RegionType.Cave and loc.show_in_spoiler]
|
||||
self.locations['Caves'] = OrderedDict(
|
||||
[(str(location), str(location.item) if location.item is not None else 'Nothing') for location in
|
||||
cave_locations])
|
||||
|
Reference in New Issue
Block a user