Centralize item module wiring in one registry

This commit is contained in:
Jage9
2026-02-21 22:02:48 -05:00
parent 6fec20e9cd
commit 0d0b36e680
3 changed files with 61 additions and 68 deletions

View 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,
}