Skip to content

fix(sockets): play four discard reveal on caster instead of victim (#1440) - #1442

Merged
itsalaidbacklife merged 3 commits into
cuttle-cards:mainfrom
rajpreetcodes:fix/four-resolve-caster-reveal
Oct 18, 2026
Merged

itsalaidbacklife merged 3 commits into
cuttle-cards:mainfrom
rajpreetcodes:fix/four-resolve-caster-reveal

Conversation

@rajpreetcodes

Copy link
Copy Markdown
Contributor

Issue number

Please check the following

  • Do the tests still pass? (see Run the Tests)
  • Is the code formatted properly? (see Linting (Formatting))
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

Root Cause & Fix

On MoveType.RESOLVE socket events, api/helpers/game-states/create-socket-events.js flips playedBy to the caster. In src/plugins/sockets/inGameEvents.js, the check for rank 4 was checking evData.playedBy !== gameStore.myPNum, which caused processFours to execute on the victim client (splicing discarded cards into opponent hand on their screen) while the caster bypassed the animation.

Inverted the check so processFours runs when evData.playedBy === gameStore.myPNum (the caster) to reveal discarded cards from the opponent hand, while the victim directly runs gameStore.updateGame(evData.game).

Test Coverage

Added unit tests in tests/unit/specs/in-game-events.spec.js asserting that:

  1. processFours is invoked with the discarded cards when the local player is the caster (playedBy === myPNum).
  2. updateGame is invoked directly without processFours when the local player is the victim (playedBy !== myPNum).

All unit tests and linting pass cleanly.

…uttle-cards#1440)

The server-side create-socket-events helper flips playedBy to the caster on MoveType.RESOLVE events. In inGameEvents, the case 4 check previously checked evData.playedBy !== gameStore.myPNum, causing processFours to run on the victim's client (splicing the discarded cards into the opponent's hand on their screen) while the caster skipped the reveal entirely.

Invert the check so processFours runs when playedBy === gameStore.myPNum (the caster) to display the discarded cards from the opponent's hand, while the victim updates the game state directly.
@Haviles04 Haviles04 added version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1) frontend Requires changes to the frontend (vue) client labels Oct 16, 2026
@itsalaidbacklife itsalaidbacklife added the bug Something isn't working label Oct 18, 2026

@itsalaidbacklife itsalaidbacklife left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix; thank you! There's one extraneous line of setup code in the tests. I'll commit the change myself so I can wrap this up without an additional review cycle

Comment thread tests/unit/specs/in-game-events.spec.js Outdated
@itsalaidbacklife
itsalaidbacklife merged commit de05072 into cuttle-cards:main Oct 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend Requires changes to the frontend (vue) client version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Four one-off: discarded cards flash in the caster's hand on the victim's screen

3 participants