From e5b0c2923dcc51f6a912933b3c8c8ae5cf5a54fb Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 28 May 2023 22:58:59 -0500 Subject: [PATCH] Hollow Knight: something # Conflicts: # worlds/hk/__init__.py HK: fix up split mothwing cloak logic HK: fix up potential if tree issues --- worlds/hk/__init__.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/worlds/hk/__init__.py b/worlds/hk/__init__.py index 78287305df5f..dd675ce6ce92 100644 --- a/worlds/hk/__init__.py +++ b/worlds/hk/__init__.py @@ -538,23 +538,40 @@ def create_vanilla_location(self, location: str, item: Item): def collect(self, state, item: HKItem) -> bool: change = super(HKWorld, self).collect(state, item) if change: + prog_items = state.prog_items for effect_name, effect_value in item_effects.get(item.name, {}).items(): - state.prog_items[item.player][effect_name] += effect_value - if item.name in {"Left_Mothwing_Cloak", "Right_Mothwing_Cloak"}: - if state.prog_items[item.player].get('RIGHTDASH', 0) and \ - state.prog_items[item.player].get('LEFTDASH', 0): - (state.prog_items[item.player]["RIGHTDASH"], state.prog_items[item.player]["LEFTDASH"]) = \ - ([max(state.prog_items[item.player]["RIGHTDASH"], state.prog_items[item.player]["LEFTDASH"])] * 2) + prog_items[effect_name, self.player] += effect_value + + # a directional overflow in dash grants an upgrade for the other side + if item.name == "Right_Mothwing_Cloak" and \ + prog_items["RIGHTDASH", self.player] > 2 > prog_items["LEFTDASH", self.player]: + prog_items["OVERFLOWLEFTDASH", self.player] += 1 + prog_items["LEFTDASH", self.player] += 1 + elif item.name == "Left_Mothwing_Cloak" and \ + prog_items["LEFTDASH", self.player] > 2 > prog_items["RIGHTDASH", self.player]: + prog_items["OVERFLOWRIGHTDASH", self.player] += 1 + prog_items["RIGHTDASH", self.player] += 1 + return change def remove(self, state, item: HKItem) -> bool: change = super(HKWorld, self).remove(state, item) if change: + prog_items = state.prog_items + + # a directional overflow in dash grants an upgrade for the other side + if item.name == "Right_Mothwing_Cloak" and prog_items["OVERFLOWLEFTDASH", self.player]: + prog_items["LEFTDASH", self.player] -= 1 + prog_items["OVERFLOWLEFTDASH", self.player] -= 1 + elif item.name == "Left_Mothwing_Cloak" and prog_items["OVERFLOWRIGHTDASH", self.player]: + prog_items["RIGHTDASH", self.player] -= 1 + prog_items["OVERFLOWRIGHTDASH", self.player] -= 1 + for effect_name, effect_value in item_effects.get(item.name, {}).items(): - if state.prog_items[item.player][effect_name] == effect_value: - del state.prog_items[item.player][effect_name] - state.prog_items[item.player][effect_name] -= effect_value + if prog_items[effect_name, item.player] == effect_value: + del prog_items[effect_name, item.player] + prog_items[effect_name, item.player] -= effect_value return change