Skip to content

Card Rat: ignore a late slap after a missed trigger - #230

Merged
acrosman merged 1 commit into
mainfrom
fix/197-card-rat-late-slap
Oct 4, 2026
Merged

acrosman merged 1 commit into
mainfrom
fix/197-card-rat-late-slap

Conversation

@acrosman

@acrosman acrosman commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Fixes #197

Problem

A slap that came just after a trigger card left the screen counted twice. The trigger was scored as a miss when the next card was dealt, and then the slap counted as a false alarm on that next card. Both are wrong outcomes, so one late reaction also pushed the speed staircase two steps toward slowing down.

Change

game.js now sets lateSlapPending when a card is dealt right after a missed trigger. In respondToCurrentCard():

  • If the current card is not a trigger, the first slap returns 'ignored'. It changes no counts and no staircase state, and the UI shows no feedback and plays no sound. The miss sound already played when the card was dealt.
  • Further slaps on that same card are false alarms as before. This keeps one late reaction from covering repeated slapping.
  • If the current card is a trigger (a pair, sandwich, or joker right after the missed one), the slap is a hit as before.
  • The flag clears on the next deal and in initGame().

index.js and the tutorial need no changes. 'ignored' already shows nothing, and in practice rounds the card to slap stays up until it is slapped, so a slap there can't be late. The issue's "sandwich (when enabled)" needs nothing extra, because sandwiches are always on today.

Tests

  • New game.test.js cases:
    • a late slap is ignored, and misses, false alarms, and the wrong streak each stay at 1, 0, and 1;
    • a second late slap is a false alarm;
    • a slap two cards after the miss is a false alarm;
    • a slap on the card after a hit trigger is still a false alarm;
    • a slap on a trigger dealt right after a missed trigger is a hit.
  • The existing "false alarm resets the speed-up streak" test only passed because it skipped a trigger on the way to its non-trigger card. The miss had already reset the streak, and the slap it expected to be a false alarm is now a late slap. It now uses a deck with spread-out triggers, so the false alarm alone resets the streak, and it asserts misses === 0 and consecutiveWrong === 1.
  • npm run lint is clean. npm run test:coverage passes: 2117 tests, all thresholds met, 100% function coverage.

Checked in the running app

I drove the app with Playwright, using an isolated --user-data-dir. Each check waited for a trigger to pass, then pressed Space on the non-trigger card that followed:

Scenario main This branch
One late slap misses 1, false alarms 1, "Too soon" message misses 1, false alarms 0, no message
Two late slaps — misses 2, false alarms 1 (the second slap)
Slap on an ordinary non-trigger card false alarm false alarm

Signed: Claude Code (Claude Opus 5.5) for Aaron Crosman

🤖 Generated with Claude Code

A slap that came just after a trigger card left the screen counted twice:
once as a miss for the trigger, then again as a false alarm on the next
card. Now, when the previous card was a missed trigger and the current
card is not one to slap, the first slap is ignored. Later slaps on that
card are still false alarms, and a slap on a card that is itself a
trigger is still a hit.

The false-alarm streak test only passed because it skipped a trigger
before slapping, so the miss had already reset the streak. It now uses a
deck whose triggers are spread out, so the false alarm alone resets it.

Fixes #197

Signed: Claude Code (Claude Opus 5.5) for Aaron Crosman

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acrosman
acrosman merged commit 364f2ae into main Oct 4, 2026
7 checks passed
@acrosman
acrosman deleted the fix/197-card-rat-late-slap branch October 4, 2026 01:00
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.

Card Rat: Double punishment for late responses

1 participant