Compare commits

...

3 Commits

Author SHA1 Message Date
Fabian Dill
775f56036c fix type 2025-01-09 17:02:36 +01:00
Fabian Dill
39342ad5d5 review concerns 2025-01-09 17:01:19 +01:00
Fabian Dill
ce09144261 Core: add creation reason to filler 2025-01-08 00:30:03 +01:00
5 changed files with 22 additions and 10 deletions

View File

@@ -373,7 +373,8 @@ class MultiWorld():
items_to_add.append(AutoWorld.call_single(self, "create_item", item_player,
group["replacement_items"][player]))
else:
items_to_add.append(AutoWorld.call_single(self, "create_filler", item_player))
items_to_add.append(AutoWorld.call_single(self, "create_filler", item_player,
AutoWorld.FillerReason.item_link))
self.random.shuffle(items_to_add)
self.itempool.extend(items_to_add[:itemcount - len(self.itempool)])

10
Fill.py
View File

@@ -7,7 +7,7 @@ from collections import Counter, deque
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld
from Options import Accessibility
from worlds.AutoWorld import call_all
from worlds.AutoWorld import call_all, FillerReason
from worlds.generic.Rules import add_item_rule
@@ -316,7 +316,7 @@ def remaining_fill(multiworld: MultiWorld,
for item in unplaced_items:
logging.debug(f"Moved {item} to start_inventory to prevent fill failure.")
multiworld.push_precollected(item)
last_batch.append(multiworld.worlds[item.player].create_filler())
last_batch.append(multiworld.worlds[item.player].create_filler(FillerReason.panic_fill))
remaining_fill(multiworld, locations, unplaced_items, name + " Start Inventory Retry")
else:
raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n"
@@ -521,7 +521,7 @@ def distribute_items_restrictive(multiworld: MultiWorld,
for item in progitempool:
logging.debug(f"Moved {item} to start_inventory to prevent fill failure.")
multiworld.push_precollected(item)
filleritempool.append(multiworld.worlds[item.player].create_filler())
filleritempool.append(multiworld.worlds[item.player].create_filler(FillerReason.panic_fill))
logging.warning(f"{len(progitempool)} items moved to start inventory,"
f" due to failure in Progression fill step.")
progitempool[:] = []
@@ -545,7 +545,7 @@ def distribute_items_restrictive(multiworld: MultiWorld,
inaccessible_location_rules(multiworld, multiworld.state, defaultlocations)
remaining_fill(multiworld, excludedlocations, filleritempool, "Remaining Excluded",
move_unplaceable_to_start_inventory=panic_method=="start_inventory")
move_unplaceable_to_start_inventory=panic_method == "start_inventory")
if excludedlocations:
raise FillError(
@@ -557,7 +557,7 @@ def distribute_items_restrictive(multiworld: MultiWorld,
restitempool = filleritempool + usefulitempool
remaining_fill(multiworld, defaultlocations, restitempool,
move_unplaceable_to_start_inventory=panic_method=="start_inventory")
move_unplaceable_to_start_inventory=panic_method == "start_inventory")
unplaced = restitempool
unfilled = defaultlocations

View File

@@ -181,7 +181,8 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
logger.warning(f"{player_name} tried to remove items from their pool that don't exist: {unfound_items}")
needed_items = target_per_player[player] - sum(unfound_items.values())
new_itempool += [multiworld.worlds[player].create_filler() for _ in range(needed_items)]
new_itempool += [multiworld.worlds[player].create_filler(AutoWorld.FillerReason.start_inventory_from_pool)
for _ in range(needed_items)]
assert len(multiworld.itempool) == len(new_itempool), "Item Pool amounts should not change."
multiworld.itempool[:] = new_itempool

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import enum
import hashlib
import logging
import pathlib
@@ -18,6 +19,15 @@ if TYPE_CHECKING:
from . import GamesPackage
from settings import Group
class FillerReason(enum.StrEnum):
undefined = enum.auto()
item_link = enum.auto()
panic_fill = enum.auto()
start_inventory_from_pool = enum.auto()
world = enum.auto()
perf_logger = logging.getLogger("performance")
@@ -527,7 +537,7 @@ class World(metaclass=AutoWorldRegister):
return False
# following methods should not need to be overridden.
def create_filler(self) -> "Item":
def create_filler(self, reason: FillerReason = FillerReason.undefined) -> "Item":
return self.create_item(self.get_filler_item_name())
# convenience methods

View File

@@ -5,7 +5,7 @@ import itertools
from typing import List, Dict, Any, cast
from BaseClasses import Region, Location, Item, Tutorial, ItemClassification
from worlds.AutoWorld import World, WebWorld
from worlds.AutoWorld import World, WebWorld, FillerReason
from . import items
from . import locations
from . import creatures
@@ -142,7 +142,7 @@ class SubnauticaWorld(World):
# resource bundle filler
for _ in range(extras):
item = self.create_filler()
item = self.create_filler(FillerReason.world)
item = cast(SubnauticaItem, item)
pool.append(item)