3.2 KiB
3.2 KiB
Item Types
This is behavior-focused documentation for item types and their defaults.
Shared Item Behavior
- Items are server-authoritative.
- Global per-type fields are injected by the server and are not persisted per-instance:
capabilitiesuseSoundemitSounduseCooldownMs(from item catalog)
- Instance fields are persisted in
server/runtime/items.json.
radio_station
Defaults
- Title:
radio - Params:
streamUrl=""enabled=truechannel="stereo"volume=50effect="off"effectValue=50
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000
Use
usetogglesenabledon/off and broadcasts chat status.
Validation
channel:stereo | mono | left | rightvolume: integer0..100effect:reverb | echo | flanger | high_pass | low_pass | offeffectValue: number0..100with0.1precision
dice
Defaults
- Title:
Dice - Params:
sides=6number=2
- Global:
useSound=sounds/roll.oggemitSound=noneuseCooldownMs=1000
Use
- Rolls
numberdice withsidessides and reports values + total.
Validation
sides: integer1..100number: integer1..100
wheel
Defaults
- Title:
wheel - Params:
spaces="yes, no"
- Global:
useSound=sounds/spin.oggemitSound=noneuseCooldownMs=4000
Use
- Announces spin immediately.
- Result is sent after delay.
Validation
spaces: comma-delimited values- At least 1 entry
- Max 100 entries
- Max 80 chars per entry
clock
Defaults
- Title:
clock - Params:
timeZone="America/Detroit"use24Hour=false
- Global:
useSound=noneemitSound=sounds/clock.ogguseCooldownMs=1000
Use
- Reports current time from item timezone and format.
Validation
timeZone: one ofCLOCK_TIME_ZONE_OPTIONSinserver/app/item_catalog.pyuse24Hour: boolean or on/off style input
Adding A New Item Type (Registry V1)
Item types are currently code-registered on both server and client so new types are additive instead of editing one large branch.
For a full copy/paste example with plain-English explanation, see docs/item-type-template.md.
- Server catalog: add global defaults in
server/app/item_catalog.py(ITEM_DEFINITIONS). - Server handlers: add
validate_update+uselogic inserver/app/item_type_handlers.pyand register it inITEM_TYPE_HANDLERS. - Server models: extend
ItemTypeliterals inserver/app/models.pyand any packet enums that list item types. - Client registry: add type metadata in
client/src/items/itemRegistry.ts(ITEM_TYPE_SEQUENCE, editable properties, and global property hints). - Client protocol types: update item-type unions in
client/src/network/protocol.tsandclient/src/state/gameState.ts. - Tests: add or update server tests under
server/tests/for use/update validation and cooldown behavior.
Example Shape
A minimal new item type usually needs:
- Catalog defaults:
default_titledefault_paramsuse_sound/emit_sounduse_cooldown_ms
- Handler behavior:
- validate params on update
- build self/others use messages
- optionally return delayed result text