Skip to content

Commit

Permalink
Core: check if a location is an event before excluding it (Archipelag…
Browse files Browse the repository at this point in the history
…oMW#2653)

* Core: check if a location is an event before excluding it

* log a warning

* put the warning in the right spot
  • Loading branch information
alwaysintreble authored and Jouramie committed Feb 28, 2024
1 parent 3f7b864 commit 7e08144
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions worlds/generic/Rules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
import logging
import typing

from BaseClasses import LocationProgressType, MultiWorld, Location, Region, Entrance
Expand Down Expand Up @@ -81,15 +82,18 @@ def forbid(sender: int, receiver: int, items: typing.Set[str]):
i.name not in sending_blockers[i.player] and old_rule(i)


def exclusion_rules(world: MultiWorld, player: int, exclude_locations: typing.Set[str]) -> None:
def exclusion_rules(multiworld: MultiWorld, player: int, exclude_locations: typing.Set[str]) -> None:
for loc_name in exclude_locations:
try:
location = world.get_location(loc_name, player)
location = multiworld.get_location(loc_name, player)
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:
if loc_name not in multiworld.worlds[player].location_name_to_id:
raise Exception(f"Unable to exclude location {loc_name} in player {player}'s world.") from e
else:
location.progress_type = LocationProgressType.EXCLUDED
if not location.event:
location.progress_type = LocationProgressType.EXCLUDED
else:
logging.warning(f"Unable to exclude location {loc_name} in player {player}'s world.")


def set_rule(spot: typing.Union["BaseClasses.Location", "BaseClasses.Entrance"], rule: CollectionRule):
Expand Down

0 comments on commit 7e08144

Please sign in to comment.