Added functioning filler weights
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from Options import FreeText, NumericOption, Toggle, DefaultOnToggle, Choice, TextChoice, Range, NamedRange, OptionList, \
|
from Options import FreeText, NumericOption, Toggle, DefaultOnToggle, Choice, TextChoice, Range, NamedRange, OptionList, \
|
||||||
PerGameCommonOptions, OptionSet
|
PerGameCommonOptions, OptionSet, OptionCounter
|
||||||
|
|
||||||
class StartingArea(Choice):
|
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]"""
|
"""If a trap is sent from Grinch, traps that are compatible with other games are triggered as well. [NOT IMPLEMENTED]"""
|
||||||
display_name = "Trap Link"
|
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
|
@dataclass
|
||||||
class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin
|
class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin
|
||||||
starting_area: StartingArea
|
starting_area: StartingArea
|
||||||
@@ -106,3 +118,4 @@ class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin
|
|||||||
unlimited_eggs: UnlimitedEggs
|
unlimited_eggs: UnlimitedEggs
|
||||||
ring_link: RingLinkOption
|
ring_link: RingLinkOption
|
||||||
trap_link: TrapLinkOption
|
trap_link: TrapLinkOption
|
||||||
|
filler_weight: FillerWeight
|
||||||
|
|||||||
@@ -63,10 +63,26 @@ class GrinchWorld(World):
|
|||||||
#Get number of current unfilled locations
|
#Get number of current unfilled locations
|
||||||
unfilled_locations: int = len(self.multiworld.get_unfilled_locations(self.player)) - len(ALL_ITEMS_TABLE.keys()) - 3
|
unfilled_locations: int = len(self.multiworld.get_unfilled_locations(self.player)) - len(ALL_ITEMS_TABLE.keys()) - 3
|
||||||
|
|
||||||
for _ in range(unfilled_locations):
|
# Total available weight sum
|
||||||
self_itempool.append(self.create_item((self.get_other_filler_item(list(MISC_ITEMS_TABLE.keys())))))
|
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
|
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):
|
def set_rules(self):
|
||||||
self.multiworld.completion_condition[self.player] = lambda state: state.has("Goal", self.player)
|
self.multiworld.completion_condition[self.player] = lambda state: state.has("Goal", self.player)
|
||||||
set_location_rules(self)
|
set_location_rules(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user