Win conditions
A game ends when an end_game action fires,
when countdownSeconds expires, or
when a team is eliminated. Here are the common shapes.
Reach a target score
Section titled “Reach a target score”compare fires for anyone over the threshold; a won flag makes it announce
once.
- id: win when: kind: and children: - { kind: compare, who: any, op: gte, left: { ref: same.state.score }, right: 30 } - { kind: state_equals, who: same, key: won, value: false } do: - { kind: set_state, target: same, key: won, value: true } - { kind: send_event, to: any, event: { type: toast, text: "Game over — someone reached 30!" } } - { kind: end_game }Adapted from king_of_the_hill (which announces but, if you want a hard stop, add
end_game as shown).
Last one standing
Section titled “Last one standing”count_state n: 1 holds when exactly one player still matches; bind that survivor
and declare them the winner.
- id: winner when: kind: and children: - { kind: count_state, who: any, key: alive, value: true, n: 1 } - { kind: state_equals, who: same, key: alive, value: true } do: - { kind: send_event, to: same, event: { type: toast, text: "You win." } } - { kind: end_game }Source: apps/wage-engine/src/games/assassin/game.json (the winner rule; add
end_game to stop the session).
Run out the clock
Section titled “Run out the clock”For a fixed-duration game, set the timer at the top level and let the engine end it:
countdownSeconds: 900 # 15 minutesWhen it expires the engine ends the game automatically. Decide the winner however
you like at that point — Pirate’s Booty compares each crew’s total score.
Team elimination
Section titled “Team elimination”If every member of a team is out, the engine can end the game on elimination. You
typically drive “out” yourself by setting alive: false (see Freeze &
thaw and Bots vs Humans’ death rule), then either
count_state the survivors or rely on the engine’s elimination check.