From 0fed7f129573afda9c494ce9dbb620fdd80e97bf Mon Sep 17 00:00:00 2001 From: espeon65536 Date: Tue, 5 Oct 2021 17:52:03 -0500 Subject: [PATCH] Core: do not error on location exclusion if the location has an ID value --- worlds/generic/Rules.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/worlds/generic/Rules.py b/worlds/generic/Rules.py index ed9b5542..e442a66e 100644 --- a/worlds/generic/Rules.py +++ b/worlds/generic/Rules.py @@ -23,10 +23,13 @@ def locality_rules(world, player: int): def exclusion_rules(world, player: int, exclude_locations: typing.Set[str]): for loc_name in exclude_locations: - location = world.get_location(loc_name, player) - add_item_rule(location, lambda i: not (i.advancement or i.never_exclude)) - location.excluded = True - + try: + location = world.get_location(loc_name, player) + add_item_rule(location, lambda i: not (i.advancement or i.never_exclude)) + location.excluded = True + except KeyError as e: # failed to find the given location. Check if it's a legitimate location + if loc_name not in world.worlds[player].location_name_to_id: + raise Exception(f"Could not find location {loc_name} in player {player}'s world.") from e def set_rule(spot, rule: CollectionRule): spot.access_rule = rule