diff --git a/BaseClasses.py b/BaseClasses.py index f8f31a0cc99b..da3ce498d4f1 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -1050,7 +1050,7 @@ def __init__(self, player: int, name: str = '', address: Optional[int] = None, p self.parent_region = parent def can_fill(self, state: CollectionState, item: Item, check_access=True) -> bool: - return ((self.always_allow(state, item) and item.name not in state.multiworld.non_local_items[item.player]) + return ((self.always_allow(state, item) and item.name not in state.multiworld.worlds[item.player].options.non_local_items) or ((self.progress_type != LocationProgressType.EXCLUDED or not (item.advancement or item.useful)) and self.item_rule(item) and (not check_access or self.can_reach(state)))) @@ -1246,7 +1246,7 @@ def create_playthrough(self, create_paths: bool = True) -> None: logging.debug('The following items could not be reached: %s', ['%s (Player %d) at %s (Player %d)' % ( location.item.name, location.item.player, location.name, location.player) for location in sphere_candidates]) - if any([multiworld.accessibility[location.item.player] != 'minimal' for location in sphere_candidates]): + if any([multiworld.worlds[location.item.player].options.accessibility != 'minimal' for location in sphere_candidates]): raise RuntimeError(f'Not all progression items reachable ({sphere_candidates}). ' f'Something went terribly wrong here.') else: diff --git a/worlds/generic/Rules.py b/worlds/generic/Rules.py index f0eef2248058..e930c4b8d6e9 100644 --- a/worlds/generic/Rules.py +++ b/worlds/generic/Rules.py @@ -14,16 +14,16 @@ ItemRule = typing.Callable[[object], bool] -def locality_needed(world: MultiWorld) -> bool: - for player in world.player_ids: - if world.local_items[player].value: +def locality_needed(multiworld: MultiWorld) -> bool: + for player in multiworld.player_ids: + if multiworld.worlds[player].options.local_items.value: return True - if world.non_local_items[player].value: + if multiworld.worlds[player].options.non_local_items.value: return True # Group - for group_id, group in world.groups.items(): - if set(world.player_ids) == set(group["players"]): + for group_id, group in multiworld.groups.items(): + if set(multiworld.player_ids) == set(group["players"]): continue if group["local_items"]: return True @@ -31,8 +31,8 @@ def locality_needed(world: MultiWorld) -> bool: return True -def locality_rules(world: MultiWorld): - if locality_needed(world): +def locality_rules(multiworld: MultiWorld): + if locality_needed(multiworld): forbid_data: typing.Dict[int, typing.Dict[int, typing.Set[str]]] = \ collections.defaultdict(lambda: collections.defaultdict(set)) @@ -40,32 +40,32 @@ def locality_rules(world: MultiWorld): def forbid(sender: int, receiver: int, items: typing.Set[str]): forbid_data[sender][receiver].update(items) - for receiving_player in world.player_ids: - local_items: typing.Set[str] = world.worlds[receiving_player].options.local_items.value + for receiving_player in multiworld.player_ids: + local_items: typing.Set[str] = multiworld.worlds[receiving_player].options.local_items.value if local_items: - for sending_player in world.player_ids: + for sending_player in multiworld.player_ids: if receiving_player != sending_player: forbid(sending_player, receiving_player, local_items) - non_local_items: typing.Set[str] = world.worlds[receiving_player].options.non_local_items.value + non_local_items: typing.Set[str] = multiworld.worlds[receiving_player].options.non_local_items.value if non_local_items: forbid(receiving_player, receiving_player, non_local_items) # Group - for receiving_group_id, receiving_group in world.groups.items(): - if set(world.player_ids) == set(receiving_group["players"]): + for receiving_group_id, receiving_group in multiworld.groups.items(): + if set(multiworld.player_ids) == set(receiving_group["players"]): continue if receiving_group["local_items"]: - for sending_player in world.player_ids: + for sending_player in multiworld.player_ids: if sending_player not in receiving_group["players"]: forbid(sending_player, receiving_group_id, receiving_group["local_items"]) if receiving_group["non_local_items"]: - for sending_player in world.player_ids: + for sending_player in multiworld.player_ids: if sending_player in receiving_group["players"]: forbid(sending_player, receiving_group_id, receiving_group["non_local_items"]) # create fewer lambda's to save memory and cache misses func_cache = {} - for location in world.get_locations(): + for location in multiworld.get_locations(): if (location.player, location.item_rule) in func_cache: location.item_rule = func_cache[location.player, location.item_rule] # empty rule that just returns True, overwrite