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

Migrated from github.com/amirmushichge/pixel-plays

Cake Stall rules: a tested `cake-stall/order.js` where you memorise a seeded order of cake layers shown for a few ticks and stack them back in that order, in a two-file pull with a test file that runs in under a second #366

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added the Cake Stall rules in `cake-stall/order.js`, with its tests in `cake-stall/order.test.mjs`, and nothing else in the repository changed. `bun test cake-stall/order.test.mjs` passes 9 tests in about 39 ms, well under one second, and `bun x tsc --noEmit` reports no errors. I didn't run `scripts/gate.ts` or the full `bun test`, so the forge's check will be the first full run.

shipped production is serving it deploy 5b5fb07

opened this

I added the Cake Stall rules in cake-stall/order.js, with its tests in cake-stall/order.test.mjs, and nothing else in the repository changed. bun test cake-stall/order.test.mjs passes 9 tests in about 39 ms, well under one second, and bun x tsc --noEmit reports no errors. I didn't run scripts/gate.ts or the full bun test, so the forge's check will be the first full run.

I also didn't find docs/VISION.md in the clone, so I worked from the issue text and from tide-crossing/causeway.js and apple-bobbing/tub.js.

The rules

  • Shape: the module uses the same UMD shape as tide-crossing/causeway.js and exports CakeStall in the browser. It also exports LAYERS, LIVES, ROUNDS, restart, orderFor and describe.
  • Orders: start(seed) gives round one with 3 layers drawn from sponge, jam, cream and icing, and the number of ticks it stays shown. Round r has r + 2 layers and is shown for 3 + length ticks. The mulberry32 generator is seeded from the seed and the round number, so an order depends only on those two. restart gives the same first round again.
  • tick: it counts the showing time down and hides the order at zero.
  • place: it adds a layer once the order is hidden.
  • Refusals: each refusal returns the same state with a reason. The reasons are game-over, unknown-layer, order-shown and order-hidden (ticking an order that is already hidden).
  • Wrong layer: it costs one of three lives and clears your stack. The same order is shown afresh for the full showing time.
  • Right stack: it scores 10 points per layer and opens the next round with one more layer.
  • Ending: losing the last life gives "Out of lives: N rounds served, score …". Finishing round 8 gives "You win: all 8 orders served, score …".
  • HUD: the state carries round, lives, score, placed, order, shown, status and line.

Tests: they cover each rule in the issue and call the module directly, with no page, renderer or server.

Left out: no page, no catalogue entry, and none of the files you listed as off limits.

Closes #354

commented

I added the Cake Stall rules in cake-stall/order.js, with its tests in cake-stall/order.test.mjs, and nothing else in the repository changed. bun test cake-stall/order.test.mjs passes 9 tests in about 39 ms, well under one second, and bun x tsc --noEmit reports no errors. I didn't run scripts/gate.ts or the full bun test, so the forge's check will be the first full run.

I also didn't find docs/VISION.md in the clone, so I worked from the issue text and from tide-crossing/causeway.js and apple-bobbing/tub.js.

The rules

  • Shape: the module uses the same UMD shape as tide-crossing/causeway.js and exports CakeStall in the browser. It also exports LAYERS, LIVES, ROUNDS, restart, orderFor and describe.
  • Orders: start(seed) gives round one with 3 layers drawn from sponge, jam, cream and icing, and the number of ticks it stays shown. Round r has r + 2 layers and is shown for 3 + length ticks. The mulberry32 generator is seeded from the seed and the round number, so an order depends only on those two. restart gives the same first round again.
  • tick: it counts the showing time down and hides the order at zero.
  • place: it adds a layer once the order is hidden.
  • Refusals: each refusal returns the same state with a reason. The reasons are game-over, unknown-layer, order-shown and order-hidden (ticking an order that is already hidden).
  • Wrong layer: it costs one of three lives and clears your stack. The same order is shown afresh for the full showing time.
  • Right stack: it scores 10 points per layer and opens the next round with one more layer.
  • Ending: losing the last life gives "Out of lives: N rounds served, score …". Finishing round 8 gives "You win: all 8 orders served, score …".
  • HUD: the state carries round, lives, score, placed, order, shown, status and line.

Tests: they cover each rule in the issue and call the module directly, with no page, renderer or server.

Left out: no page, no catalogue entry, and none of the files you listed as off limits.

Approved

The rules module is pure, seeded and refuses with reasons, and the tests cover every rule in the issue. It is rules-only by design, so there is no page to see in the preview. I read the source and did not run the tests myself. Two things I would do next: (1) the playable page and catalogue entry, with a keyboard-reachable layer picker and a live-region announcement of state.line, which the HUD fields already support. (2) Credit the original, a memory-stacking cake game, in the page and README when they land.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs