From baa7992a7af0aa66a9a14e004f5c89d91be7f58d Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 30 Aug 2021 01:16:04 +0200 Subject: [PATCH] AutoWorld: add post_fill LttP: Move ShopSlotFill to post_fill --- Main.py | 6 ++---- worlds/AutoWorld.py | 3 +++ worlds/alttp/Shops.py | 1 + worlds/alttp/__init__.py | 4 ++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Main.py b/Main.py index 801015a6..14f19884 100644 --- a/Main.py +++ b/Main.py @@ -14,7 +14,7 @@ from BaseClasses import MultiWorld, CollectionState, Region, RegionType from worlds.alttp.Items import item_name_groups from worlds.alttp.Regions import lookup_vanilla_location_to_entrance 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.Shops import SHOP_ID_START, total_shop_slots, FillDisabledShopSlots from Utils import output_path, get_options, __version__, version_tuple from worlds.generic.Rules import locality_rules, exclusion_rules from worlds import AutoWorld @@ -198,9 +198,7 @@ def main(args, seed=None): elif world.algorithm == 'balanced': distribute_items_restrictive(world) - logger.info("Filling Shop Slots") - - ShopSlotFill(world) + AutoWorld.call_all(world, 'post_fill') if world.players > 1: balance_multiworld_progression(world) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index eec29fd2..cc1ac665 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -138,6 +138,9 @@ class World(metaclass=AutoWorldRegister): This gets called once per present world type.""" pass + def post_fill(self): + """Optional Method that is called after regular fill. Can be used to do adjustments before output generation.""" + def generate_output(self, output_directory: str): """This method gets called from a threadpool, do not use world.random here. If you need any last-second randomization, use MultiWorld.slot_seeds[slot] instead.""" diff --git a/worlds/alttp/Shops.py b/worlds/alttp/Shops.py index f90f42fc..a0d7d84b 100644 --- a/worlds/alttp/Shops.py +++ b/worlds/alttp/Shops.py @@ -159,6 +159,7 @@ def ShopSlotFill(world): shop_slots -= removed if shop_slots: + logger.info("Filling LttP Shop Slots") del shop_slots from Fill import swap_location_item diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 98199e07..08123ff6 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -229,6 +229,10 @@ class ALTTPWorld(World): from .Dungeons import fill_dungeons_restrictive fill_dungeons_restrictive(world) + @classmethod + def stage_post_fill(cls, world): + Shops.ShopSlotFill(world) + def generate_output(self, output_directory: str): world = self.world player = self.player