Enums, packets & REST API
All defined in packages/shared/src/ — the single source of
truth both client and server import from. This page summarizes what's
there; treat the source files as authoritative.
Enums (enumerations.ts)
| Enum | Values (0-indexed) | Extended via |
|---|---|---|
ItemType | None, Weapon, Armor, Helmet, Shield, ConsumableHP(Sub), ConsumableMP(Sub), ConsumableSP(Sub), Key, Currency, Spell, Warp — 0 to 14 | itemEffectRegistry |
NpcBehavior | AttackOnSight, AttackWhenAttacked, Friendly, Shopkeeper, Guard — 0 to 4 | npcBehaviorRegistry |
SpellType | AddHP, AddMP, AddSP, SubHP, SubMP, SubSP, GiveItem — 0 to 6 | spellEffectRegistry |
TileType | Walkable, Blocked, Warp, ItemSpawn, NpcAvoid, Key, KeyOpen, Heal, Kill, Door, Sign, Message, Sprite, NpcSpawn, Nudge — 0 to 14 | tileTriggerRegistry (on-enter types only — see Behaviors & Rules) |
MapMoral | None, Safe, PK | — |
AccessLevel | None, Monitor, Mapper, Developer, Creator | — |
ChatChannel | Say, MapChat, Global, Broadcast, Admin, Whisper, Emote, Map | — |
TradeAction, PartyAction, GuildAction | Request/Invite/Accept/Decline/... action verbs for their respective systems | — |
Direction | Up, Down, Left, Right | — |
When registering a custom behavior for one of the "Extended via" enums, pick an id well above the highest built-in value (e.g. start at 100) so a future engine update that adds a new built-in value can never collide with yours.
Packets (packets/client.ts, packets/server.ts)
ClientPacket and ServerPacket are plain string
constant maps (not enums) — every room.send(...)/
onMessage(...) call uses one of these instead of a string
literal. Categories, roughly:
- Auth/character select: NewAccount, Login, AddChar, DelChar, UseChar
- Movement: PlayerMove, PlayerDir
- Inventory/items: PickupItem, DropItem, UseItem, UnequipItem, BuyItem, RepairItems
- Combat/spells: Attack, UseSpell
- Chat: Say, Emote, Global, Broadcast, AdminMsg, PlayerMsg, MapMsg
- Admin: SetAccess, Kick, Ban, Warp, SetSpawn
- Trade/Party/Guild: Trade, Party, Guild (each takes an action sub-field from its own enum)
- Live content updates (server → client): UpdateItem, UpdateNpc, UpdateSpell, UpdateShop, ServerConfig — pushed by REST saves, see Architecture
packets/payloads.ts has the typed payload interface for each
one (S_* for server→client, C_* for
client→server).
REST API (packages/server/src/routes/)
Used by the standalone editor and by the game client's login/character
flow. All write endpoints require a Bearer JWT with
sufficient AccessLevel.
| Route file | Base path | Covers |
|---|---|---|
routes/auth.ts | /api/auth | Register, login, character create/delete/list |
routes/content.ts | /api/content | Items, NPCs, spells, shops, maps, server config, classes, music file listing — GET (public read) + PUT/POST (Developer/Mapper+) |
routes/admin.ts | /api/admin | Account/ban administration |
Every content type follows the same REST shape: GET /:type
(list), GET /:type/:id (one record), PUT /:type/:id
(update), POST /:type (create, server assigns the next id).