|
2 | 2 | from dataclasses import dataclass
|
3 | 3 | from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Union
|
4 | 4 |
|
5 |
| -from BaseClasses import CollectionState, Item, Location, LocationProgressType |
| 5 | +from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld |
6 | 6 |
|
7 | 7 | from .data import static_logic as static_witness_logic
|
8 | 8 | from .data.utils import weighted_sample
|
@@ -184,17 +184,26 @@ def word_direct_hint(world: "WitnessWorld", hint: WitnessLocationHint) -> Witnes
|
184 | 184 |
|
185 | 185 |
|
186 | 186 | 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 | + ] |
189 | 202 |
|
190 | 203 | if not locations:
|
191 | 204 | return None
|
192 | 205 |
|
193 | 206 | 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) + ")" |
198 | 207 |
|
199 | 208 | return WitnessLocationHint(location_obj, False)
|
200 | 209 |
|
|
0 commit comments