Play pair sound before element check and add pair detection debug log

Sound was gated behind element check which may fail during swap
animation when card DOM elements are replaced by overlays.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken 2026-02-22 16:41:17 -05:00
parent a76fd8da32
commit 1fa13bbe3b

View File

@ -2592,6 +2592,7 @@ 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);
@ -2607,10 +2608,10 @@ class GolfGame {
} }
firePairCelebration(playerId, pos1, pos2) { firePairCelebration(playerId, pos1, pos2) {
this.playSound('pair');
const elements = this.getCardElements(playerId, pos1, pos2); const elements = this.getCardElements(playerId, pos1, pos2);
if (elements.length < 2) return; if (elements.length < 2) return;
this.playSound('pair');
if (window.cardAnimations) { if (window.cardAnimations) {
window.cardAnimations.celebratePair(elements[0], elements[1]); window.cardAnimations.celebratePair(elements[0], elements[1]);
} }