From 2419f7f484610bea4e3bc991c03fc6ab3f92c74c Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 22:39:54 -0600 Subject: [PATCH 1/7] make get_filler_item_name an abstract method --- worlds/AutoWorld.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index ded8701d3b61..c2df9de077d4 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -5,6 +5,7 @@ import pathlib import sys import time +from abc import abstractmethod from random import Random from dataclasses import make_dataclass from typing import (Any, Callable, ClassVar, Dict, FrozenSet, List, Mapping, Optional, Set, TextIO, Tuple, @@ -466,9 +467,9 @@ def create_item(self, name: str) -> "Item": """ raise NotImplementedError + @abstractmethod def get_filler_item_name(self) -> str: """Called when the item pool needs to be filled with additional items to match location count.""" - logging.warning(f"World {self} is generating a filler item without custom filler pool.") return self.multiworld.random.choice(tuple(self.item_name_to_id.keys())) @classmethod From 4f2bfd6496b5fffd77c929ba52de8250d2b69a5d Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 22:41:12 -0600 Subject: [PATCH 2/7] super call for factorio/raft --- worlds/factorio/__init__.py | 3 +++ worlds/raft/__init__.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 8f8abeb292f1..a12883537e80 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -537,6 +537,9 @@ def create_item(self, name: str) -> FactorioItem: all_items[name], self.player) return item + def get_filler_item_name(self) -> str: + return super().get_filler_item_name() + class FactorioLocation(Location): game: str = Factorio.game diff --git a/worlds/raft/__init__.py b/worlds/raft/__init__.py index 71d5d1c7e44b..78fbb81aa961 100644 --- a/worlds/raft/__init__.py +++ b/worlds/raft/__init__.py @@ -224,6 +224,10 @@ def fill_slot_data(self): "DeathLink": bool(self.options.death_link) } + def get_filler_item_name(self) -> str: + return super().get_filler_item_name() + + def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): ret = Region(name, player, world) if locations: From 54a3cd648d5b02fb9110c840f32a5c57d8c672ec Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 22:43:51 -0600 Subject: [PATCH 3/7] oc2 filler name from #1172 --- worlds/overcooked2/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/worlds/overcooked2/__init__.py b/worlds/overcooked2/__init__.py index 44227d4becaa..ac7337f4f1dd 100644 --- a/worlds/overcooked2/__init__.py +++ b/worlds/overcooked2/__init__.py @@ -591,6 +591,9 @@ def write_spoiler(self, spoiler_handle: TextIO) -> None: kitchen_name = world.level_mapping[overworld_id].shortname spoiler_handle.write(f'{overworld_name} | {kitchen_name}\n') + def get_filler_item_name(self) -> str: + return "Bonus Star" + def level_unlock_requirement_factory(stars_to_win: int) -> Dict[int, int]: level_unlock_counts = dict() From f4143394fce58f6d11e211d6e360cd11eda93d01 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 23:03:16 -0600 Subject: [PATCH 4/7] inherit from ABCMeta --- worlds/AutoWorld.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index c2df9de077d4..7ab4cb363555 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -5,7 +5,7 @@ import pathlib import sys import time -from abc import abstractmethod +from abc import ABCMeta, abstractmethod from random import Random from dataclasses import make_dataclass from typing import (Any, Callable, ClassVar, Dict, FrozenSet, List, Mapping, Optional, Set, TextIO, Tuple, @@ -22,7 +22,7 @@ perf_logger = logging.getLogger("performance") -class AutoWorldRegister(type): +class AutoWorldRegister(ABCMeta): world_types: Dict[str, Type[World]] = {} __file__: str zip_path: Optional[str] @@ -470,7 +470,7 @@ def create_item(self, name: str) -> "Item": @abstractmethod def get_filler_item_name(self) -> str: """Called when the item pool needs to be filled with additional items to match location count.""" - return self.multiworld.random.choice(tuple(self.item_name_to_id.keys())) + return self.random.choice(tuple(self.item_name_to_id.keys())) @classmethod def create_group(cls, multiworld: "MultiWorld", new_player_id: int, players: Set[int]) -> World: From 8110e8c2164a9fb5eb3ce95b2a4a1d729a893151 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 23:03:24 -0600 Subject: [PATCH 5/7] generic implementation --- worlds/generic/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/worlds/generic/__init__.py b/worlds/generic/__init__.py index 29f808b20272..389799c55892 100644 --- a/worlds/generic/__init__.py +++ b/worlds/generic/__init__.py @@ -49,6 +49,9 @@ def create_item(self, name: str) -> Item: return Item(name, ItemClassification.filler, -1, self.player) raise KeyError(name) + def get_filler_item_name(self) -> str: + return "Nothing" + class PlandoItem(NamedTuple): item: str From 4642ebb72ba9e73fa225a539279516c20c61fa3e Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 7 Dec 2024 23:05:02 -0600 Subject: [PATCH 6/7] TestWorld implementation --- test/general/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/general/__init__.py b/test/general/__init__.py index 8afd84976540..3a7d3e145691 100644 --- a/test/general/__init__.py +++ b/test/general/__init__.py @@ -60,6 +60,9 @@ class TestWorld(World): location_name_to_id = {} hidden = True + def get_filler_item_name(self) -> str: + return "Nothing" + # add our test world to the data package, so we can test it later network_data_package["games"][TestWorld.game] = TestWorld.get_data_package_data() From daa2e3301406b16cba510496d77d11e618da6455 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sun, 8 Dec 2024 10:26:26 -0600 Subject: [PATCH 7/7] drop raft change --- worlds/raft/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/worlds/raft/__init__.py b/worlds/raft/__init__.py index 78fbb81aa961..71d5d1c7e44b 100644 --- a/worlds/raft/__init__.py +++ b/worlds/raft/__init__.py @@ -224,10 +224,6 @@ def fill_slot_data(self): "DeathLink": bool(self.options.death_link) } - def get_filler_item_name(self) -> str: - return super().get_filler_item_name() - - def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): ret = Region(name, player, world) if locations: