diff --git a/Main.py b/Main.py index 6555eedf..2de97265 100644 --- a/Main.py +++ b/Main.py @@ -14,7 +14,6 @@ from BaseClasses import MultiWorld, CollectionState, Region, Item from worlds.alttp.Items import item_name_groups from worlds.alttp.Regions import lookup_vanilla_location_to_entrance from worlds.alttp.Rom import patch_rom, patch_race_rom, patch_enemizer, apply_rom_settings, LocalRom, get_hash_string -from worlds.alttp.Dungeons import fill_dungeons, fill_dungeons_restrictive from Fill import distribute_items_restrictive, flood_items, balance_multiworld_progression, distribute_planned from worlds.alttp.Shops import ShopSlotFill, SHOP_ID_START, total_shop_slots, FillDisabledShopSlots from worlds.alttp.ItemPool import difficulties, fill_prizes @@ -218,18 +217,9 @@ def main(args, seed=None): distribute_planned(world) - logger.info('Placing Dungeon Prizes.') + logger.info('Running Pre Main Fill.') - fill_prizes(world) - - logger.info('Placing Dungeon Items.') - - if world.algorithm in ['balanced', 'vt26'] or any( - list(args.mapshuffle.values()) + list(args.compassshuffle.values()) + - list(args.keyshuffle.values()) + list(args.bigkeyshuffle.values())): - fill_dungeons_restrictive(world) - else: - fill_dungeons(world) + AutoWorld.call_all(world, "pre_fill") logger.info('Fill the world.') diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index ed43b6ff..ffbe9c1f 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -5,7 +5,7 @@ from BaseClasses import MultiWorld, Item, CollectionState class AutoWorldRegister(type): - world_types:Dict[str, World] = {} + world_types: Dict[str, World] = {} def __new__(cls, name, bases, dct): # filter out any events @@ -20,7 +20,6 @@ class AutoWorldRegister(type): dct["location_names"] = frozenset(dct["location_name_to_id"]) dct["all_names"] = dct["item_names"] | dct["location_names"] | set(dct.get("item_name_groups", {})) - # construct class new_class = super().__new__(cls, name, bases, dct) if "game" in dct: @@ -45,8 +44,14 @@ def call_single(world: MultiWorld, method_name: str, player: int, *args): def call_all(world: MultiWorld, method_name: str, *args): + world_types = set() for player in world.player_ids: + world_types.add(world.worlds[player].__class__) call_single(world, method_name, player, *args) + for world_type in world_types: + stage_callable = getattr(world_type, f"stage_{method_name}", None) + if stage_callable: + stage_callable(world) class World(metaclass=AutoWorldRegister): @@ -54,7 +59,7 @@ class World(metaclass=AutoWorldRegister): A Game should have its own subclass of World in which it defines the required data structures.""" options: dict = {} # link your Options mapping - game: str # name the game + game: str # name the game topology_present: bool = False # indicate if world type has any meaningful layout/pathing all_names: Set[str] = frozenset() # gets automatically populated with all item, item group and location names @@ -91,6 +96,9 @@ class World(metaclass=AutoWorldRegister): self.player = player # overridable methods that get called by Main.py, sorted by execution order + # can also be implemented as a classmethod and called "stage_ tuple: return max((0, 1, 4), super(ALTTPWorld, self).get_required_client_version())