diff --git a/Fill.py b/Fill.py index 48ed7253d9..7bd5756627 100644 --- a/Fill.py +++ b/Fill.py @@ -280,6 +280,7 @@ def remaining_fill(multiworld: MultiWorld, item_to_place = itempool.pop() spot_to_fill: typing.Optional[Location] = None + # going through locations in the same order as the provided `locations` argument for i, location in enumerate(locations): if location_can_fill_item(location, item_to_place): # popping by index is faster than removing by content, diff --git a/worlds/dark_souls_3/__init__.py b/worlds/dark_souls_3/__init__.py index 8c9716c03d..4ee972be9c 100644 --- a/worlds/dark_souls_3/__init__.py +++ b/worlds/dark_souls_3/__init__.py @@ -6,6 +6,7 @@ from logging import warning from typing import cast, Any, Callable, Dict, Set, List, Optional, TextIO, Union from BaseClasses import CollectionState, MultiWorld, Region, Location, LocationProgressType, Entrance, Tutorial, ItemClassification +from Fill import remaining_fill from worlds.AutoWorld import World, WebWorld from worlds.generic.Rules import CollectionRule, ItemRule, add_rule, add_item_rule @@ -1473,6 +1474,7 @@ class DarkSouls3World(World): f"contain smoothed items, but only {len(converted_item_order)} items to smooth." ) + sorted_spheres = [] for sphere in locations_by_sphere: locations = [loc for loc in sphere if loc.item.name in names] @@ -1480,12 +1482,12 @@ class DarkSouls3World(World): offworld = ds3_world._shuffle([loc for loc in locations if loc.game != "Dark Souls III"]) onworld = sorted((loc for loc in locations if loc.game == "Dark Souls III"), key=lambda loc: loc.data.region_value) - # Give offworld regions the last (best) items within a given sphere - for location in onworld + offworld: - new_item = ds3_world._pop_item(location, converted_item_order) - location.item = new_item - new_item.location = location + sorted_spheres.extend(onworld) + sorted_spheres.extend(offworld) + + converted_item_order.reverse() + remaining_fill(multiworld, sorted_spheres, converted_item_order, name="DS3 Smoothing", check_location_can_fill=True) if ds3_world.options.smooth_upgrade_items: base_names = { @@ -1518,19 +1520,6 @@ class DarkSouls3World(World): self.random.shuffle(copy) return copy - def _pop_item( - self, - location: Location, - items: List[DarkSouls3Item] - ) -> DarkSouls3Item: - """Returns the next item in items that can be assigned to location.""" - for i, item in enumerate(items): - if location.can_fill(self.multiworld.state, item, False): - return items.pop(i) - - # If we can't find a suitable item, give up and assign an unsuitable one. - return items.pop(0) - def _get_our_locations(self) -> List[DarkSouls3Location]: return cast(List[DarkSouls3Location], self.multiworld.get_locations(self.player))