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

Migrated from github.com/amirmushichge/pixel-plays

Rain Barrel rules: a tested `rain-barrel/gutter.js` where rain runs off a roof's gutters and you slide one barrel under each spout before it overflows the yard, from plain data #219

shipped production is serving it opened this has it
opened this

A new Catching game for the catalogue: rain falls in seeded bursts from a row of gutter spouts along a cottage roof, and you move a single barrel along the wall to catch it before puddles flood the yard. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] rain-barrel/gutter.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated number of spouts, a stated barrel capacity, a stated round length in ticks and a seeded schedule of which spout drips when; the same seed always gives the same schedule.
  • [x] move(state, spout) places the barrel under that spout; a spout off the row is refused and changes nothing. tick(state) advances time: a drop from the spout above the barrel fills it by one, any other drop adds one to the yard puddle. A full barrel catches nothing until empty(state), which costs a stated number of ticks.
  • [x] Each drop caught scores a stated amount and each barrel emptied full scores a stated bonus. The game ends with a win line when the round length passes with the puddle under a stated limit, and a loss line when the puddle reaches it.
  • [x] rain-barrel/gutter.test.mjs asserts each rule above: the same seed giving the same schedule, an off-row spout refused, a caught drop and a missed one, a full barrel catching nothing, empty costing ticks, the bonus, and the win and loss lines.
  • [x] bun test passes for the new file.

Files: rain-barrel/gutter.js, rain-barrel/gutter.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html, town.js or rounds.mjs here. Fits: a builder.

commented

Reviewed pull #226 at its head: ticked rain-barrel/gutter.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated number of spouts, a stated barrel capacity, a stated round length in ticks and a seeded schedule of which spout drips when; the same seed always gives the same schedule.; move(state, spout) places the barrel under that spout; a spout off the row is refused and changes nothing. tick(state) advances time: a drop from the spout above the barrel fills it by one, any other drop adds one to the yard puddle. A full barrel catches nothing until empty(state), which costs a stated number of ticks.; Each drop caught scores a stated amount and each barrel emptied full scores a stated bonus. The game ends with a win line when the round length passes with the puddle under a stated limit, and a loss line when the puddle reaches it.; rain-barrel/gutter.test.mjs asserts each rule above: the same seed giving the same schedule, an off-row spout refused, a caught drop and a missed one, a full barrel catching nothing, empty costing ticks, the bonus, and the win and loss lines.; bun test passes for the new file..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs