mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-21 15:03:18 -07:00
TUNIC: Refactor entrance hint generation (#5620)
* Refactor hint generation * Remove debug print * Early out per qwint's comment
This commit is contained in:
@@ -672,25 +672,29 @@ class TunicWorld(World):
|
||||
# Remove parentheses for better readability
|
||||
spoiler_handle.write(f'{ability[ability.find("(")+1:ability.find(")")]}: {self.ability_unlocks[ability]} Gold Questagons\n')
|
||||
|
||||
def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None:
|
||||
if self.options.entrance_rando:
|
||||
hint_data.update({self.player: {}})
|
||||
# all state seems to have efficient paths
|
||||
all_state = self.multiworld.get_all_state(True)
|
||||
all_state.update_reachable_regions(self.player)
|
||||
paths = all_state.path
|
||||
portal_names = {portal.name for portal in portal_mapping}.union({f"Shop Portal {i + 1}" for i in range(500)})
|
||||
for location in self.multiworld.get_locations(self.player):
|
||||
# skipping event locations
|
||||
if not location.address:
|
||||
@classmethod
|
||||
def stage_extend_hint_information(cls, multiworld: MultiWorld, hint_data: dict[int, dict[int, str]]) -> None:
|
||||
tunic_er_worlds: list[TunicWorld] = [world for world in multiworld.get_game_worlds("TUNIC")
|
||||
if world.options.entrance_rando]
|
||||
if not tunic_er_worlds:
|
||||
return
|
||||
|
||||
hint_data.update({world.player: {} for world in tunic_er_worlds})
|
||||
all_state = multiworld.get_all_state()
|
||||
paths = all_state.path
|
||||
portal_names = {portal.name for portal in portal_mapping}.union({f"Shop Portal {i + 1}" for i in range(500)})
|
||||
for world in tunic_er_worlds:
|
||||
all_state.update_reachable_regions(world.player)
|
||||
for region in world.get_regions():
|
||||
if region.name == "Menu":
|
||||
continue
|
||||
path_to_loc = []
|
||||
path_to_region = []
|
||||
previous_name = "placeholder"
|
||||
try:
|
||||
name, connection = paths[location.parent_region]
|
||||
name, connection = paths[region]
|
||||
except KeyError:
|
||||
# logic bug, proceed with warning since it takes a long time to update AP
|
||||
warning(f"{location.name} is not logically accessible for {self.player_name}. "
|
||||
warning(f"{region.name} is not logically accessible for {world.player_name}. "
|
||||
"Creating entrance hint Inaccessible. Please report this to the TUNIC rando devs. "
|
||||
"If you are using Plando Items (excluding early locations), then this is likely the cause.")
|
||||
hint_text = "Inaccessible"
|
||||
@@ -703,11 +707,14 @@ class TunicWorld(World):
|
||||
# was getting some cases like Library Grave -> Library Grave -> other place
|
||||
if name in portal_names and name != previous_name:
|
||||
previous_name = name
|
||||
path_to_loc.append(name)
|
||||
hint_text = " -> ".join(reversed(path_to_loc))
|
||||
path_to_region.append(name)
|
||||
hint_text = " -> ".join(reversed(path_to_region))
|
||||
|
||||
if hint_text:
|
||||
hint_data[self.player][location.address] = hint_text
|
||||
for location in region.get_locations():
|
||||
if location.address is None:
|
||||
continue
|
||||
hint_data[world.player][location.address] = hint_text
|
||||
|
||||
def get_real_location(self, location: Location) -> tuple[str, int]:
|
||||
# if it's not in a group, it's not in an item link
|
||||
|
||||
@@ -29,6 +29,8 @@ def create_er_regions(world: "TunicWorld") -> dict[Portal, Portal]:
|
||||
world.used_shop_numbers = set()
|
||||
|
||||
for region_name, region_data in world.er_regions.items():
|
||||
if region_name == "Zig Skip Exit":
|
||||
continue
|
||||
if world.options.entrance_rando and region_name == "Zig Skip Exit":
|
||||
# need to check if there's a seed group for this first
|
||||
if world.options.entrance_rando.value not in EntranceRando.options.values():
|
||||
@@ -773,11 +775,17 @@ def pair_portals(world: "TunicWorld", regions: dict[str, Region]) -> dict[Portal
|
||||
# loop through our list of paired portals and make two-way connections
|
||||
def create_randomized_entrances(world: "TunicWorld", portal_pairs: dict[Portal, Portal], regions: dict[str, Region]) -> None:
|
||||
for portal1, portal2 in portal_pairs.items():
|
||||
# this portal is completely inaccessible, so let's not make this connection
|
||||
if portal1.region == "Zig Skip Exit":
|
||||
continue
|
||||
# connect to the outlet region if there is one, if not connect to the actual region
|
||||
regions[portal1.region].connect(
|
||||
connecting_region=regions[get_portal_outlet_region(portal2, world)],
|
||||
name=portal1.name)
|
||||
if not world.options.decoupled or not world.options.entrance_rando:
|
||||
# this portal is completely inaccessible, so let's not make this connection
|
||||
if portal2.region == "Zig Skip Exit":
|
||||
continue
|
||||
regions[portal2.region].connect(
|
||||
connecting_region=regions[get_portal_outlet_region(portal1, world)],
|
||||
name=portal2.name)
|
||||
|
||||
Reference in New Issue
Block a user