refactor: collapse item modules into plugins and remove no-op client item behaviors

This commit is contained in:
Jage9
2026-02-24 03:00:30 -05:00
parent d4dbb807da
commit 7903bab131
38 changed files with 375 additions and 345 deletions

View File

@@ -5,7 +5,6 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Literal, cast
from .items import clock, piano, radio
from .items.registry import ITEM_MODULES, ITEM_TYPE_ORDER
ItemType = Literal["radio_station", "dice", "wheel", "clock", "widget", "piano"]
@@ -15,12 +14,12 @@ ITEM_TYPE_EDITABLE_PROPERTIES: dict[ItemType, tuple[str, ...]] = {
item_type: ITEM_MODULES[item_type].EDITABLE_PROPERTIES for item_type in ITEM_TYPE_SEQUENCE
}
CLOCK_DEFAULT_TIME_ZONE = clock.DEFAULT_TIME_ZONE
CLOCK_TIME_ZONE_OPTIONS = clock.TIME_ZONE_OPTIONS
RADIO_EFFECT_OPTIONS = radio.EFFECT_OPTIONS
RADIO_CHANNEL_OPTIONS = radio.CHANNEL_OPTIONS
PIANO_INSTRUMENT_OPTIONS = piano.INSTRUMENT_OPTIONS
PIANO_VOICE_MODE_OPTIONS = piano.VOICE_MODE_OPTIONS
CLOCK_DEFAULT_TIME_ZONE = cast(str, ITEM_MODULES["clock"].DEFAULT_TIME_ZONE)
CLOCK_TIME_ZONE_OPTIONS = cast(tuple[str, ...], ITEM_MODULES["clock"].TIME_ZONE_OPTIONS)
RADIO_EFFECT_OPTIONS = cast(tuple[str, ...], ITEM_MODULES["radio_station"].EFFECT_OPTIONS)
RADIO_CHANNEL_OPTIONS = cast(tuple[str, ...], ITEM_MODULES["radio_station"].CHANNEL_OPTIONS)
PIANO_INSTRUMENT_OPTIONS = cast(tuple[str, ...], ITEM_MODULES["piano"].INSTRUMENT_OPTIONS)
PIANO_VOICE_MODE_OPTIONS = cast(tuple[str, ...], ITEM_MODULES["piano"].VOICE_MODE_OPTIONS)
@dataclass(frozen=True)

View File

@@ -1,2 +1 @@
"""Per-item modules containing item-specific schema and behavior."""
"""Item subsystem package (shared helpers + type-plugin loader)."""

View File

@@ -4,9 +4,9 @@ from __future__ import annotations
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params, parse_bool_like_or_none
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params, parse_bool_like_or_none
LABEL = "clock"
TOOLTIP = "It tells the time. What did you think it did?"

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import clock
from . import module
ITEM_TYPE_PLUGIN = {
"type": "clock",
"order": 10,
"module": clock,
"module": module,
}

View File

@@ -5,9 +5,9 @@ from __future__ import annotations
import random
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params
LABEL = "dice"
TOOLTIP = "Great for drinking games or boredom."

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import dice
from . import module
ITEM_TYPE_PLUGIN = {
"type": "dice",
"order": 20,
"module": dice,
"module": module,
}

View File

@@ -4,9 +4,9 @@ from __future__ import annotations
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params
LABEL = "piano"
TOOLTIP = "Playable keyboard instrument with multiple synth voices."

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import piano
from . import module
ITEM_TYPE_PLUGIN = {
"type": "piano",
"order": 30,
"module": piano,
"module": module,
}

View File

@@ -4,9 +4,9 @@ from __future__ import annotations
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params, toggle_bool_param
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params, toggle_bool_param
LABEL = "radio"
TOOLTIP = "Can play stations from the Internet. Tune multiple to the same station and they will sync up."

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import radio
from . import module
ITEM_TYPE_PLUGIN = {
"type": "radio_station",
"order": 40,
"module": radio,
"module": module,
}

View File

@@ -5,9 +5,9 @@ from __future__ import annotations
import random
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params
LABEL = "wheel"
TOOLTIP = "Spin to win fabulous prizes."

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import wheel
from . import module
ITEM_TYPE_PLUGIN = {
"type": "wheel",
"order": 50,
"module": wheel,
"module": module,
}

View File

@@ -4,9 +4,9 @@ from __future__ import annotations
from typing import Callable
from ..item_types import ItemUseResult
from ..models import WorldItem
from .helpers import keep_only_known_params, parse_bool_like, toggle_bool_param
from ....item_types import ItemUseResult
from ....models import WorldItem
from ...helpers import keep_only_known_params, parse_bool_like, toggle_bool_param
LABEL = "widget"
TOOLTIP = "A basic item. Make it a beacon or whatever you want."

View File

@@ -2,10 +2,10 @@
from __future__ import annotations
from ... import widget
from . import module
ITEM_TYPE_PLUGIN = {
"type": "widget",
"order": 60,
"module": widget,
"module": module,
}