From 7493b7f35ed24c9afb9ddafcf796aee207b1cd03 Mon Sep 17 00:00:00 2001 From: espeon65536 Date: Wed, 14 Jul 2021 08:24:34 -0500 Subject: [PATCH] Implement excluded locations --- Main.py | 5 ++++- Mystery.py | 7 +++++++ worlds/generic/Rules.py | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Main.py b/Main.py index 29c56a2b..7c925337 100644 --- a/Main.py +++ b/Main.py @@ -21,7 +21,7 @@ from Fill import distribute_items_restrictive, flood_items, balance_multiworld_p from worlds.alttp.Shops import create_shops, ShopSlotFill, SHOP_ID_START, total_shop_slots, FillDisabledShopSlots from worlds.alttp.ItemPool import generate_itempool, difficulties, fill_prizes from Utils import output_path, parse_player_names, get_options, __version__, version_tuple -from worlds.generic.Rules import locality_rules +from worlds.generic.Rules import locality_rules, exclusion_rules from worlds import AutoWorld import Patch @@ -252,6 +252,9 @@ def main(args, seed=None): for player in world.alttp_player_ids: set_rules(world, player) + for player in world.player_ids: + exclusion_rules(world, player, args.excluded_locations[player]) + AutoWorld.call_all(world, "generate_basic") logger.info("Running Item Plando") diff --git a/Mystery.py b/Mystery.py index 95acff5d..608b9be8 100644 --- a/Mystery.py +++ b/Mystery.py @@ -547,6 +547,13 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b ret.startinventory = startitems ret.start_hints = set(game_weights.get('start_hints', [])) + ret.excluded_locations = set() + for location in game_weights.get('exclude_locations', []): + if location in world_type.location_names: + ret.excluded_locations.add(location) + else: + raise Exception(f"Could not exclude location {location}, as it was not recognized.") + if ret.game in AutoWorldRegister.world_types: for option_name, option in AutoWorldRegister.world_types[ret.game].options.items(): if option_name in game_weights: diff --git a/worlds/generic/Rules.py b/worlds/generic/Rules.py index 2316f008..6167d86b 100644 --- a/worlds/generic/Rules.py +++ b/worlds/generic/Rules.py @@ -9,6 +9,12 @@ def locality_rules(world, player): forbid_items_for_player(location, world.non_local_items[player], player) +def exclusion_rules(world, player: int, excluded_locations: set): + for loc_name in excluded_locations: + location = world.get_location(loc_name, player) + add_item_rule(location, lambda i: not (i.advancement or i.smallkey or i.bigkey)) + + def set_rule(spot, rule): spot.access_rule = rule