Compare commits

..

No commits in common. "cc75ff18628f3488075ecc44dfb89883e5d450b9" and "975ee6ea25f0b43f4a92f09abd42a8efe94ace65" have entirely different histories.

1 changed files with 20 additions and 43 deletions

View File

@ -713,26 +713,19 @@ export default class GoFishGame extends Phaser.Scene {
const askerCard = beforeState.players[askerSeat].hand.find(c => c.rank === rank);
if (!askerCard) { onComplete(); return; }
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;
const askerSprite = this.makeCardSprite(askerCard, askerLayout.handCenter.x, askerLayout.handCenter.y, {
faceUp: false, rotation: 0,
});
askerSprite.setDepth(D.banner - 4);
this.transientObjs.push(askerSprite);
// Move asker card to show zone then flip it face-up (skip flip if already face-up).
// Move asker card to show zone then flip it face-up.
this.tweens.add({
targets: askerSprite,
x: askerShow.x, y: askerShow.y,
duration: 280,
ease: 'Cubic.easeOut',
onComplete: () => {
if (!askerLayout.handFaceUp) this.flipCardFaceUp(askerSprite, askerCard);
},
onComplete: () => this.flipCardFaceUp(askerSprite, askerCard),
});
// After card is revealed, cast fishing line toward the target, then show result.
@ -746,12 +739,9 @@ export default class GoFishGame extends Phaser.Scene {
: targetShow.x + (i - (n - 1) / 2) * (CARD_W + 8);
const ty = isTargetVert ? targetShow.y + (i - (n - 1) / 2) * (CARD_H + 8)
: targetShow.y;
const existingTargetSprite = this.cardObjs.get(`hand-${targetSeat}-${card.id}`);
const sprite = existingTargetSprite
?? this.makeCardSprite(card, targetLayout.handCenter.x, targetLayout.handCenter.y, {
faceUp: targetLayout.handFaceUp, rotation: 0,
});
if (existingTargetSprite) this.cardObjs.delete(`hand-${targetSeat}-${card.id}`);
const sprite = this.makeCardSprite(card, targetLayout.handCenter.x, targetLayout.handCenter.y, {
faceUp: false, rotation: 0,
});
sprite.setDepth(D.banner - 4);
this.transientObjs.push(sprite);
this.tweens.add({
@ -760,9 +750,7 @@ export default class GoFishGame extends Phaser.Scene {
duration: 250,
delay: i * 80,
ease: 'Cubic.easeOut',
onComplete: () => {
if (!targetLayout.handFaceUp) this.flipCardFaceUp(sprite, card);
},
onComplete: () => this.flipCardFaceUp(sprite, card),
});
return { sprite, tx, ty };
});
@ -794,13 +782,12 @@ export default class GoFishGame extends Phaser.Scene {
this.time.delayedCall(320, () => onComplete(allSprites));
});
} else {
// 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, () => {
// Fish — flip card back face-down and return it to hand.
this.flipCardFaceDown(askerSprite);
this.time.delayedCall(340, () => {
this.tweens.add({
targets: askerSprite,
x: origX, y: origY,
x: askerLayout.handCenter.x, y: askerLayout.handCenter.y,
duration: 280, ease: 'Cubic.easeIn',
onComplete: () => { if (askerSprite.active) askerSprite.destroy(); },
});
@ -1024,37 +1011,27 @@ export default class GoFishGame extends Phaser.Scene {
if (sprite) {
const revealCard = askerSeat === 0 ? after.lastAsk.drawnCard : null;
const drawnCard = after.lastAsk.drawnCard;
const newHand = after.players[askerSeat].hand;
const cardIndex = newHand.findIndex(c => c.id === drawnCard.id);
const askerLayout = slotLayout(this.slotForSeat[askerSeat]);
let destX, destY;
if (askerLayout.handAxis === 'x') {
destX = askerLayout.handCenter.x + (cardIndex - (newHand.length - 1) / 2) * HAND_SPREAD;
destY = askerLayout.handCenter.y;
} else {
destX = askerLayout.handCenter.x;
destY = askerLayout.handCenter.y + (cardIndex - (newHand.length - 1) / 2) * HAND_SPREAD;
}
this.animateFishDraw(sprite, revealCard, destX, destY, continueAfterDraw);
this.animateFishDraw(sprite, askerSeat, revealCard, continueAfterDraw);
} else {
this.time.delayedCall(50, continueAfterDraw);
}
}
animateFishDraw(sprite, revealCard, destX, destY, onComplete) {
animateFishDraw(sprite, askerSeat, revealCard, onComplete) {
const layout = slotLayout(this.slotForSeat[askerSeat]);
sprite.setDepth(D.banner - 4);
this.transientObjs.push(sprite);
const flyToHand = () => {
this.tweens.add({
targets: sprite,
x: destX, y: destY,
x: layout.handCenter.x, y: layout.handCenter.y,
rotation: 0,
alpha: 0,
duration: 400,
ease: 'Cubic.easeIn',
onComplete: () => onComplete(),
onComplete: () => { if (sprite.active) sprite.destroy(); },
});
this.time.delayedCall(450, onComplete);
};
if (revealCard) {