- A schema that describes serializable saved data.
- A class that gives your rules convenient methods.
.stateClass(GameState).
Available field schemas
Use
t.object for data that needs no methods. Use t.state when nested data benefits from its own class.
Nest state classes
Define the child before its parent:GameState and PlayerState instances, so methods such as getPlayer are available while rules execute.
Initialize fields
Class field values become the defaults for a new game. Use.setup() on the game definition for values that depend on players, setup input, or randomness.
State must stay serializable. Do not store functions, class constructors, promises, dates, maps, or external service objects in fields.
.model() are persisted.
Protect secret fields
Return a different state view to each player.