Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: make get_filler_item_name abstract #4341

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/general/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions worlds/AutoWorld.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import sys
import time
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,
Expand All @@ -21,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]
Expand Down Expand Up @@ -466,10 +467,10 @@ 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()))
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:
Expand Down
3 changes: 3 additions & 0 deletions worlds/factorio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions worlds/generic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions worlds/overcooked2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading