1.4 KiB
1.4 KiB
Door framework
A door is a self-contained game/program launched from the Door Games menu.
Contract (types.ts)
interface DoorModule {
id: string; // stable; also the migration namespace ("<id>/001_init.sql")
name: string; // menu name
description: string; // menu blurb, keep under ~45 chars
minSecurity?: number; // users.security_level needed to see it
migrationsDir?: string;// path.join(__dirname, 'migrations')
init?(): Promise<void>;// once at server start, after migrations (start timers here)
run(s: Session): Promise<void>; // one caller's visit; return to go back to the BBS
}
doorMenu.tslistsregistry.tsentries and runs one. A non-Disconnectederror thrown fromrunis caught and logged, and the caller goes back to the menu instead of being hung up on.- While a caller is in a door,
s.activityis the door name (shown in Who's Online).
Adding a door
src/doors/<id>/index.tsexporting aDoorModule.- Optional
src/doors/<id>/migrations/NNN_name.sql. Prefix tables with a short door tag (e.g.sl_). - Add one import line to
registry.ts. - Add
src/doors/<id>/CLAUDE.mddescribing the door's design and file map. - Keep game rules in pure modules with
*.test.tsnext to them;npm testpicks them up.
Imports allowed from a door: ../../session/*, ../../ui/*, ../../db, ../../nodes,
../../users/userRepo. Nothing else from core, and nothing from other doors.