**Each is built on one of the **pattern helpers, and each is real: you can configure it and play it today.
These are the models to read before writing your own, and shipping a turn-based game starts by composing one of them.
battle — the simultaneous pattern
Secret offensive and defensive moves. An offense scores unless any opponent blocked it.
A duel by default; set players higher for a free-for-all. Every field here is in the reference.
{
key: "battle",
kind: "battle",
rules: {
offense: {
pick: 3,
moves: [
{ name: "fire", power: 10 },
{ name: "ice", power: 8 },
{ name: "wind", power: 6 },
{ name: "stone", power: 4 },
],
},
defense: {
pick: 3,
moves: [
{ name: "guard-fire", blocks: "fire" },
{ name: "guard-ice", blocks: "ice" },
{ name: "guard-wind", blocks: "wind" },
{ name: "guard-stone", blocks: "stone" },
],
},
},
turnTimeoutMs: 60_000,
leaderboard: { board: "wins", points: { win: 3, draw: 1, loss: 0 } },
}The timeout is alarm-enforced, never a timer — a submission that does not land in time abandons the session.
The leaderboard publish is optional and needs the leaderboard capability composed.
An action is { offense, defense }.
connect-n — the turn-based pattern
One model, three games, config apart:
| Game | Rules |
|---|---|
| Tic-tac-toe | { rows: 3, cols: 3, connect: 3 } |
| Connect Four | { rows: 7, cols: 6, connect: 4 } |
| Gomoku | { rows: 15, cols: 15, connect: 5 } |
{ key: "tictactoe", kind: "connect-n", rules: { rows: 3, cols: 3, connect: 3 } }An action is { row, col }.
Nothing here is hidden, so its redact returns the same view to everyone — which is what a fully-open game looks like through the seam.
craps — the wagering-table pattern
Pass and don’t-pass and field bets, come-out and point phases, shooter rotation, with the house as the off-ledger counterparty.
{
key: "craps",
kind: "craps",
mode: "table",
players: 8,
rules: { currency: "chips", minBet: 5, maxBet: 100 },
}An action is { kind: "bet", ... } or { kind: "event" }.
mode: "table" is what makes it long-lived — active from creation, players buying in and cashing out between rounds.
Install the ledger capability. A wagering model declares effects, and without a ledger there is nothing to settle them against.
They are examples, not a library you are stuck inside
For anything the three do not cover — a Words-With-Friends-style game with a hidden rack and a dictionary — pick the closest pattern, or the raw seam, write the game, and register it in your Worker entry.
Only the game logic is yours. The session infrastructure is the same for every game.
And re-registering a built-in’s kind replaces it, so overriding one of these is a supported move rather than a fork.