Skip to content

Commit 72b7bfe

Browse files
NewSoupViqwint
authored andcommitted
The Witness: Make item links work properly with the hint system (ArchipelagoMW#3110)
1 parent 114d870 commit 72b7bfe

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

worlds/witness/hints.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dataclasses import dataclass
33
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Union
44

5-
from BaseClasses import CollectionState, Item, Location, LocationProgressType
5+
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld
66

77
from .data import static_logic as static_witness_logic
88
from .data.utils import weighted_sample
@@ -184,17 +184,26 @@ def word_direct_hint(world: "WitnessWorld", hint: WitnessLocationHint) -> Witnes
184184

185185

186186
def hint_from_item(world: "WitnessWorld", item_name: str, own_itempool: List[Item]) -> Optional[WitnessLocationHint]:
187-
188-
locations = [item.location for item in own_itempool if item.name == item_name and item.location]
187+
def get_real_location(multiworld: MultiWorld, location: Location):
188+
"""If this location is from an item_link pseudo-world, get the location that the item_link item is on.
189+
Return the original location otherwise / as a fallback."""
190+
if location.player not in world.multiworld.groups:
191+
return location
192+
193+
try:
194+
return multiworld.find_item(location.item.name, location.player)
195+
except StopIteration:
196+
return location
197+
198+
locations = [
199+
get_real_location(world.multiworld, item.location)
200+
for item in own_itempool if item.name == item_name and item.location
201+
]
189202

190203
if not locations:
191204
return None
192205

193206
location_obj = world.random.choice(locations)
194-
location_name = location_obj.name
195-
196-
if location_obj.player != world.player:
197-
location_name += " (" + world.multiworld.get_player_name(location_obj.player) + ")"
198207

199208
return WitnessLocationHint(location_obj, False)
200209

0 commit comments

Comments
 (0)