From 91d042341130b39ec99e99173f0d9c79196047ed Mon Sep 17 00:00:00 2001 From: MarioSpore Date: Wed, 5 Nov 2025 19:45:50 -0500 Subject: [PATCH] Added functioning filler weights --- worlds/grinch/Options.py | 15 ++++++++++++++- worlds/grinch/__init__.py | 20 ++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/worlds/grinch/Options.py b/worlds/grinch/Options.py index e6bdbb69..756bea6f 100644 --- a/worlds/grinch/Options.py +++ b/worlds/grinch/Options.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from Options import FreeText, NumericOption, Toggle, DefaultOnToggle, Choice, TextChoice, Range, NamedRange, OptionList, \ - PerGameCommonOptions, OptionSet + PerGameCommonOptions, OptionSet, OptionCounter class StartingArea(Choice): """ @@ -93,6 +93,18 @@ class TrapLinkOption(Toggle): """If a trap is sent from Grinch, traps that are compatible with other games are triggered as well. [NOT IMPLEMENTED]""" display_name = "Trap Link" +class FillerWeight(OptionCounter): + """ + Determines how often each filler item appears in the itempool + """ + default = { + "5 Rotten Eggs": 50, + "10 Rotten Eggs": 25, + "20 Rotten Eggs": 15, + # "Fully Healed Grinch": 10, + } + display_name = "Filler Weights" + @dataclass class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin starting_area: StartingArea @@ -106,3 +118,4 @@ class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin unlimited_eggs: UnlimitedEggs ring_link: RingLinkOption trap_link: TrapLinkOption + filler_weight: FillerWeight diff --git a/worlds/grinch/__init__.py b/worlds/grinch/__init__.py index b13185db..341c67e3 100644 --- a/worlds/grinch/__init__.py +++ b/worlds/grinch/__init__.py @@ -63,10 +63,26 @@ class GrinchWorld(World): #Get number of current unfilled locations unfilled_locations: int = len(self.multiworld.get_unfilled_locations(self.player)) - len(ALL_ITEMS_TABLE.keys()) - 3 - for _ in range(unfilled_locations): - self_itempool.append(self.create_item((self.get_other_filler_item(list(MISC_ITEMS_TABLE.keys()))))) + # Total available weight sum + total_fillerweights = sum(self.options.filler_weight[filler] for filler in MISC_ITEMS_TABLE) + + # Fill remaining locations according to weight ratio + for filler in MISC_ITEMS_TABLE: + weight_ratio = self.options.filler_weight[filler] / total_fillerweights + filler_count = round(unfilled_locations * weight_ratio) + for _ in range(filler_count): + self_itempool.append(self.create_item(filler)) + + # Make sure we don't underfill (in case of rounding losses) + while len(self_itempool) < unfilled_locations: + self_itempool.append(self.create_item(self.get_other_filler_item(list(MISC_ITEMS_TABLE.keys())))) + self.multiworld.itempool += self_itempool + # for _ in range(unfilled_locations): + # self_itempool.append(self.create_item((self.get_other_filler_item(list(MISC_ITEMS_TABLE.keys()))))) + # self.multiworld.itempool += self_itempool + def set_rules(self): self.multiworld.completion_condition[self.player] = lambda state: state.has("Goal", self.player) set_location_rules(self)