4.3 KiB
4.3 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)emitRange(spatial range in squares)directional(directional attenuation enabled)
- Instance fields are persisted in
server/runtime/items.json.
radio_station
Defaults
- Title:
radio - Params:
streamUrl=""enabled=truechannel="stereo"volume=50effect="off"effectValue=50facing=0emitRange=20
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000emitRange=20directional=true
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.1precisionfacing: number0..360with0.1precisionemitRange: integer5..20
dice
Defaults
- Title:
Dice - Params:
sides=6number=2
- Global:
useSound=sounds/roll.oggemitSound=noneuseCooldownMs=1000emitRange=15directional=false
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=4000emitRange=15directional=false
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=1000emitRange=10directional=false
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
widget
Defaults
- Title:
widget - Params:
enabled=truedirectional=falsefacing=0emitRange=15useSound=""emitSound=""
- Global:
useSound=noneemitSound=noneuseCooldownMs=1000emitRange=15directional=false
Use
usetogglesenabledon/off and playsuseSoundwhen configured.
Validation
enabled: boolean or on/off style inputdirectional: boolean or on/off style inputfacing: number0..360with0.1precisionemitRange: integer1..20useSound: empty, filename (assumed undersounds/), or full URLemitSound: empty, filename (assumed undersounds/), or full URL
Adding A New Item Type (Registry V1)
Item types are currently code-registered on both server and client. Server item logic is split per item module and wired through one registry.
For a full copy/paste example with plain-English explanation, see docs/item-type-template.md.
- Server item module: add a new file under
server/app/items/with:- defaults/capabilities
- property metadata/options
validate_updateanduse_item
- Server registry: add one entry in
server/app/items/registry.py:ITEM_MODULESITEM_TYPE_ORDER(if ordering changes)
- Server models: extend
ItemTypeliterals inserver/app/models.pyand any packet enums that list item types. - Client fallback registry: add type defaults in
client/src/items/itemRegistry.ts(DEFAULT_ITEM_TYPE_SEQUENCE, editable/global fallback metadata). - Client protocol/state 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