Core: World: MultiWorld and another deprecated option getter (#3254)
* world: multiworld and deprecated options getting * Oops * Found two more
This commit is contained in:
parent
af83050b75
commit
701fbab837
|
@ -1050,7 +1050,7 @@ class Location:
|
||||||
self.parent_region = parent
|
self.parent_region = parent
|
||||||
|
|
||||||
def can_fill(self, state: CollectionState, item: Item, check_access=True) -> bool:
|
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))
|
or ((self.progress_type != LocationProgressType.EXCLUDED or not (item.advancement or item.useful))
|
||||||
and self.item_rule(item)
|
and self.item_rule(item)
|
||||||
and (not check_access or self.can_reach(state))))
|
and (not check_access or self.can_reach(state))))
|
||||||
|
@ -1246,7 +1246,7 @@ class Spoiler:
|
||||||
logging.debug('The following items could not be reached: %s', ['%s (Player %d) at %s (Player %d)' % (
|
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
|
location.item.name, location.item.player, location.name, location.player) for location in
|
||||||
sphere_candidates])
|
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}). '
|
raise RuntimeError(f'Not all progression items reachable ({sphere_candidates}). '
|
||||||
f'Something went terribly wrong here.')
|
f'Something went terribly wrong here.')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -14,16 +14,16 @@ else:
|
||||||
ItemRule = typing.Callable[[object], bool]
|
ItemRule = typing.Callable[[object], bool]
|
||||||
|
|
||||||
|
|
||||||
def locality_needed(world: MultiWorld) -> bool:
|
def locality_needed(multiworld: MultiWorld) -> bool:
|
||||||
for player in world.player_ids:
|
for player in multiworld.player_ids:
|
||||||
if world.local_items[player].value:
|
if multiworld.worlds[player].options.local_items.value:
|
||||||
return True
|
return True
|
||||||
if world.non_local_items[player].value:
|
if multiworld.worlds[player].options.non_local_items.value:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Group
|
# Group
|
||||||
for group_id, group in world.groups.items():
|
for group_id, group in multiworld.groups.items():
|
||||||
if set(world.player_ids) == set(group["players"]):
|
if set(multiworld.player_ids) == set(group["players"]):
|
||||||
continue
|
continue
|
||||||
if group["local_items"]:
|
if group["local_items"]:
|
||||||
return True
|
return True
|
||||||
|
@ -31,8 +31,8 @@ def locality_needed(world: MultiWorld) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def locality_rules(world: MultiWorld):
|
def locality_rules(multiworld: MultiWorld):
|
||||||
if locality_needed(world):
|
if locality_needed(multiworld):
|
||||||
|
|
||||||
forbid_data: typing.Dict[int, typing.Dict[int, typing.Set[str]]] = \
|
forbid_data: typing.Dict[int, typing.Dict[int, typing.Set[str]]] = \
|
||||||
collections.defaultdict(lambda: collections.defaultdict(set))
|
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]):
|
def forbid(sender: int, receiver: int, items: typing.Set[str]):
|
||||||
forbid_data[sender][receiver].update(items)
|
forbid_data[sender][receiver].update(items)
|
||||||
|
|
||||||
for receiving_player in world.player_ids:
|
for receiving_player in multiworld.player_ids:
|
||||||
local_items: typing.Set[str] = world.worlds[receiving_player].options.local_items.value
|
local_items: typing.Set[str] = multiworld.worlds[receiving_player].options.local_items.value
|
||||||
if local_items:
|
if local_items:
|
||||||
for sending_player in world.player_ids:
|
for sending_player in multiworld.player_ids:
|
||||||
if receiving_player != sending_player:
|
if receiving_player != sending_player:
|
||||||
forbid(sending_player, receiving_player, local_items)
|
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:
|
if non_local_items:
|
||||||
forbid(receiving_player, receiving_player, non_local_items)
|
forbid(receiving_player, receiving_player, non_local_items)
|
||||||
|
|
||||||
# Group
|
# Group
|
||||||
for receiving_group_id, receiving_group in world.groups.items():
|
for receiving_group_id, receiving_group in multiworld.groups.items():
|
||||||
if set(world.player_ids) == set(receiving_group["players"]):
|
if set(multiworld.player_ids) == set(receiving_group["players"]):
|
||||||
continue
|
continue
|
||||||
if receiving_group["local_items"]:
|
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"]:
|
if sending_player not in receiving_group["players"]:
|
||||||
forbid(sending_player, receiving_group_id, receiving_group["local_items"])
|
forbid(sending_player, receiving_group_id, receiving_group["local_items"])
|
||||||
if receiving_group["non_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"]:
|
if sending_player in receiving_group["players"]:
|
||||||
forbid(sending_player, receiving_group_id, receiving_group["non_local_items"])
|
forbid(sending_player, receiving_group_id, receiving_group["non_local_items"])
|
||||||
|
|
||||||
# create fewer lambda's to save memory and cache misses
|
# create fewer lambda's to save memory and cache misses
|
||||||
func_cache = {}
|
func_cache = {}
|
||||||
for location in world.get_locations():
|
for location in multiworld.get_locations():
|
||||||
if (location.player, location.item_rule) in func_cache:
|
if (location.player, location.item_rule) in func_cache:
|
||||||
location.item_rule = func_cache[location.player, location.item_rule]
|
location.item_rule = func_cache[location.player, location.item_rule]
|
||||||
# empty rule that just returns True, overwrite
|
# empty rule that just returns True, overwrite
|
||||||
|
|
Loading…
Reference in New Issue