@tableverse-kit/engine is the rules package. It turns your game definition into one GameExecutor that Tableverse can run.
Your frontend does not import or run these rules. It communicates with the executor through @tableverse-kit/client.
The four parts of a game
State
The saved facts of the game, such as scores, pieces, decks, and player order.
Commands
The actions players can attempt, with input validation and execution rules.
Stages
The current phase, allowed commands, active players, and next phase.
Game definition
The state, events, setup, and initial stage assembled into one game.
Typical file layout
Small games can keep everything in a few files:game.ts as the place that assembles them.
Main exports
tdefines serializable field and input schemas.defineGameStatepairs saved fields with a state class.createCommandFactorycreates commands for that class.createStageFactorycreates the flow between player actions.defineEventsdeclares player-facing event payloads.GameDefinitionBuilderassembles the game.createGameExecutorproduces the finished runtime surface.
Rules to keep in mind
- Use the provided
rngfor every random choice.Math.random()cannot be replayed. - Store only values described by
tschemas. - Put rule changes inside command execution, automatic stages, or setup.
- Treat
gameas read-only in validation, availability, and transition callbacks. - Use hidden-information rules for secrets. Never send canonical state to a player.
Model game state
Define saved fields and rule methods.