From 0f208885631b19b7c7b0b2b0930b8b7355de7f61 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 1 Feb 2022 16:36:14 +0100 Subject: [PATCH] Options: allow yaml access to Priority Locations --- BaseClasses.py | 2 +- Main.py | 5 ++++- Options.py | 9 ++++++++- worlds/generic/Rules.py | 2 +- worlds/oot/HintList.py | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index a1c1e9c3..5435fd44 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -918,6 +918,7 @@ class LocationProgressType(Enum): PRIORITY = 2 EXCLUDED = 3 + class Location(): # If given as integer, then this is the shop's inventory index shop_slot: Optional[int] = None @@ -927,7 +928,6 @@ class Location(): spot_type = 'Location' game: str = "Generic" show_in_spoiler: bool = True - excluded: bool = False crystal: bool = False progress_type: LocationProgressType = LocationProgressType.DEFAULT always_allow = staticmethod(lambda item, state: False) diff --git a/Main.py b/Main.py index b62e545e..09262d44 100644 --- a/Main.py +++ b/Main.py @@ -9,7 +9,7 @@ import tempfile import zipfile from typing import Dict, Tuple, Optional -from BaseClasses import MultiWorld, CollectionState, Region, RegionType +from BaseClasses import MultiWorld, CollectionState, Region, RegionType, LocationProgressType 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 @@ -137,6 +137,9 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No for player in world.player_ids: exclusion_rules(world, player, world.exclude_locations[player].value) + world.priority_locations[player].value -= world.exclude_locations[player].value + for location_name in world.priority_locations[player].value: + world.get_location(location_name, player).progress_type = LocationProgressType.PRIORITY AutoWorld.call_all(world, "generate_basic") diff --git a/Options.py b/Options.py index 35c2ed14..f0bb9ac0 100644 --- a/Options.py +++ b/Options.py @@ -428,6 +428,12 @@ class ExcludeLocations(OptionSet): verify_location_name = True +class PriorityLocations(OptionSet): + """Prevent these locations from having an unimportant item""" + displayname = "Priority Locations" + verify_location_name = True + + class DeathLink(Toggle): """When you die, everyone dies. Of course the reverse is true too.""" displayname = "Death Link" @@ -440,7 +446,8 @@ per_game_common_options = { "start_inventory": StartInventory, "start_hints": StartHints, "start_location_hints": StartLocationHints, - "exclude_locations": ExcludeLocations + "exclude_locations": ExcludeLocations, + "priority_locations": PriorityLocations, } if __name__ == "__main__": diff --git a/worlds/generic/Rules.py b/worlds/generic/Rules.py index 20f8a0b2..2a607d98 100644 --- a/worlds/generic/Rules.py +++ b/worlds/generic/Rules.py @@ -32,9 +32,9 @@ def exclusion_rules(world, player: int, exclude_locations: typing.Set[str]): raise Exception(f"Unable to exclude location {loc_name} in player {player}'s world.") from e else: add_item_rule(location, lambda i: not (i.advancement or i.never_exclude)) - location.excluded = True location.progress_type = LocationProgressType.EXCLUDED + def set_rule(spot, rule: CollectionRule): spot.access_rule = rule diff --git a/worlds/oot/HintList.py b/worlds/oot/HintList.py index e3a08628..e94fd5f3 100644 --- a/worlds/oot/HintList.py +++ b/worlds/oot/HintList.py @@ -1,5 +1,7 @@ import random +from BaseClasses import LocationProgressType + # Abbreviations # DMC Death Mountain Crater # DMT Death Mountain Trail @@ -1257,7 +1259,7 @@ def hintExclusions(world, clear_cache=False): world.hint_exclusions = [] for location in world.get_locations(): - if (location.locked and (location.item.type != 'Song' or world.shuffle_song_items != 'song')) or location.excluded: + if (location.locked and (location.item.type != 'Song' or world.shuffle_song_items != 'song')) or location.progress_type == LocationProgressType.EXCLUDED: world.hint_exclusions.append(location.name) world_location_names = [