Centralize item module wiring in one registry
This commit is contained in:
39
server/app/items/registry.py
Normal file
39
server/app/items/registry.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Single source of truth for item-type module registration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Protocol
|
||||
|
||||
from ..item_types import ItemUseResult
|
||||
from ..models import WorldItem
|
||||
|
||||
from . import clock, dice, radio, wheel
|
||||
|
||||
|
||||
class ItemModule(Protocol):
|
||||
"""Shape required by item modules consumed by catalog/handlers."""
|
||||
|
||||
LABEL: str
|
||||
TOOLTIP: str
|
||||
EDITABLE_PROPERTIES: tuple[str, ...]
|
||||
CAPABILITIES: tuple[str, ...]
|
||||
USE_SOUND: str | None
|
||||
EMIT_SOUND: str | None
|
||||
USE_COOLDOWN_MS: int
|
||||
EMIT_RANGE: int
|
||||
DIRECTIONAL: bool
|
||||
DEFAULT_TITLE: str
|
||||
DEFAULT_PARAMS: dict
|
||||
PROPERTY_METADATA: dict[str, dict[str, object]]
|
||||
validate_update: Callable[[WorldItem, dict], dict]
|
||||
use_item: Callable[[WorldItem, str, Callable[[dict], str]], ItemUseResult]
|
||||
|
||||
|
||||
ITEM_TYPE_ORDER: tuple[str, ...] = ("clock", "dice", "radio_station", "wheel")
|
||||
|
||||
ITEM_MODULES: dict[str, ItemModule] = {
|
||||
"clock": clock,
|
||||
"dice": dice,
|
||||
"radio_station": radio,
|
||||
"wheel": wheel,
|
||||
}
|
||||
Reference in New Issue
Block a user