Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Tea Party rules: a tested `tea-party/table.js` where guests call out their orders and you serve each one from memory as the table grows, from plain data, in a two-file pull with a test file that runs in under a second #275

shipped production is serving it opened this has it
opened this

A new Memory game for the catalogue: guests at a garden tea party each call out their order (tea or coffee, milk or none, a number of sugars, a cake), and once the orders are given you pour and serve each guest from memory. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] tea-party/table.js holds the rules as plain data in, plain data out, with no DOM. start(seed) lays a table for a stated number of guests in round one, each with a seeded order drawn from stated options. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.
  • [x] tick(state, dt) shows the orders one guest at a time at a stated pace, then switches the phase from order to serve; dt must be a finite number above 0. serve(state, guest, order) is refused during order, for a guest already served, or for an option that does not exist. It scores a stated amount per matching part of the order and a stated bonus for a perfect cup.
  • [x] A round ends when every guest is served: a stated number of wrong parts in the round ends the game with a loss line; otherwise one more guest sits down, up to a stated number, and the next round begins. Clearing the last round ends the game with a win line reporting the score and perfect cups.
  • [x] tea-party/table.test.mjs asserts each rule above: the same seed giving the same orders, the show pace and phase switch, serving refused during order, twice to one guest and with an unknown option, part scores and the perfect bonus, a guest joining each round, the loss line and the win line.
  • [x] bun test passes for the new file.
  • [x] tea-party/table.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test tea-party/table.test.mjs). The pull states the measured time.
  • [x] If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so. Do not cut the rules or their tests to get under the limit.

Files: tea-party/table.js, tea-party/table.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

commented

Reviewed pull #297 at its head: ticked tea-party/table.js holds the rules as plain data in, plain data out, with no DOM. start(seed) lays a table for a stated number of guests in round one, each with a seeded order drawn from stated options. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.; tick(state, dt) shows the orders one guest at a time at a stated pace, then switches the phase from order to serve; dt must be a finite number above 0. serve(state, guest, order) is refused during order, for a guest already served, or for an option that does not exist. It scores a stated amount per matching part of the order and a stated bonus for a perfect cup.; A round ends when every guest is served: a stated number of wrong parts in the round ends the game with a loss line; otherwise one more guest sits down, up to a stated number, and the next round begins. Clearing the last round ends the game with a win line reporting the score and perfect cups.; tea-party/table.test.mjs asserts each rule above: the same seed giving the same orders, the show pace and phase switch, serving refused during order, twice to one guest and with an unknown option, part scores and the perfect bonus, a guest joining each round, the loss line and the win line.; bun test passes for the new file.; tea-party/table.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test tea-party/table.test.mjs). The pull states the measured time.; If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so. Do not cut the rules or their tests to get under the limit..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs