fix MultiTracker
This commit is contained in:
parent
00ccecac9c
commit
66c15c8639
19
Fill.py
19
Fill.py
|
@ -28,7 +28,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
placements = []
|
placements = []
|
||||||
|
|
||||||
swapped_items = Counter()
|
swapped_items = Counter()
|
||||||
reachable_items: dict[str, deque] = {}
|
reachable_items: typing.Dict[int, deque] = {}
|
||||||
for item in itempool:
|
for item in itempool:
|
||||||
reachable_items.setdefault(item.player, deque()).append(item)
|
reachable_items.setdefault(item.player, deque()).append(item)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
has_beaten_game = world.has_beaten_game(maximum_exploration_state)
|
has_beaten_game = world.has_beaten_game(maximum_exploration_state)
|
||||||
|
|
||||||
for item_to_place in items_to_place:
|
for item_to_place in items_to_place:
|
||||||
spot_to_fill: Location = None
|
spot_to_fill: typing.Optional[Location] = None
|
||||||
if world.accessibility[item_to_place.player] == 'minimal':
|
if world.accessibility[item_to_place.player] == 'minimal':
|
||||||
perform_access_check = not world.has_beaten_game(maximum_exploration_state,
|
perform_access_check = not world.has_beaten_game(maximum_exploration_state,
|
||||||
item_to_place.player) if single_player_placement else not has_beaten_game
|
item_to_place.player) if single_player_placement else not has_beaten_game
|
||||||
|
@ -59,7 +59,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# we filled all reachable spots.
|
# we filled all reachable spots.
|
||||||
# try swaping 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
|
||||||
|
@ -71,7 +71,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
swap_state = sweep_from_pool(base_state, itempool)
|
swap_state = sweep_from_pool(base_state, itempool)
|
||||||
if (not single_player_placement or location.player == item_to_place.player) \
|
if (not single_player_placement or location.player == item_to_place.player) \
|
||||||
and location.can_fill(swap_state, item_to_place, perform_access_check):
|
and location.can_fill(swap_state, item_to_place, perform_access_check):
|
||||||
# Add this item to the exisiting placement, and
|
# Add this item to the existing placement, and
|
||||||
# add the old item to the back of the queue
|
# add the old item to the back of the queue
|
||||||
spot_to_fill = placements.pop(i)
|
spot_to_fill = placements.pop(i)
|
||||||
swapped_items[placed_item.player,
|
swapped_items[placed_item.player,
|
||||||
|
@ -85,7 +85,7 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
location.item = placed_item
|
location.item = placed_item
|
||||||
placed_item.location = location
|
placed_item.location = location
|
||||||
|
|
||||||
if spot_to_fill == None:
|
if spot_to_fill is None:
|
||||||
# Maybe the game can be beaten anyway?
|
# Maybe the game can be beaten anyway?
|
||||||
unplaced_items.append(item_to_place)
|
unplaced_items.append(item_to_place)
|
||||||
if world.accessibility[item_to_place.player] != 'minimal' and world.can_beat_game():
|
if world.accessibility[item_to_place.player] != 'minimal' and world.can_beat_game():
|
||||||
|
@ -103,11 +103,8 @@ def fill_restrictive(world: MultiWorld, base_state: CollectionState, locations,
|
||||||
itempool.extend(unplaced_items)
|
itempool.extend(unplaced_items)
|
||||||
|
|
||||||
|
|
||||||
def distribute_items_restrictive(world: MultiWorld, fill_locations=None):
|
def distribute_items_restrictive(world: MultiWorld):
|
||||||
# If not passed in, then get a shuffled list of locations to fill in
|
fill_locations = world.get_unfilled_locations()
|
||||||
if not fill_locations:
|
|
||||||
fill_locations = world.get_unfilled_locations()
|
|
||||||
|
|
||||||
world.random.shuffle(fill_locations)
|
world.random.shuffle(fill_locations)
|
||||||
|
|
||||||
# get items to distribute
|
# get items to distribute
|
||||||
|
@ -133,7 +130,7 @@ def distribute_items_restrictive(world: MultiWorld, fill_locations=None):
|
||||||
call_all(world, "fill_hook", progitempool, nonexcludeditempool,
|
call_all(world, "fill_hook", progitempool, nonexcludeditempool,
|
||||||
localrestitempool, nonlocalrestitempool, restitempool, fill_locations)
|
localrestitempool, nonlocalrestitempool, restitempool, fill_locations)
|
||||||
|
|
||||||
locations: dict[LocationProgressType, list[Location]] = {
|
locations: typing.Dict[LocationProgressType, typing.List[Location]] = {
|
||||||
type: [] for type in LocationProgressType}
|
type: [] for type in LocationProgressType}
|
||||||
|
|
||||||
for loc in fill_locations:
|
for loc in fill_locations:
|
||||||
|
|
|
@ -930,7 +930,7 @@ def getTracker(tracker: UUID):
|
||||||
if not room:
|
if not room:
|
||||||
abort(404)
|
abort(404)
|
||||||
locations, names, use_door_tracker, seed_checks_in_area, player_location_to_area, \
|
locations, names, use_door_tracker, seed_checks_in_area, player_location_to_area, \
|
||||||
precollected_items, games = get_static_room_data(room)
|
precollected_items, games, slot_data = get_static_room_data(room)
|
||||||
|
|
||||||
inventory = {teamnumber: {playernumber: collections.Counter() for playernumber in range(1, len(team) + 1)}
|
inventory = {teamnumber: {playernumber: collections.Counter() for playernumber in range(1, len(team) + 1)}
|
||||||
for teamnumber, team in enumerate(names)}
|
for teamnumber, team in enumerate(names)}
|
||||||
|
|
Loading…
Reference in New Issue