Fix pair chime not playing for local player's own swaps

The swap animation defers state updates to pendingGameState, which
bypassed checkForNewPairs entirely. Now pair detection runs when the
deferred state is applied after the swap animation completes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken 2026-02-22 16:47:43 -05:00
parent 2dcdaf2b49
commit 21362ba125

View File

@ -1573,8 +1573,10 @@ class GolfGame {
this.heldCardFloating.classList.add('hidden'); this.heldCardFloating.classList.add('hidden');
if (this.pendingGameState) { if (this.pendingGameState) {
const oldState = this.gameState;
this.gameState = this.pendingGameState; this.gameState = this.pendingGameState;
this.pendingGameState = null; this.pendingGameState = null;
this.checkForNewPairs(oldState, this.gameState);
this.renderGame(); this.renderGame();
} }
} }
@ -2592,7 +2594,6 @@ class GolfGame {
if (!wasPaired && nowPaired) { if (!wasPaired && nowPaired) {
// New pair formed! // New pair formed!
console.log('[PAIR] New pair detected for', newPlayer.name, 'col', top, bottom, 'isLocal:', newPlayer.id === this.playerId);
setTimeout(() => { setTimeout(() => {
this.firePairCelebration(newPlayer.id, top, bottom); this.firePairCelebration(newPlayer.id, top, bottom);
}, window.TIMING?.celebration?.pairDelay || 50); }, window.TIMING?.celebration?.pairDelay || 50);