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

Migrated from github.com/amirmushichge/pixel-plays

Stained Glass rules: a tested `stained-glass/window.js` where you colour leaded panes so no two neighbours match, within par strokes, from plain data, in a two-file pull with a test file that runs in under a second #249

shipped production is serving it opened this has it
opened this

A new Puzzle game for the catalogue: a church window of leaded panes, and you colour each pane from a small palette so that no two panes sharing a lead line have the same colour, in as few strokes as you can. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] stained-glass/window.js holds the rules as plain data in, plain data out, with no DOM. start(level) gives a window from a stated list of hand-made levels: panes with ids, the pairs of panes that share a lead line, a palette of stated size, some panes already fixed in colour, and a stated par number of strokes. Every level has at least one solution, and the test proves it for each level.
  • [x] paint(state, pane, colour) colours a pane; it is refused for a fixed pane or a colour outside the palette. clashes(state) lists every pair of neighbouring panes with the same colour. clear(state, pane) empties a pane. Every accepted paint counts as one stroke.
  • [x] A level is solved when every pane is coloured and clashes is empty: it scores a stated amount, plus a stated bonus at or under par, and the next level begins. The game ends with a win line after the last level, reporting total strokes against total par; there is no loss, only restart(state) of the current level.
  • [x] stained-glass/window.test.mjs asserts each rule above: every level solvable, a fixed pane and an off-palette colour refused, a clash found and cleared, the stroke count, the par bonus, moving to the next level, and the win line.
  • [x] bun test passes for the new file.
  • [x] stained-glass/window.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 stained-glass/window.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: stained-glass/window.js, stained-glass/window.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 #273 at its head: ticked stained-glass/window.js holds the rules as plain data in, plain data out, with no DOM. start(level) gives a window from a stated list of hand-made levels: panes with ids, the pairs of panes that share a lead line, a palette of stated size, some panes already fixed in colour, and a stated par number of strokes. Every level has at least one solution, and the test proves it for each level.; paint(state, pane, colour) colours a pane; it is refused for a fixed pane or a colour outside the palette. clashes(state) lists every pair of neighbouring panes with the same colour. clear(state, pane) empties a pane. Every accepted paint counts as one stroke.; A level is solved when every pane is coloured and clashes is empty: it scores a stated amount, plus a stated bonus at or under par, and the next level begins. The game ends with a win line after the last level, reporting total strokes against total par; there is no loss, only restart(state) of the current level.; stained-glass/window.test.mjs asserts each rule above: every level solvable, a fixed pane and an off-palette colour refused, a clash found and cleared, the stroke count, the par bonus, moving to the next level, and the win line.; bun test passes for the new file.; stained-glass/window.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 stained-glass/window.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