Skip to content

Testable engine, draw-concurrency fix, complete timer removal, tests + CI/Pages#1

Merged
Tom-Notch merged 2 commits into
mainfrom
fix/engine-tests-ci-pages
Jul 4, 2026
Merged

Testable engine, draw-concurrency fix, complete timer removal, tests + CI/Pages#1
Tom-Notch merged 2 commits into
mainfrom
fix/engine-tests-ci-pages

Conversation

@Tom-Notch

Copy link
Copy Markdown
Owner

Takes over the project cleanup end to end.

Bugs fixed

  • Overlapping spins: 无中生有 (extraDraws) queued extra draws on a fixed 700ms timer while each spin took ~1200ms, so animations overlapped and the button/isDrawing state raced. A click now runs one serialized draw sequence (primary + chained extras, one spin at a time) that always re-enables the button. Removed the dead applyRule._extraGuard and capped runaway extra draws.
  • Incomplete timer removal: the prior pass left rules.default.json carrying the timer tag + timerSeconds:6 — out of sync with app.js (which claims the two are mirrors). Removed both, trimmed the t=6秒 countdown from descriptions, dropped timerSeconds from the README. A regression test now guards it.
  • Deck-share edge: displayed vs. drawn probabilities disagreed when only one deck had enabled rules. deckShares() now makes them consistent (and the display sums to 1).

Structure

  • Split all game logic into engine.js — DOM-free, UMD (browser global + CommonJS), RNG injected — so it is unit-testable. index.html still works from file:// (plain scripts, no ES modules). app.js is now just the DOM layer. ctx.drawAgain() customScript API preserved.

Tests (node --test, zero deps)

  • 16 engine tests + a DOM smoke test that drives a real draw sequence and asserts it terminates.
  • Includes an engine.jsrules.default.json sync test.

Tooling

  • pre-commit: add prettier for JS/CSS/HTML (the web files nothing else formatted).
  • CI: test.yml runs the suite on push/PR; pages.yml deploys to GitHub Pages gated on tests passing.

🤖 Generated with Claude Code

Tom-Notch and others added 2 commits July 4, 2026 09:15
…add tests + CI/Pages

Engine / bugs:
- Split all game logic out of app.js into engine.js (DOM-free, UMD: browser
  global + CommonJS) with injected RNG, so it is unit-testable. index.html
  still works from file:// (plain scripts, no modules).
- Fix overlapping spins: a click now runs one serialized draw sequence
  (primary + chained extra draws, one spin at a time) that always re-enables
  the button. Removes the dead applyRule._extraGuard and caps runaway
  extraDraws. Preserves the ctx.drawAgain() customScript API.
- Fix deck-share edge: display and draw probabilities now agree (and sum to 1)
  when only one deck has enabled rules.

Timer removal (the previous pass was incomplete):
- rules.default.json still carried the 'timer' tag + timerSeconds:6, out of
  sync with app.js. Removed both; trimmed the tap-dance seconds-countdown from
  descriptions; dropped timerSeconds from README. Regression test guards it.

Tests / tooling:
- Add zero-dependency test suite (node --test): 16 engine tests + a DOM smoke
  test that drives a real draw sequence. Includes an engine<->rules.default.json
  sync test.
- pre-commit: add prettier for JS/CSS/HTML (the web files nothing else formatted).
- CI: test.yml runs the suite on push/PR; pages.yml deploys via GitHub Actions
  gated on tests passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…moke test

The 700ms inter-extra-draw delay was hardcoded, so the DOM smoke test was
timing-dependent on which rule the RNG drew. Expose it as a setting
(default 700ms) and set it to 0 in the test so chained draws resolve
deterministically.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Tom-Notch Tom-Notch merged commit d3d49ba into main Jul 4, 2026
5 checks passed
@Tom-Notch Tom-Notch deleted the fix/engine-tests-ci-pages branch July 4, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant