From 3bb3a902b30a40a52d89d980e97d8efcb3204563 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 28 Mar 2022 01:50:58 +0200 Subject: [PATCH] SM: Optimize a bit (#350) * SM: Optimize a bit * SM: init bosses only once --- worlds/sm/__init__.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/worlds/sm/__init__.py b/worlds/sm/__init__.py index 421a6bb4..3b408fd4 100644 --- a/worlds/sm/__init__.py +++ b/worlds/sm/__init__.py @@ -524,23 +524,23 @@ class SMWorld(World): progitempool.sort( key=lambda item: 1 if (item.name == 'Morph Ball') else 0) - def post_fill(self): - new_state = CollectionState(self.world) + @classmethod + def stage_post_fill(cls, world): + new_state = CollectionState(world) progitempool = [] - for item in self.world.itempool: - if item.player == self.player and item.advancement: + for item in world.itempool: + if item.game == "Super Metroid" and item.advancement: progitempool.append(item) - if item.location.player == self.player and item.game == "Super Metroid" and item.type == "Nothing": - item.location.address = None for item in progitempool: new_state.collect(item, True) - + bossesLoc = ['Draygon', 'Kraid', 'Ridley', 'Phantoon', 'Mother Brain'] - for bossLoc in bossesLoc: - if (not self.world.get_location(bossLoc, self.player).can_reach(new_state)): - self.world.state.smbm[self.player].onlyBossLeft = True - break + for player in world.get_game_players("Super Metroid"): + for bossLoc in bossesLoc: + if not world.get_location(bossLoc, player).can_reach(new_state): + world.state.smbm[player].onlyBossLeft = True + break def create_locations(self, player: int): @@ -576,5 +576,7 @@ class SMItem(Item): game = "Super Metroid" def __init__(self, name, advancement, type, code, player: int = None): + if type == "Nothing": + code = None super(SMItem, self).__init__(name, advancement, code, player) self.type = type