Update item docs for per-item modules and registry
This commit is contained in:
@@ -112,15 +112,20 @@ This is behavior-focused documentation for item types and their defaults.
|
||||
|
||||
## 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.
|
||||
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`.
|
||||
|
||||
1. Server catalog: add global defaults in `server/app/item_catalog.py` (`ITEM_DEFINITIONS`).
|
||||
2. Server handlers: add `validate_update` + `use` logic in `server/app/item_type_handlers.py` and register it in `ITEM_TYPE_HANDLERS`.
|
||||
1. Server item module: add a new file under `server/app/items/` with:
|
||||
- defaults/capabilities
|
||||
- property metadata/options
|
||||
- `validate_update` and `use_item`
|
||||
2. Server registry: add one entry in `server/app/items/registry.py`:
|
||||
- `ITEM_MODULES`
|
||||
- `ITEM_TYPE_ORDER` (if ordering changes)
|
||||
3. Server models: extend `ItemType` literals in `server/app/models.py` and any packet enums that list item types.
|
||||
4. Client registry: add type metadata in `client/src/items/itemRegistry.ts` (`ITEM_TYPE_SEQUENCE`, editable properties, and global property hints).
|
||||
5. Client protocol types: update item-type unions in `client/src/network/protocol.ts` and `client/src/state/gameState.ts`.
|
||||
4. Client fallback registry: add type defaults in `client/src/items/itemRegistry.ts` (`DEFAULT_ITEM_TYPE_SEQUENCE`, editable/global fallback metadata).
|
||||
5. Client protocol/state types: update item-type unions in `client/src/network/protocol.ts` and `client/src/state/gameState.ts`.
|
||||
6. Tests: add or update server tests under `server/tests/` for use/update validation and cooldown behavior.
|
||||
|
||||
### Example Shape
|
||||
|
||||
Reference in New Issue
Block a user