ItemLinks: fix all_state not collecting event locations

This commit is contained in:
Fabian Dill 2022-02-22 09:49:01 +01:00
parent de5249f99e
commit 5dbccfcbbd
2 changed files with 13 additions and 12 deletions

View File

@ -272,6 +272,7 @@ class MultiWorld():
def _recache(self): def _recache(self):
"""Rebuild world cache""" """Rebuild world cache"""
self._cached_locations = None
for region in self.regions: for region in self.regions:
player = region.player player = region.player
self._region_cache[player][region.name] = region self._region_cache[player][region.name] = region

24
Fill.py
View File

@ -4,7 +4,6 @@ import collections
import itertools import itertools
from collections import Counter, deque from collections import Counter, deque
from BaseClasses import CollectionState, Location, LocationProgressType, MultiWorld, Item from BaseClasses import CollectionState, Location, LocationProgressType, MultiWorld, Item
from worlds.AutoWorld import call_all from worlds.AutoWorld import call_all
@ -14,7 +13,7 @@ class FillError(RuntimeError):
pass pass
def sweep_from_pool(base_state: CollectionState, itempool=[]): def sweep_from_pool(base_state: CollectionState, itempool: typing.Sequence[Item] = tuple()):
new_state = base_state.copy() new_state = base_state.copy()
for item in itempool: for item in itempool:
new_state.collect(item, True) new_state.collect(item, True)
@ -22,8 +21,8 @@ def sweep_from_pool(base_state: CollectionState, itempool=[]):
return new_state return new_state
def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations, itempool: typing.List[Item], def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations: typing.List[Location],
single_player_placement=False, lock=False): itempool: typing.List[Item], single_player_placement=False, lock=False):
unplaced_items = [] unplaced_items = []
placements: typing.List[Location] = [] placements: typing.List[Location] = []
@ -62,7 +61,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
else: else:
# we filled all reachable spots. # we filled all reachable spots.
# try swapping this item with previously placed items # try swapping this item with previously placed items
for(i, location) in enumerate(placements): for (i, location) in enumerate(placements):
placed_item = location.item placed_item = location.item
# Unplaceable items can sometimes be swapped infinitely. Limit the # Unplaceable items can sometimes be swapped infinitely. Limit the
# number of times we will swap an individual item to prevent this # number of times we will swap an individual item to prevent this
@ -233,7 +232,8 @@ def distribute_items_restrictive(world: MultiWorld):
logging.info(f'Per-Player counts: {print_data})') logging.info(f'Per-Player counts: {print_data})')
def fast_fill(world: MultiWorld, item_pool: typing.List, fill_locations: typing.List) -> typing.Tuple[typing.List, typing.List]: def fast_fill(world: MultiWorld, item_pool: typing.List, fill_locations: typing.List) -> typing.Tuple[
typing.List, typing.List]:
placing = min(len(item_pool), len(fill_locations)) placing = min(len(item_pool), len(fill_locations))
for item, location in zip(item_pool, fill_locations): for item, location in zip(item_pool, fill_locations):
world.push_item(location, item, False) world.push_item(location, item, False)
@ -338,7 +338,7 @@ def balance_multiworld_progression(world: MultiWorld):
balancing_state.collect(location.item, True, location) balancing_state.collect(location.item, True, location)
player = location.item.player player = location.item.player
# only replace items that end up in another player's world # only replace items that end up in another player's world
if(not location.locked and if (not location.locked and
player in balancing_players and player in balancing_players and
location.player != player and location.player != player and
location.progress_type != LocationProgressType.PRIORITY): location.progress_type != LocationProgressType.PRIORITY):
@ -441,7 +441,7 @@ def distribute_planned(world: MultiWorld):
logging.debug(f'{warning}') logging.debug(f'{warning}')
def failed(warning: str, force): def failed(warning: str, force):
if force in [True, 'fail', 'failure']: if force in [True, 'fail', 'failure']:
raise Exception(warning) raise Exception(warning)
else: else:
warn(warning, force) warn(warning, force)
@ -502,15 +502,15 @@ def distribute_planned(world: MultiWorld):
block['locations'] = locations block['locations'] = locations
if not block['count']: if not block['count']:
block['count'] = (min(len(block['items']), len(block['locations'])) if len(block['locations']) block['count'] = (min(len(block['items']), len(block['locations'])) if
> 0 else len(block['items'])) len(block['locations']) > 0 else len(block['items']))
if isinstance(block['count'], int): if isinstance(block['count'], int):
block['count'] = {'min': block['count'], 'max': block['count']} block['count'] = {'min': block['count'], 'max': block['count']}
if 'min' not in block['count']: if 'min' not in block['count']:
block['count']['min'] = 0 block['count']['min'] = 0
if 'max' not in block['count']: if 'max' not in block['count']:
block['count']['max'] = (min(len(block['items']), len(block['locations'])) if len(block['locations']) block['count']['max'] = (min(len(block['items']), len(block['locations'])) if
> 0 else len(block['items'])) len(block['locations']) > 0 else len(block['items']))
if block['count']['max'] > len(block['items']): if block['count']['max'] > len(block['items']):
count = block['count'] count = block['count']
failed(f"Plando count {count} greater than items specified", block['force']) failed(f"Plando count {count} greater than items specified", block['force'])