1.7 KiB
1.7 KiB
Item Type Template
This page is the practical template for the current plugin-driven item architecture.
Plain-English Flow
When adding a new item type:
- Server item package
- Add
server/app/items/types/<item_type>/with:definition.pyfor metadata/constantsvalidator.pyforvalidate_update(item, next_params)actions.pyforuse_item(item, nickname, clock_formatter)module.pyas thin exported surfaceplugin.pyfor registration
- Server plugin file
- Add
server/app/items/types/<item_type>/plugin.pyexporting:typeordermodule
- Shared item-type unions
- Add the type in:
server/app/models.pyclient/src/network/protocol.tsclient/src/state/gameState.ts
- Client runtime behavior (optional)
- Default: no item-specific client module needed.
- Add
client/src/items/types/<item_type>/behavior.tsonly if this item needs custom client runtime UX/audio logic (for example piano mode).
That is enough for a first working item type.
Reference Sample Folder
See docs/examples/item-type-sample/ for a complete copyable folder with all five files.
Minimal module.py Example
from .actions import use_item
from .definition import LABEL, TOOLTIP, EDITABLE_PROPERTIES, CAPABILITIES, USE_SOUND, EMIT_SOUND, USE_COOLDOWN_MS, EMIT_RANGE, DIRECTIONAL, DEFAULT_TITLE, DEFAULT_PARAMS, PROPERTY_METADATA
from .validator import validate_update
Checklist Before Commit
- Add/adjust server tests for
useandupdatevalidation. - Run
cd server && uv run --extra dev pytest. - Run
cd client && npm run lint && npm run build. - Update
docs/item-types.mdanddocs/item-schema.mdif behavior/defaults changed.