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 #262

Merged opened this

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

Merged

This pull adds the Conkers rules in conkers/match.js and its tests in conkers/match.test.mjs. The new test file passes: 11 tests in 51 ms, measured with bun test conkers/match.test.mjs. I couldn't run bun x tsc --noEmit because the repo has no tsconfig, so it only printed its help text.

Notes

shipped production is serving it deploy ab54f53

opened this

This pull adds the Conkers rules in conkers/match.js and its tests in conkers/match.test.mjs. The new test file passes: 11 tests in 51 ms, measured with bun test conkers/match.test.mjs.

I couldn't run bun x tsc --noEmit because the repo has no tsconfig, so it only printed its help text. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Setup: start(seed) gives a match against Smudge (6 hit points), Biscuit (8) and Old Iron (10). Your conker has 12 hit points and you swing first.
  • swing(state, meter): it refuses a reading that isn't a number from 0 to 1, a swing out of turn, and any swing once the game is over.

- A reading from 0.4 to 0.6 does 4 damage. - Any other reading up to 0.85 does 1 damage. - A reading above 0.85 tangles the strings: no damage, and the turn passes.

  • Turns: every swing passes the turn, tangled or not.
  • opponentTurn(state): it draws its meter reading from the seed and the swing count, so the same seed and inputs give the same match. It uses the same damage and tangle rules as you.
  • Cracking: cracking a rival scores 100 plus 10 for each hit point you have left. The next rival steps up with your hit points carried over, and you swing first. Cracking the last rival ends the game with a win line giving the total score. Your conker cracked ends it with a loss line.

Choices to check

  • A tangle ends the striker's turn the same way any other swing does. The issue didn't say whether a tangle should cost anything more.
  • The numbers above (hit points, sweet spot, damage, score) are mine, since the issue left them to be stated. Each is a named constant at the top of the file.

I didn't add a page or a catalogue entry, and I touched nothing outside conkers/.

🤖 Generated with Claude Code

Closes #256

1 earlier comment · 1 event
commented

This pull adds the Conkers rules in conkers/match.js and its tests in conkers/match.test.mjs. The new test file passes: 11 tests in 51 ms, measured with bun test conkers/match.test.mjs.

I couldn't run bun x tsc --noEmit because the repo has no tsconfig, so it only printed its help text. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Setup: start(seed) gives a match against Smudge (6 hit points), Biscuit (8) and Old Iron (10). Your conker has 12 hit points and you swing first.
  • swing(state, meter): it refuses a reading that isn't a number from 0 to 1, a swing out of turn, and any swing once the game is over.

- A reading from 0.4 to 0.6 does 4 damage. - Any other reading up to 0.85 does 1 damage. - A reading above 0.85 tangles the strings: no damage, and the turn passes.

  • Turns: every swing passes the turn, tangled or not.
  • opponentTurn(state): it draws its meter reading from the seed and the swing count, so the same seed and inputs give the same match. It uses the same damage and tangle rules as you.
  • Cracking: cracking a rival scores 100 plus 10 for each hit point you have left. The next rival steps up with your hit points carried over, and you swing first. Cracking the last rival ends the game with a win line giving the total score. Your conker cracked ends it with a loss line.

Choices to check

  • A tangle ends the striker's turn the same way any other swing does. The issue didn't say whether a tangle should cost anything more.
  • The numbers above (hit points, sweet spot, damage, score) are mine, since the issue left them to be stated. Each is a named constant at the top of the file.

I didn't add a page or a catalogue entry, and I touched nothing outside conkers/.

🤖 Generated with Claude Code

Changes requested — before the latest push

The rules are sound and cover every box in the issue, and the 51 ms measured time is stated. Two cleanliness misses remain, both in the test file, and I am blocking on them because the list says no dead code. 1) In the loss test, lines 129-131 build a state that the loop right below immediately overwrites; delete them and declare let s, o; before the loop. 2) The comment on back is wrong; it describes something else. Reword it to say it hands the turn back to the player. Optional: OPPONENTS is exported as a mutable array and is shared by reference in start, so freeze it or copy it in the export. No other changes needed; I will approve on the next round.

commented

I made all three changes and pushed them to the same branch. bun test conkers/match.test.mjs still passes (11 tests, 59 ms on the last full run), and I didn't re-run tsc.

  • Loss test: I removed the dead setup and declared let s, o; before the loop.
  • back comment: it now reads "the same state with the turn handed back to the player".
  • OPPONENTS: the array and each entry are now frozen. start already copied each entry, so callers still get their own mutable copies.
Approved

All three earlier asks are met: the loss test has no dead setup, the back comment reads correctly, and OPPONENTS is frozen while start() still hands out mutable copies. The rules are plain data with no DOM, they are seeded, and they are covered by 11 tests measured at 59 ms. The pull touches only conkers/. No page or catalogue entry exists yet, which is what the issue asked for. Conkers is a traditional playground game, so no creator needs crediting. Two things I would do next: (1) Non-blocking: add the playable page and catalogue entry with a keyboard-operable meter (Space or Enter to stop it) and a visible, non-colour-only readout of the sweet spot and the tangle zone, so it works on a 360px phone with a thumb and with a screen reader. (2) Non-blocking: have the page word each refusal reason (bad-meter, not-your-turn, over) for a person rather than showing the code.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs