Skip to content

Card Rat: pause to shuffle the deck between passes - #239

Merged
acrosman merged 8 commits into
mainfrom
feat/198-shuffle-pause
Oct 25, 2026
Merged

acrosman merged 8 commits into
mainfrom
feat/198-shuffle-pause

Conversation

@acrosman

@acrosman acrosman commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Once all 55 cards in a pass have been dealt, Card Rat now pauses to shuffle before dealing the next pass, as the issue asks. This PR also adds a separate sound harness, so a sound can be heard without playing a game.

What changed

  • Audio service: a new playShuffleSound() that is synthesized, not a recording. It plays about 0.75 s of softened noise whose level flutters smoothly, quickly at first and slower as the last cards fall, then a soft swish. The noise is darkened (one-pole smoothing plus a 2000 Hz low-pass) to keep hiss down, and the gain is 0.15.
  • Game logic (game.js): dealNextCard() now reports deckExhausted on the last card of a pass. A new shuffleForNextPass() only replaces the deck:
    • The last card stays current and stays on the table.
    • Slaps during the shuffle score as they would at any other time.
    • A trigger that wasn't slapped is still scored as a miss when the next card is dealt.
    • Pairs and sandwiches carry across into the new pass.
  • Controller (index.js): after the last card's display time, the status line reads "Shuffling". After 500 ms, the deck card wiggles and the shuffle sound plays. The next deal comes 1200 ms later. End Game cancels the shuffle, as it does the deal timer.
  • The shuffle sound follows the existing Card sound checkbox. The wiggle is off under prefers-reduced-motion.
  • Sound harness: npm run sound-harness opens a separate Electron window that plays every sound in audioService.js:
    • Each play* function that takes no arguments gets a button on its own.
    • The four playSweepPair sequences come from SOUND_PRESETS, with inputs for sweep length and gap.
    • playFeedbackSound only calls playSuccessSound or playFailureSound, so it is listed in SOUND_WRAPPERS and gets no buttons of its own. Each sound has one button.
    • A test fails if the service exports a play* function the harness can't play.
    • It lives in scripts/sound-harness/, which Forge does not package.
  • The welcome panel gets one more line about the shuffle, and the matching CLAUDE.md files are updated.

Worth a close look

  • Status line: a slap during the shuffle replaces "Shuffling" with the normal slap feedback, as it would for any other slap.
  • Sound tuning: the values are named constants at the top of the shuffle section in audioService.js. Use the harness to try changes.

Testing

  • npm run lint is clean.
  • npm run test:coverage: all 2198 tests pass, and the coverage thresholds are met.
  • In the real app (isolated user-data dir), I played through a full pass:
    • "Shuffling" appeared and the last card stayed visible.
    • Pressing Space during the shuffle on a non-trigger counted as a false alarm.
    • The shuffle started 500 ms later, and the first card of the new pass came about 1.7 s after the last card's time ended.
    • There were no console errors.
  • I launched the harness and clicked all 8 buttons (sweeps set to 80/40 ms). There were no errors. I could not listen to them.

Signed: Claude Code

🤖 Generated with Claude Code

acrosman and others added 8 commits October 24, 2026 21:59
playShuffleSound() generates a riffle of short noise clicks followed by a
soft swish, played through a band-pass filter. No audio file is used.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the last card of a pass, the table clears and the status line reads
"Shuffling". After a short pause, the deck card wiggles and the shuffle
sound plays (unless Card sound is off), then the next pass is dealt.

An unslapped trigger on the last card still counts as a miss. Slaps while
shuffling are ignored, and the first card of a new pass cannot pair or
sandwich with cards from the old one.

Fixes #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shuffle now only replaces the deck. The last card stays on the table
and stays current, so slaps during the shuffle score as they would at any
other time, a missed trigger is still scored when the next card is dealt,
and pairs and sandwiches carry across into the new pass.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the separate noise clicks with continuous softened noise whose
level flutters smoothly, quickly at first and slower as the last cards
fall, through a low-pass filter instead of a band-pass filter.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
npm run sound-harness opens a separate Electron window with a button for
each play* function in audioService.js that takes no arguments, so a sound
can be heard and tuned without playing a game. It lives in scripts/, which
Forge does not package.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lower its gain from 0.25 to 0.15, and darken the noise: a stronger
one-pole smoothing (0.35 to 0.2) and a lower low-pass cutoff (3000 Hz to
2000 Hz) cut the white-noise hiss.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add presets for the sounds that need arguments: success and failure
through playFeedbackSound, and all four playSweepPair sequences, with
inputs for the sweep length and gap. A test fails if the audio service
exports a play* function the harness cannot play.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
playFeedbackSound only calls playSuccessSound or playFailureSound, so its
two buttons repeated the Success and Failure buttons. SOUND_WRAPPERS now
lists it as a wrapper, which gets no buttons of its own; the harness test
checks that each wrapper's sounds have buttons.

Refs #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acrosman
acrosman merged commit 3006b7b into main Oct 25, 2026
7 checks passed
@acrosman
acrosman deleted the feat/198-shuffle-pause branch October 25, 2026 14:32
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