Skip to content

Commit

Permalink
Create items lists once for all WL4 worlds
Browse files Browse the repository at this point in the history
Add Start Inventory from Pool option
  • Loading branch information
lilDavid committed Sep 2, 2024
1 parent f37f5bc commit 2d4ab68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 14 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class WL4World(World):

web = WL4Web()

JEWEL_PIECES = tuple(filter_items(type=ItemType.JEWEL))
CDS = tuple(filter_item_names(type=ItemType.CD))
ABILITIES = tuple(filter_item_names(type=ItemType.ABILITY))
GOLDEN_TREASURES = tuple(filter_item_names(type=ItemType.TREASURE))
FILLER_ITEMS = tuple(filter_item_names(type=ItemType.ITEM))

def generate_early(self):
if self.options.goal in (Goal.option_local_golden_treasure_hunt, Goal.option_local_golden_diva_treasure_hunt):
self.options.local_items.value.update(self.item_name_groups['Golden Treasure'])
Expand Down Expand Up @@ -157,7 +163,7 @@ def create_items(self):

required_jewels = self.options.required_jewels.value
pool_jewels = self.options.pool_jewels.value
for name, item in filter_items(type=ItemType.JEWEL):
for name, item in self.JEWEL_PIECES:
force_non_progression = required_jewels == 0
if item.passage() == Passage.ENTRY:
copies = min(pool_jewels, 1)
Expand All @@ -171,10 +177,10 @@ def create_items(self):
for _ in range(copies):
itempool.append(self.create_item(name, force_non_progression))

for name in filter_item_names(type=ItemType.CD):
for name in self.CDS:
itempool.append(self.create_item(name))

for name in filter_item_names(type=ItemType.ABILITY):
for name in self.ABILITIES:
itempool.append(self.create_item(name))
if name.startswith('Progressive'):
itempool.append(self.create_item(name))
Expand All @@ -188,12 +194,11 @@ def create_items(self):
itempool.append(self.create_item('Full Health Item'))

if treasure_hunt:
for name in filter_item_names(type=ItemType.TREASURE):
for name in self.GOLDEN_TREASURES:
itempool.append(self.create_item(name))

junk_count = total_required_locations - len(itempool)
junk_item_pool = tuple(filter_item_names(type=ItemType.ITEM))
itempool.extend(self.create_item(self.random.choice(junk_item_pool)) for _ in range(junk_count))
itempool.extend(self.create_item(self.get_filler_item_name()) for _ in range(junk_count))

self.multiworld.itempool += itempool

Expand Down Expand Up @@ -223,6 +228,9 @@ def fill_slot_data(self) -> Mapping[str, Any]:
'death_link',
)

def get_filler_item_name(self) -> str:
return self.random.choice(self.FILLER_ITEMS)

def create_item(self, name: str, force_non_progression=False) -> Item:
return WL4Item(name, self.player, force_non_progression)

Expand Down
3 changes: 2 additions & 1 deletion options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from Options import Choice, PerGameCommonOptions, Toggle, DeathLink, Range, OptionGroup
from Options import Choice, PerGameCommonOptions, Toggle, DeathLink, Range, OptionGroup, StartInventoryPool


class Goal(Choice):
Expand Down Expand Up @@ -226,3 +226,4 @@ class WL4Options(PerGameCommonOptions):
smash_through_hard_blocks: SmashThroughHardBlocks
music_shuffle: MusicShuffle
wario_voice_shuffle: WarioVoiceShuffle
start_inventory_from_pool: StartInventoryPool

0 comments on commit 2d4ab68

Please sign in to comment.