From 0cf3549c86e38c534f22645572581f98948cc9ce Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:46:11 -0500 Subject: [PATCH] remove collect --- worlds/mm2/__init__.py | 19 ------------------- worlds/mm2/rules.py | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/worlds/mm2/__init__.py b/worlds/mm2/__init__.py index 83ea6e3d3963..07e1823f9387 100644 --- a/worlds/mm2/__init__.py +++ b/worlds/mm2/__init__.py @@ -288,22 +288,3 @@ def modify_multidata(self, multidata: Dict[str, Any]) -> None: if rom_name: new_name = base64.b64encode(bytes(self.rom_name)).decode() multidata["connect_names"][new_name] = multidata["connect_names"][self.player_name] - - def collect(self, state: "CollectionState", item: "Item") -> bool: - change = super().collect(state, item) - if change and item.name in self.item_name_groups["Weapons"]: - # need to evaluate robot master access - for boss, reqs in self.wily_5_weapons.items(): - if boss in robot_masters: - if state.has_all(map(lambda x: weapons_to_name[x], reqs), self.player): - state.prog_items[self.player][robot_masters[boss]] = 1 - return change - - def remove(self, state: "CollectionState", item: "Item") -> bool: - change = super().remove(state, item) - if change and item.name in self.item_name_groups["Weapons"]: - for boss, reqs in self.wily_5_weapons.items(): - if boss in robot_masters: - if not state.has_all(map(lambda x: weapons_to_name[x], reqs), self.player): - state.prog_items[self.player][robot_masters[boss]] = 0 - return change diff --git a/worlds/mm2/rules.py b/worlds/mm2/rules.py index 6ac0023087aa..d90c8b4222a0 100644 --- a/worlds/mm2/rules.py +++ b/worlds/mm2/rules.py @@ -70,8 +70,16 @@ } -def can_defeat_enough_rbms(state: "CollectionState", player: int, required: int) -> bool: - return state.has_from_list(robot_masters.values(), player, required) +def can_defeat_enough_rbms(state: "CollectionState", player: int, + required: int, boss_requirements: Dict[int, List[str]]): + can_defeat = 0 + for boss, reqs in boss_requirements.items(): + if boss in robot_masters: + if state.has_all(map(lambda x: weapons_to_name[x], reqs), player): + can_defeat += 1 + if can_defeat >= required: + return True + return False def set_rules(world: "MM2World") -> None: @@ -269,7 +277,8 @@ def set_rules(world: "MM2World") -> None: # Need to defeat x amount of robot masters for Wily 5 add_rule(world.get_location(names.wily_5), - lambda state: can_defeat_enough_rbms(state, world.player, world.options.wily_5_requirement.value)) + lambda state: can_defeat_enough_rbms(state, world.player, world.options.wily_5_requirement.value, + world.wily_5_weapons)) add_rule(world.get_location(names.wily_stage_5), lambda state: can_defeat_enough_rbms(state, world.player, world.options.wily_5_requirement.value))