Mirage Source 6
Reference / Enums, Packets & API

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)

EnumValues (0-indexed)Extended via
ItemTypeNone, Weapon, Armor, Helmet, Shield, ConsumableHP(Sub), ConsumableMP(Sub), ConsumableSP(Sub), Key, Currency, Spell, Warp — 0 to 14itemEffectRegistry
NpcBehaviorAttackOnSight, AttackWhenAttacked, Friendly, Shopkeeper, Guard — 0 to 4npcBehaviorRegistry
SpellTypeAddHP, AddMP, AddSP, SubHP, SubMP, SubSP, GiveItem — 0 to 6spellEffectRegistry
TileTypeWalkable, Blocked, Warp, ItemSpawn, NpcAvoid, Key, KeyOpen, Heal, Kill, Door, Sign, Message, Sprite, NpcSpawn, Nudge — 0 to 14tileTriggerRegistry (on-enter types only — see Behaviors & Rules)
MapMoralNone, Safe, PK—
AccessLevelNone, Monitor, Mapper, Developer, Creator—
ChatChannelSay, MapChat, Global, Broadcast, Admin, Whisper, Emote, Map—
TradeAction, PartyAction, GuildActionRequest/Invite/Accept/Decline/... action verbs for their respective systems—
DirectionUp, 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 fileBase pathCovers
routes/auth.ts/api/authRegister, login, character create/delete/list
routes/content.ts/api/contentItems, NPCs, spells, shops, maps, server config, classes, music file listing — GET (public read) + PUT/POST (Developer/Mapper+)
routes/admin.ts/api/adminAccount/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).