2026-02-20 08:16:43 -05:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
from typing import Literal
|
|
|
|
|
|
2026-02-21 00:55:19 -05:00
|
|
|
ItemType = Literal["radio_station", "dice", "wheel"]
|
2026-02-20 08:16:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
class ItemDefinition:
|
|
|
|
|
default_title: str
|
|
|
|
|
capabilities: tuple[str, ...]
|
|
|
|
|
use_sound: str | None
|
|
|
|
|
default_params: dict
|
2026-02-20 16:47:11 -05:00
|
|
|
use_cooldown_ms: int = 1000
|
2026-02-20 08:16:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ITEM_DEFINITIONS: dict[ItemType, ItemDefinition] = {
|
|
|
|
|
"radio_station": ItemDefinition(
|
|
|
|
|
default_title="radio",
|
2026-02-21 01:11:08 -05:00
|
|
|
capabilities=("editable", "carryable", "deletable", "usable"),
|
2026-02-20 08:16:43 -05:00
|
|
|
use_sound=None,
|
2026-02-21 01:48:20 -05:00
|
|
|
default_params={"streamUrl": "", "enabled": True, "channel": "stereo", "volume": 50, "effect": "off", "effectValue": 50},
|
2026-02-20 08:16:43 -05:00
|
|
|
),
|
|
|
|
|
"dice": ItemDefinition(
|
|
|
|
|
default_title="Dice",
|
|
|
|
|
capabilities=("editable", "carryable", "deletable", "usable"),
|
|
|
|
|
use_sound="sounds/roll.ogg",
|
|
|
|
|
default_params={"sides": 6, "number": 2},
|
|
|
|
|
),
|
2026-02-21 00:55:19 -05:00
|
|
|
"wheel": ItemDefinition(
|
|
|
|
|
default_title="wheel",
|
|
|
|
|
capabilities=("editable", "carryable", "deletable", "usable"),
|
|
|
|
|
use_sound="sounds/spin.ogg",
|
|
|
|
|
default_params={"spaces": "yes, no"},
|
|
|
|
|
use_cooldown_ms=4000,
|
|
|
|
|
),
|
2026-02-20 08:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_item_definition(item_type: ItemType) -> ItemDefinition:
|
|
|
|
|
return ITEM_DEFINITIONS[item_type]
|
2026-02-20 16:47:11 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_item_use_cooldown_ms(item_type: ItemType) -> int:
|
|
|
|
|
definition = get_item_definition(item_type)
|
|
|
|
|
cooldown_ms = definition.use_cooldown_ms
|
|
|
|
|
if isinstance(cooldown_ms, int) and cooldown_ms > 0:
|
|
|
|
|
return cooldown_ms
|
|
|
|
|
return 1000
|