Skip to content

Commit 5ce71db

Browse files
author
threeandthreee
authored
LADX: use start_inventory_from_pool (#4641)
1 parent aff98a5 commit 5ce71db

File tree

2 files changed

+40
-45
lines changed

2 files changed

+40
-45
lines changed

worlds/ladx/Options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os.path
44
import typing
55
import logging
6-
from Options import Choice, Toggle, DefaultOnToggle, Range, FreeText, PerGameCommonOptions, OptionGroup, Removed
6+
from Options import Choice, Toggle, DefaultOnToggle, Range, FreeText, PerGameCommonOptions, OptionGroup, Removed, StartInventoryPool
77
from collections import defaultdict
88
import Utils
99

@@ -665,6 +665,7 @@ class LinksAwakeningOptions(PerGameCommonOptions):
665665
tarins_gift: TarinsGift
666666
overworld: Overworld
667667
stabilize_item_pool: StabilizeItemPool
668+
start_inventory_from_pool: StartInventoryPool
668669

669670
warp_improvements: Removed
670671
additional_warp_points: Removed

worlds/ladx/__init__.py

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ def create_event(self, event: str):
225225
def create_items(self) -> None:
226226
itempool = []
227227

228-
exclude = [item.name for item in self.multiworld.precollected_items[self.player]]
229-
230228
self.prefill_original_dungeon = [ [], [], [], [], [], [], [], [], [] ]
231229
self.prefill_own_dungeons = []
232230
self.pre_fill_items = []
@@ -243,50 +241,46 @@ def create_items(self) -> None:
243241
continue
244242
item_name = ladxr_item_to_la_item_name[ladx_item_name]
245243
for _ in range(count):
246-
if item_name in exclude:
247-
exclude.remove(item_name) # this is destructive. create unique list above
248-
self.multiworld.itempool.append(self.create_item(self.get_filler_item_name()))
249-
else:
250-
item = self.create_item(item_name)
251-
252-
if not self.options.tradequest and isinstance(item.item_data, TradeItemData):
253-
location = self.multiworld.get_location(item.item_data.vanilla_location, self.player)
254-
location.place_locked_item(item)
255-
location.show_in_spoiler = False
256-
continue
257-
258-
if isinstance(item.item_data, DungeonItemData):
259-
item_type = item.item_data.ladxr_id[:-1]
260-
shuffle_type = self.dungeon_item_types[item_type]
261-
262-
if item.item_data.dungeon_item_type == DungeonItemType.INSTRUMENT and shuffle_type == ShuffleInstruments.option_vanilla:
263-
# Find instrument, lock
264-
# TODO: we should be able to pinpoint the region we want, save a lookup table please
265-
found = False
266-
for r in self.multiworld.get_regions(self.player):
267-
if r.dungeon_index != item.item_data.dungeon_index:
244+
item = self.create_item(item_name)
245+
246+
if not self.options.tradequest and isinstance(item.item_data, TradeItemData):
247+
location = self.multiworld.get_location(item.item_data.vanilla_location, self.player)
248+
location.place_locked_item(item)
249+
location.show_in_spoiler = False
250+
continue
251+
252+
if isinstance(item.item_data, DungeonItemData):
253+
item_type = item.item_data.ladxr_id[:-1]
254+
shuffle_type = self.dungeon_item_types[item_type]
255+
256+
if item.item_data.dungeon_item_type == DungeonItemType.INSTRUMENT and shuffle_type == ShuffleInstruments.option_vanilla:
257+
# Find instrument, lock
258+
# TODO: we should be able to pinpoint the region we want, save a lookup table please
259+
found = False
260+
for r in self.multiworld.get_regions(self.player):
261+
if r.dungeon_index != item.item_data.dungeon_index:
262+
continue
263+
for loc in r.locations:
264+
if not isinstance(loc, LinksAwakeningLocation):
268265
continue
269-
for loc in r.locations:
270-
if not isinstance(loc, LinksAwakeningLocation):
271-
continue
272-
if not isinstance(loc.ladxr_item, Instrument):
273-
continue
274-
loc.place_locked_item(item)
275-
found = True
276-
break
277-
if found:
278-
break
279-
else:
280-
if shuffle_type == DungeonItemShuffle.option_original_dungeon:
281-
self.prefill_original_dungeon[item.item_data.dungeon_index - 1].append(item)
282-
self.pre_fill_items.append(item)
283-
elif shuffle_type == DungeonItemShuffle.option_own_dungeons:
284-
self.prefill_own_dungeons.append(item)
285-
self.pre_fill_items.append(item)
286-
else:
287-
itempool.append(item)
266+
if not isinstance(loc.ladxr_item, Instrument):
267+
continue
268+
loc.place_locked_item(item)
269+
found = True
270+
break
271+
if found:
272+
break
288273
else:
289-
itempool.append(item)
274+
if shuffle_type == DungeonItemShuffle.option_original_dungeon:
275+
self.prefill_original_dungeon[item.item_data.dungeon_index - 1].append(item)
276+
self.pre_fill_items.append(item)
277+
elif shuffle_type == DungeonItemShuffle.option_own_dungeons:
278+
self.prefill_own_dungeons.append(item)
279+
self.pre_fill_items.append(item)
280+
else:
281+
itempool.append(item)
282+
else:
283+
itempool.append(item)
290284

291285
self.multi_key = self.generate_multi_key()
292286

0 commit comments

Comments
 (0)