Skip to content

Commit

Permalink
makes grub hunt goal option that calculates the total available grubs…
Browse files Browse the repository at this point in the history
… (including item link replacements) and requires all of them to be gathered for goal completion
  • Loading branch information
qwint committed Apr 23, 2024
1 parent daccb30 commit 6629c21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions worlds/hk/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ class Goal(Choice):
option_radiance = 3
option_godhome = 4
option_godhome_flower = 5
option_grub_hunt = 6
default = 0


Expand Down
24 changes: 24 additions & 0 deletions worlds/hk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class HKWorld(World):
ranges: typing.Dict[str, typing.Tuple[int, int]]
charm_costs: typing.List[int]
cached_filler_items = {}
grub_count: int
data_version = 2

def __init__(self, world, player):
Expand All @@ -164,6 +165,7 @@ def __init__(self, world, player):
self.ranges = {}
self.created_shop_items = 0
self.vanilla_shop_costs = deepcopy(vanilla_shop_costs)
self.grub_count = 0

def generate_early(self):
world = self.multiworld
Expand Down Expand Up @@ -441,12 +443,32 @@ def set_rules(self):
world.completion_condition[player] = lambda state: state.count("Defeated_Pantheon_5", player)
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()
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":
from collections import Counter
relevant_groups = self.multiworld.get_player_groups(self.player)
grub_player_count = Counter()

for grub in [item for item in self.multiworld.get_items() if item.name == "Grub"]:
if grub.player in relevant_groups or grub.player == self.player:
grub_player_count += Counter({grub.player: 1})
if grub.location and grub.location.player in relevant_groups:
# not counting our grubs stuck in item links because we also will count the group's copy
pass
else:
self.grub_count += 1

self.multiworld.completion_condition[self.player] = lambda state, g=grub_player_count: \
all([state.has("Grub", player, count) for player, count in g.items()])

def fill_slot_data(self):
slot_data = {}

Expand Down Expand Up @@ -484,6 +506,8 @@ def fill_slot_data(self):

slot_data["notch_costs"] = self.charm_costs

slot_data["grub_count"] = self.grub_count

return slot_data

def create_item(self, name: str) -> HKItem:
Expand Down

0 comments on commit 6629c21

Please sign in to comment.