Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

RoundMachine

const RoundMachine: Machine<{ countdown: number; elapsed: number; lap: number; laps: number; reason: string; score: number; seconds: number; target: number; }, EventsIn<{ countdown: { on: { LOSE: Lost; }; wait: { seconds: (machineArgs) => number; then: Playing; }; }; lost: { }; playing: { on: { LOSE: Lost; WIN: Won; }; }; ready: { on: { LOSE: Lost; START: readonly [{ guard: (machineArgs) => boolean; target: Countdown; }, { target: Playing; }]; }; }; won: { }; }>, ValueIn<{ countdown: { on: { LOSE: Lost; }; wait: { seconds: (machineArgs) => number; then: Playing; }; }; lost: { }; playing: { on: { LOSE: Lost; WIN: Won; }; }; ready: { on: { LOSE: Lost; START: readonly [{ guard: (machineArgs) => boolean; target: Countdown; }, { target: Playing; }]; }; }; won: { }; }>, StateTags<{ countdown: { on: { LOSE: Lost; }; wait: { seconds: (machineArgs) => number; then: Playing; }; }; lost: { }; playing: { on: { LOSE: Lost; WIN: Won; }; }; ready: { on: { LOSE: Lost; START: readonly [{ guard: (machineArgs) => boolean; target: Countdown; }, { target: Playing; }]; }; }; won: { }; }>>

A round of play as a machine: playing, then won or lost; spawned in Ready it waits for START, and in Countdown it waits out its countdown first. The step scores a round in play and sends it WIN or LOSE; its countdown is a wait of countdown seconds. Its context: won when score, the coins addCoins credited while it played, reaches target, or when lap, the laps she finished, reaches laps; lost when seconds run out first, a zero turning its rule off. elapsed is the seconds it played, and reason why it was lost: "time", or the reason a game failed it with. A round spawned bare takes the defaults below, a minute and one coin; <Round> writes each of its own.