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

Migrated from github.com/amirmushichge/pixel-plays

Conkers rules: a tested `conkers/match.js` where you time a swing on a power meter to crack a run of rivals' conkers before yours cracks, from plain data, in a two-file pull with a test file that runs in under a second #256

shipped production is serving it opened this has it
opened this

A new Sport game for the catalogue: a playground conker match against a computer opponent, where you time your swing on a power meter and the strings can tangle. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] conkers/match.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a match against a stated list of opponents, each conker with stated hit points, and the striker alternating between the player and the opponent. Randomness comes only from the seed, so the same seed and inputs give the same match.
  • [x] swing(state, meter) takes a meter reading from 0 to 1 and is refused outside that range or when it is not the player's turn. A reading inside the stated sweet spot does stated full damage, a reading outside it does stated reduced damage, and a reading above a stated limit tangles the strings: no damage, and the striker loses the turn. opponentTurn(state) plays the opponent's swing from the seed.
  • [x] A conker at zero hit points is cracked. Cracking the opponent's conker wins the bout, scores a stated amount plus a stated bonus for each hit point you have left, and the next opponent steps up with your conker's hit points carried over. Your conker cracked ends the game with a loss line. Beating the last opponent ends it with a win line that reports the total score.
  • [x] conkers/match.test.mjs asserts each rule above: an out-of-range meter refused, a swing out of turn refused, sweet-spot and off-spot damage, a tangle passing the turn, the same seed giving the same match, cracking, carry-over to the next opponent, the score and bonus, the loss line and the win line.
  • [x] bun test passes for the new file.
  • [x] conkers/match.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 conkers/match.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: conkers/match.js, conkers/match.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 #262 at its head: ticked conkers/match.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a match against a stated list of opponents, each conker with stated hit points, and the striker alternating between the player and the opponent. Randomness comes only from the seed, so the same seed and inputs give the same match.; swing(state, meter) takes a meter reading from 0 to 1 and is refused outside that range or when it is not the player's turn. A reading inside the stated sweet spot does stated full damage, a reading outside it does stated reduced damage, and a reading above a stated limit tangles the strings: no damage, and the striker loses the turn. opponentTurn(state) plays the opponent's swing from the seed.; A conker at zero hit points is cracked. Cracking the opponent's conker wins the bout, scores a stated amount plus a stated bonus for each hit point you have left, and the next opponent steps up with your conker's hit points carried over. Your conker cracked ends the game with a loss line. Beating the last opponent ends it with a win line that reports the total score.; conkers/match.test.mjs asserts each rule above: an out-of-range meter refused, a swing out of turn refused, sweet-spot and off-spot damage, a tangle passing the turn, the same seed giving the same match, cracking, carry-over to the next opponent, the score and bonus, the loss line and the win line.; bun test passes for the new file.; conkers/match.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 conkers/match.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