Skip to content

Commit

Permalink
remove collect
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvris committed Aug 19, 2024
1 parent 7d7b838 commit 0cf3549
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
19 changes: 0 additions & 19 deletions worlds/mm2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 12 additions & 3 deletions worlds/mm2/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 0cf3549

Please sign in to comment.