From 27c13a57d4a8837cc539d5368d5a1fe5e492d19b Mon Sep 17 00:00:00 2001 From: Brian Fertig Date: Tue, 19 May 2026 18:07:03 -0600 Subject: [PATCH] Animation improvements --- public/src/games/gofish/GoFishGame.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/public/src/games/gofish/GoFishGame.js b/public/src/games/gofish/GoFishGame.js index d7e7bb8..12f10c7 100644 --- a/public/src/games/gofish/GoFishGame.js +++ b/public/src/games/gofish/GoFishGame.js @@ -713,19 +713,26 @@ export default class GoFishGame extends Phaser.Scene { const askerCard = beforeState.players[askerSeat].hand.find(c => c.rank === rank); if (!askerCard) { onComplete(); return; } - const askerSprite = this.makeCardSprite(askerCard, askerLayout.handCenter.x, askerLayout.handCenter.y, { - faceUp: false, rotation: 0, - }); + const existingSprite = this.cardObjs.get(`hand-${askerSeat}-${askerCard.id}`); + const askerSprite = existingSprite + ?? this.makeCardSprite(askerCard, askerLayout.handCenter.x, askerLayout.handCenter.y, { + faceUp: askerLayout.handFaceUp, rotation: 0, + }); + if (existingSprite) this.cardObjs.delete(`hand-${askerSeat}-${askerCard.id}`); + const origX = askerSprite.x; + const origY = askerSprite.y; askerSprite.setDepth(D.banner - 4); this.transientObjs.push(askerSprite); - // Move asker card to show zone then flip it face-up. + // Move asker card to show zone then flip it face-up (skip flip if already face-up). this.tweens.add({ targets: askerSprite, x: askerShow.x, y: askerShow.y, duration: 280, ease: 'Cubic.easeOut', - onComplete: () => this.flipCardFaceUp(askerSprite, askerCard), + onComplete: () => { + if (!askerLayout.handFaceUp) this.flipCardFaceUp(askerSprite, askerCard); + }, }); // After card is revealed, cast fishing line toward the target, then show result. @@ -782,12 +789,13 @@ export default class GoFishGame extends Phaser.Scene { this.time.delayedCall(320, () => onComplete(allSprites)); }); } else { - // Fish — flip card back face-down and return it to hand. - this.flipCardFaceDown(askerSprite); - this.time.delayedCall(340, () => { + // Fish — flip card back face-down (if needed) and return it to hand. + if (!askerLayout.handFaceUp) this.flipCardFaceDown(askerSprite); + const returnDelay = askerLayout.handFaceUp ? 80 : 340; + this.time.delayedCall(returnDelay, () => { this.tweens.add({ targets: askerSprite, - x: askerLayout.handCenter.x, y: askerLayout.handCenter.y, + x: origX, y: origY, duration: 280, ease: 'Cubic.easeIn', onComplete: () => { if (askerSprite.active) askerSprite.destroy(); }, });