Skip to content

Commit

Permalink
add option to set number needed for grub hub
Browse files Browse the repository at this point in the history
  • Loading branch information
qwint committed Apr 24, 2024
1 parent 412be06 commit 5d3607f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion worlds/hk/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ class Goal(Choice):
default = 0


class GrubHuntGoal(NamedRange):
"""The amount of grubs required to finish Grub Hunt.
On 'All' any grubs from item links replacements etc. will be counted"""
display_name = "Grub Hunt Goal"
range_start = 1
range_end = 46
special_range_names = {"all": 0}
default = 46


class WhitePalace(Choice):
"""
Whether or not to include White Palace or not. Note: Even if excluded, the King Fragment check may still be
Expand Down Expand Up @@ -517,7 +527,7 @@ class CostSanityHybridChance(Range):
**{
option.__name__: option
for option in (
StartLocation, Goal, WhitePalace, ExtraPlatforms, AddUnshuffledLocations, StartingGeo,
StartLocation, Goal, GrubHuntGoal, WhitePalace, ExtraPlatforms, AddUnshuffledLocations, StartingGeo,
DeathLink, DeathLinkShade, DeathLinkBreaksFragileCharms,
MinimumGeoPrice, MaximumGeoPrice,
MinimumGrubPrice, MaximumGrubPrice,
Expand Down
8 changes: 6 additions & 2 deletions worlds/hk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,19 @@ def set_rules(self):
elif goal == Goal.option_godhome_flower:
world.completion_condition[player] = lambda state: state.count("Godhome_Flower_Quest", player)
elif goal == Goal.option_grub_hunt:
pass # will set in pre_fill()
if self.options.GrubHuntGoal == "all":
pass # will set in pre_fill()
else:
self.grub_count = self.options.GrubHuntGoal.value
world.completion_condition[player] = lambda state: state.has("Grub", player, self.grub_count)
else:
# Any goal
world.completion_condition[player] = lambda state: state._hk_can_beat_thk(player) or state._hk_can_beat_radiance(player)

set_rules(self)

def pre_fill(self):
if self.options.Goal == "grub_hunt":
if self.options.Goal == "grub_hunt" and self.grub_count == 0:
from collections import Counter
relevant_groups = self.multiworld.get_player_groups(self.player)
grub_player_count = Counter()
Expand Down

0 comments on commit 5d3607f

Please sign in to comment.