Testable engine, draw-concurrency fix, complete timer removal, tests + CI/Pages#1
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Takes over the project cleanup end to end.
Bugs fixed
isDrawingstate 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 deadapplyRule._extraGuardand capped runaway extra draws.rules.default.jsoncarrying thetimertag +timerSeconds:6— out of sync withapp.js(which claims the two are mirrors). Removed both, trimmed thet=6秒countdown from descriptions, droppedtimerSecondsfrom the README. A regression test now guards it.deckShares()now makes them consistent (and the display sums to 1).Structure
engine.js— DOM-free, UMD (browser global + CommonJS), RNG injected — so it is unit-testable.index.htmlstill works fromfile://(plain scripts, no ES modules).app.jsis now just the DOM layer.ctx.drawAgain()customScript API preserved.Tests (
node --test, zero deps)engine.js⇄rules.default.jsonsync test.Tooling
test.ymlruns the suite on push/PR;pages.ymldeploys to GitHub Pages gated on tests passing.🤖 Generated with Claude Code