Compare commits

...

3 Commits

Author SHA1 Message Date
Brian Fertig 2521146579 feat: replace route cars with animated train car sprites and card animations
- Generate a `ttr-train-car` texture and use images instead of procedural drawing for owned routes.
- Add `animateClaimRoute` to animate cards flying from hand to a lineup, transforming into train cars, then placing on the route.
- Update human and AI route claim flows to use the new animation.
- Add a pulsing turn indicator triangle that moves to the current player's portrait.
- Track `trainCarObjs` for proper cleanup during route re-renders.
2026-05-30 13:41:14 -06:00
Brian Fertig 97befdb502 feat: add market card sliding and refill animations to Ticket to Ride
- Implement `animateMarketSlideUp` to slide remaining cards up when one is drawn.
- Add `animateRefillMarketSlot` to animate a new card appearing from the deck.
- Update human and AI draw handlers to orchestrate card draw, slide, and refill animations.
- Introduce `marketSlotObjs` to track UI objects per slot for targeted tweens.
- Create `renderAllExceptMarket` to render the rest of the game while market animations play.
- Refactor `renderMarket` to group objects by slot index.
2026-05-30 13:17:49 -06:00
Brian Fertig ae6c69e25c feat: add opponent hand visualization and update AI draw animations
- Introduce mini face-down card fans below opponent portraits to show hand size.
- Modify AI draw animations to target specific slots within the mini hand fan.
- Adjust layout constants (OPP_STEP) and text positions to accommodate the new UI.
- Simplify opponent info text to remove redundant card counts.
2026-05-30 12:52:41 -06:00
1 changed files with 311 additions and 25 deletions

View File

@ -28,8 +28,9 @@ const TTR_CARD_FRAME = {
// Right-band + bottom-strip layout (1920×1080). The map occupies x<1400.
const RB = { x0: 1408, cx: 1660, w: 512 };
const OPP_COL1_X = 1450, OPP_COL2_X = 1706, OPP_Y0 = 150, OPP_STEP = 100, OPP_R = 32;
const OPP_COL1_X = 1450, OPP_COL2_X = 1706, OPP_Y0 = 150, OPP_STEP = 150, OPP_R = 32;
const MK_X = 1476, MK_Y0 = 507, MK_STEP = 104, CARD_W = 78, CARD_H = 112;
const MINI_W = 22, MINI_H = 32, MINI_STEP = 14;
const PILE_X = 1646;
const BOT_Y = 980;
@ -51,11 +52,16 @@ export default class TicketToRideGame extends Phaser.Scene {
this.playerScoreText = null;
this.scoreBadgeContainers = [];
this.oppScoreTexts = {};
this.oppMiniHandGfx = [];
this.oppMiniHandCount = [];
this.marketSlotObjs = [];
this.trainCarObjs = [];
}
create() {
try { new MusicPlayer(this, this.cache.json.get('music')?.tracks ?? []); } catch (_) { /* no music json */ }
this.buildParticleTexture();
this.buildTrainCarTexture();
this.buildBackdrop();
this.buildStaticBoard();
this.buildRightPanel();
@ -70,6 +76,22 @@ export default class TicketToRideGame extends Phaser.Scene {
g.destroy();
}
buildTrainCarTexture() {
const g = this.make.graphics({ x: 0, y: 0, add: false });
g.fillStyle(0xffffff, 1); g.fillRoundedRect(1, 3, 118, 34, 4); // body
g.fillStyle(0xdddddd, 1); g.fillRect(5, 3, 110, 9); // roof
g.fillStyle(0x181818, 1); g.fillRect(14, 14, 92, 12); // window glass
g.fillStyle(0xdddddd, 1); g.fillRect(42, 14, 4, 12); // mullion 1
g.fillRect(74, 14, 4, 12); // mullion 2
g.fillStyle(0xaaaaaa, 1); g.fillRoundedRect(10, 30, 22, 9, 2); // left truck
g.fillRoundedRect(88, 30, 22, 9, 2); // right truck
g.fillStyle(0x999999, 1); g.fillRect(30, 29, 60, 4); // underframe
g.fillStyle(0xeeeeee, 1); g.fillRect(1, 13, 3, 14); // left end cap
g.fillRect(116, 13, 3, 14); // right end cap
g.generateTexture('ttr-train-car', 120, 40);
g.destroy();
}
// ── backdrop: sea + land silhouette ─────────────────────────────────────────
buildBackdrop() {
if (this.playfield?.key && this.textures.exists(this.playfield.key)) {
@ -196,6 +218,10 @@ export default class TicketToRideGame extends Phaser.Scene {
this.scoreBadgeContainers.forEach((c) => c.destroy());
this.scoreBadgeContainers = [];
this.oppScoreTexts = {};
this.oppMiniHandGfx.forEach((g) => g?.destroy());
this.oppMiniHandGfx = [];
this.oppMiniHandCount.forEach((t) => t?.destroy());
this.oppMiniHandCount = [];
// Player score badge (above human portrait in the bottom HUD)
const pb = this._makeScoreBadge(80, BOT_Y - 64, this.playerColor(0).hex, 16);
@ -209,10 +235,10 @@ export default class TicketToRideGame extends Phaser.Scene {
this.opponentPortraits.push(portrait);
const col = PLAYER_COLORS[this.gs.players[seat].colorIndex];
this.add.circle(x, y, OPP_R + 4, col.hex, 0).setStrokeStyle(3, col.hex, 0.95).setDepth(D.hud + 2);
this.add.text(x + OPP_R + 12, y - 18, this.pname(seat), {
this.add.text(x + OPP_R + 12, y - 10, this.pname(seat), {
fontFamily: 'Righteous', fontSize: '15px', color: COLORS.textHex,
}).setOrigin(0, 0.5).setDepth(D.hud + 1);
const info = this.add.text(x + OPP_R + 12, y + 6, '', {
const info = this.add.text(x + OPP_R + 12, y + 10, '', {
fontFamily: '"Julius Sans One"', fontSize: '12px', color: COLORS.mutedHex, lineSpacing: 2,
}).setOrigin(0, 0.5).setDepth(D.hud + 1);
this.oppPanelText[seat] = info;
@ -221,6 +247,16 @@ export default class TicketToRideGame extends Phaser.Scene {
const ob = this._makeScoreBadge(x, y - OPP_R - 14, col.hex, 13);
this.oppScoreTexts[seat] = ob.text;
this.scoreBadgeContainers.push(ob.container);
// Mini face-down hand fan below portrait
const fanX = x - OPP_R;
const fanY = y + OPP_R + 20;
const miniGfx = this.add.graphics().setDepth(D.hud + 1);
this.oppMiniHandGfx[seat] = miniGfx;
const miniCount = this.add.text(fanX + 86, fanY, '×0', {
fontFamily: 'Righteous', fontSize: '13px', color: COLORS.mutedHex,
}).setOrigin(0, 0.5).setDepth(D.hud + 2);
this.oppMiniHandCount[seat] = miniCount;
}
}
@ -275,6 +311,8 @@ export default class TicketToRideGame extends Phaser.Scene {
new Button(this, 80, 40, 'Leave', () => this.scene.start('GameMenu'),
{ variant: 'ghost', width: 120, height: 40, fontSize: 17 }).setDepth(D.banner);
this._buildTurnTriangle();
}
// ── helpers ───────────────────────────────────────────────────────────────────
@ -339,16 +377,24 @@ export default class TicketToRideGame extends Phaser.Scene {
const srcX = MK_X;
const srcY = MK_Y0 + i * (CARD_W + 10);
const color = this.gs.faceUp[i];
const origFaceUpLength = this.gs.faceUp.length;
const newGs = L.drawTrainCard(this.gs, 0, 'faceUp', i);
const refillHappened = newGs.faceUp.length === origFaceUpLength;
const refillSlot = origFaceUpLength - 1;
const refillColor = refillHappened ? newGs.faceUp[refillSlot] : undefined;
this.busy = true;
this.gs = newGs;
this.renderAll();
this.marketSlotObjs[i]?.forEach((o) => o.setVisible(false));
this.renderAllExceptMarket();
playSound(this, SFX.CARD_DEAL);
const dest = this.handDestForColor(color);
await this.animateCardDraw({
srcX, srcY, srcAngle: -90, cardFrame: TTR_CARD_FRAME[color],
shouldFlip: false, destX: dest.x, destY: dest.y, destW: 97, destH: 140,
});
await this.animateMarketSlideUp(i, origFaceUpLength - 1);
if (refillColor !== undefined) await this.animateRefillMarketSlot(refillSlot, refillColor);
this.renderAll();
this.busy = false;
this.advance();
}
@ -387,13 +433,23 @@ export default class TicketToRideGame extends Phaser.Scene {
this.renderHover();
}
onRouteClick(id) {
async onRouteClick(id) {
if (!this.canHumanAct()) return;
if (this.gs.drawnThisTurn > 0) { this.flash('You are drawing cards this turn'); return; }
if (!L.routeClaimable(this.gs, 0, id)) { this.flash('That route is not available'); return; }
const opts = L.paymentOptions(this.gs.players[0], ROUTES[id]);
if (opts.length === 0) { this.flash('Not enough matching cards'); return; }
if (opts.length === 1) { this.applyHuman(L.claimRoute(this.gs, 0, id, opts[0]), SFX.CARD_PLACE); return; }
if (opts.length === 1) {
const payment = opts[0];
const newGs = L.claimRoute(this.gs, 0, id, payment);
this.busy = true;
await this.animateClaimRoute(0, id, payment);
this.gs = newGs;
playSound(this, SFX.CARD_PLACE);
this.busy = false;
this.advance();
return;
}
this.promptClaimPayment(id, opts);
}
@ -406,7 +462,9 @@ export default class TicketToRideGame extends Phaser.Scene {
const a = AI.chooseAction(this.gs, seat);
if (a.type === 'claimRoute') {
this.gs = L.claimRoute(this.gs, seat, a.routeId, a.payment);
const newGs = L.claimRoute(this.gs, seat, a.routeId, a.payment);
await this.animateClaimRoute(seat, a.routeId, a.payment);
this.gs = newGs;
playSound(this, SFX.CARD_PLACE);
this.opponentPortraits[seat - 1]?.playEmotion?.('happy');
} else if (a.type === 'drawTickets') {
@ -414,34 +472,62 @@ export default class TicketToRideGame extends Phaser.Scene {
// pendingTickets now set for this AI seat — advance() routes to aiResolveTickets.
} else { // drawTrain
const { x: dX, y: dY } = this.oppPos(seat);
const fanX = dX - OPP_R;
const fanY = dY + OPP_R + 20;
// First draw
const faceUpColor1 = a.source === 'faceUp' ? this.gs.faceUp[a.index] : null;
const srcX1 = a.source === 'faceUp' ? MK_X : PILE_X;
const srcY1 = a.source === 'faceUp' ? MK_Y0 + a.index * (CARD_W + 10) : MK_Y0;
const firstFaceUp = a.source === 'faceUp';
const faceUpColor1 = firstFaceUp ? this.gs.faceUp[a.index] : null;
const srcX1 = firstFaceUp ? MK_X : PILE_X;
const srcY1 = firstFaceUp ? MK_Y0 + a.index * (CARD_W + 10) : MK_Y0;
const origFaceUpLen1 = firstFaceUp ? this.gs.faceUp.length : 0;
if (firstFaceUp) this.marketSlotObjs[a.index]?.forEach((o) => o.setVisible(false));
this.gs = L.drawTrainCard(this.gs, seat, a.source, a.index);
const slot1 = Math.min(L.handCount(this.gs.players[seat]) - 1, 4);
const refillHappened1 = firstFaceUp && this.gs.faceUp.length === origFaceUpLen1;
const refillColor1 = refillHappened1 ? this.gs.faceUp[origFaceUpLen1 - 1] : undefined;
playSound(this, SFX.CARD_DEAL);
this.renderAll();
if (firstFaceUp) this.renderAllExceptMarket(); else this.renderAll();
await this.animateCardDraw({
srcX: srcX1, srcY: srcY1, srcAngle: -90,
cardFrame: faceUpColor1 ? TTR_CARD_FRAME[faceUpColor1] : TTR_CARD_FRAME.back,
shouldFlip: false, destX: dX, destY: dY, destW: 44, destH: 64,
shouldFlip: false,
destX: fanX + slot1 * MINI_STEP + MINI_W / 2, destY: fanY,
destW: MINI_W, destH: MINI_H,
});
if (firstFaceUp) {
await this.animateMarketSlideUp(a.index, origFaceUpLen1 - 1);
if (refillColor1 !== undefined) await this.animateRefillMarketSlot(origFaceUpLen1 - 1, refillColor1);
this.renderAll();
}
// Second draw if the turn is still in progress.
if ((this.gs.phase === 'turn' || this.gs.phase === 'lastRound')
&& this.gs.currentPlayer === seat && this.gs.drawnThisTurn === 1 && !this.gs.pendingTickets) {
await this.delay(150);
const b = AI.chooseSecondDraw(this.gs, seat);
const faceUpColor2 = b.source === 'faceUp' ? this.gs.faceUp[b.index] : null;
const srcX2 = b.source === 'faceUp' ? MK_X : PILE_X;
const srcY2 = b.source === 'faceUp' ? MK_Y0 + b.index * (CARD_W + 10) : MK_Y0;
const secondFaceUp = b.source === 'faceUp';
const faceUpColor2 = secondFaceUp ? this.gs.faceUp[b.index] : null;
const srcX2 = secondFaceUp ? MK_X : PILE_X;
const srcY2 = secondFaceUp ? MK_Y0 + b.index * (CARD_W + 10) : MK_Y0;
const origFaceUpLen2 = secondFaceUp ? this.gs.faceUp.length : 0;
if (secondFaceUp) this.marketSlotObjs[b.index]?.forEach((o) => o.setVisible(false));
this.gs = L.drawTrainCard(this.gs, seat, b.source, b.index);
const slot2 = Math.min(L.handCount(this.gs.players[seat]) - 1, 4);
const refillHappened2 = secondFaceUp && this.gs.faceUp.length === origFaceUpLen2;
const refillColor2 = refillHappened2 ? this.gs.faceUp[origFaceUpLen2 - 1] : undefined;
playSound(this, SFX.CARD_DEAL);
this.renderAll();
if (secondFaceUp) this.renderAllExceptMarket(); else this.renderAll();
await this.animateCardDraw({
srcX: srcX2, srcY: srcY2, srcAngle: -90,
cardFrame: faceUpColor2 ? TTR_CARD_FRAME[faceUpColor2] : TTR_CARD_FRAME.back,
shouldFlip: false, destX: dX, destY: dY, destW: 44, destH: 64,
shouldFlip: false,
destX: fanX + slot2 * MINI_STEP + MINI_W / 2, destY: fanY,
destW: MINI_W, destH: MINI_H,
});
if (secondFaceUp) {
await this.animateMarketSlideUp(b.index, origFaceUpLen2 - 1);
if (refillColor2 !== undefined) await this.animateRefillMarketSlot(origFaceUpLen2 - 1, refillColor2);
this.renderAll();
}
}
}
@ -474,6 +560,8 @@ export default class TicketToRideGame extends Phaser.Scene {
}
renderRoutes() {
this.trainCarObjs.forEach((o) => o.destroy());
this.trainCarObjs = [];
const g = this.routeGfx;
g.clear();
ROUTES.forEach((r, id) => {
@ -481,7 +569,14 @@ export default class TicketToRideGame extends Phaser.Scene {
const segs = this.segCache[id];
if (owner != null) {
const col = this.playerColor(owner);
for (const seg of segs) this.drawCar(g, seg, col.hex, col.hexDark, 0xffffff);
for (const seg of segs) {
const img = this.add.image(seg.cx, seg.cy, 'ttr-train-car')
.setDisplaySize(seg.w, seg.h)
.setRotation(seg.angle)
.setTint(col.hex)
.setDepth(D.train);
this.trainCarObjs.push(img);
}
} else {
const fill = CARD_COLOR_HEX[r.color] ?? CARD_COLOR_HEX.gray;
for (const seg of segs) this.drawCar(g, seg, fill, 0x2a2118, null);
@ -514,6 +609,7 @@ export default class TicketToRideGame extends Phaser.Scene {
renderMarket() {
this.marketObjs.forEach((o) => o.destroy());
this.marketObjs = [];
this.marketSlotObjs = [];
const myTurn = this.canHumanAct();
const mkStep = CARD_W + 10; // rotated visual height + padding
for (let i = 0; i < 5; i++) {
@ -523,16 +619,17 @@ export default class TicketToRideGame extends Phaser.Scene {
const g = this.add.graphics().setDepth(D.market);
g.lineStyle(2, COLORS.mutedHex, 0.5);
g.strokeRoundedRect(MK_X - CARD_H / 2, y - CARD_W / 2, CARD_H, CARD_W, 8);
this.marketSlotObjs[i] = [g];
this.marketObjs.push(g);
continue;
}
const objs = this.makeCardFace(MK_X, y, CARD_W, CARD_H, color, D.market, '');
objs.forEach((o) => o.setAngle(-90));
this.marketObjs.push(...objs);
const z = this.add.zone(MK_X, y, CARD_H, CARD_W).setDepth(D.market + 2);
if (myTurn) z.setInteractive({ useHandCursor: true });
z.on('pointerdown', () => this.onMarketClick(i));
this.marketObjs.push(z);
this.marketSlotObjs[i] = [...objs, z];
this.marketObjs.push(...objs, z);
}
}
@ -576,7 +673,7 @@ export default class TicketToRideGame extends Phaser.Scene {
const p = this.gs.players[seat];
const info = this.oppPanelText[seat];
if (info) {
info.setText(`Trains ${p.trainsLeft} Cards ${L.handCount(p)}\nTickets ${p.tickets.length}`);
info.setText(`Trains ${p.trainsLeft}\nTickets ${p.tickets.length}`);
}
this.oppScoreTexts[seat]?.setText(String(L.publicScore(this.gs, seat)));
if (this.gs.currentPlayer === seat) {
@ -584,6 +681,26 @@ export default class TicketToRideGame extends Phaser.Scene {
this.oppRingGfx.lineStyle(4, COLORS.goldHex, 1);
this.oppRingGfx.strokeCircle(x, y, OPP_R + 8);
}
// Mini hand fan
const gfx = this.oppMiniHandGfx[seat];
if (gfx) {
const { x, y } = this.oppPos(seat);
const fanX = x - OPP_R;
const fanY = y + OPP_R + 20;
gfx.clear();
const count = L.handCount(p);
const n = Math.min(count, 5);
for (let c = 0; c < n; c++) {
const cx = fanX + c * MINI_STEP;
gfx.fillStyle(0x1a2750, 1);
gfx.fillRoundedRect(cx, fanY - MINI_H / 2, MINI_W, MINI_H, 3);
gfx.lineStyle(1.5, 0x8aaad4, 0.9);
gfx.strokeRoundedRect(cx, fanY - MINI_H / 2, MINI_W, MINI_H, 3);
gfx.lineStyle(1, 0xfdf3d8, 0.12);
gfx.strokeRoundedRect(cx + 2, fanY - MINI_H / 2 + 2, MINI_W - 4, MINI_H - 4, 2);
}
this.oppMiniHandCount[seat]?.setText(`×${count}`);
}
}
}
@ -601,6 +718,45 @@ export default class TicketToRideGame extends Phaser.Scene {
}
this.statusText.setText(msg);
this.logText.setText(s.log[s.log.length - 1] ?? '');
this._updateTurnIndicator();
}
_buildTurnTriangle() {
const g = this.add.graphics().setDepth(D.hud + 8);
g.fillStyle(0xffdd00, 1);
g.fillTriangle(-10, -13, -10, 13, 10, 0);
g.setPosition(-9999, -9999);
this.turnIndicator = g;
this._turnSeat = null;
this.tweens.add({
targets: g, scaleX: 1.4, scaleY: 1.4,
duration: 700, yoyo: true, repeat: -1, ease: 'Sine.InOut',
});
}
_seatPortraitPos(seat) {
if (seat === 0) return { x: 80, y: BOT_Y, r: 46 };
const { x, y } = this.oppPos(seat);
return { x, y, r: OPP_R };
}
_updateTurnIndicator() {
const seat = this.gs?.currentPlayer;
if (seat == null || !this.turnIndicator) return;
const pos = this._seatPortraitPos(seat);
if (!pos) return;
const tx = pos.x - pos.r - 20;
const ty = pos.y;
if (this._turnSeat === seat) return;
this._turnSeat = seat;
if (this.turnIndicator.x < 0) {
this.turnIndicator.setPosition(tx, ty);
} else {
this.tweens.add({
targets: this.turnIndicator, x: tx, y: ty,
duration: 600, ease: 'Cubic.Out',
});
}
}
flash(message) {
@ -712,11 +868,19 @@ export default class TicketToRideGame extends Phaser.Scene {
}).setOrigin(0.5).setDepth(D.modal + 2);
this.modalObjs.push(overlay, panel, title);
const finish = (payment) => {
const finish = async (payment) => {
this.closeModal();
this.busy = false;
if (payment) this.applyHuman(L.claimRoute(this.gs, 0, routeId, payment), SFX.CARD_PLACE);
else this.advance();
if (payment) {
const newGs = L.claimRoute(this.gs, 0, routeId, payment);
await this.animateClaimRoute(0, routeId, payment);
this.gs = newGs;
playSound(this, SFX.CARD_PLACE);
this.busy = false;
this.advance();
} else {
this.busy = false;
this.advance();
}
};
options.forEach((opt, i) => {
@ -837,11 +1001,133 @@ export default class TicketToRideGame extends Phaser.Scene {
delay(ms) { return new Promise((res) => this.time.delayedCall(ms, res)); }
renderAllExceptMarket() {
if (!this.gs) return;
this.renderRoutes();
this.renderHover();
this.renderHand();
this.renderPiles();
this.renderPanels();
this.renderStatus();
}
handDestForColor(colorKey) {
const i = HAND_ORDER.indexOf(colorKey);
return { x: 400 + i * 105, y: 1000 };
}
async animateClaimRoute(seat, routeId, payment) {
const ANIM_DEPTH = D.banner + 10;
const CX = GAME_WIDTH / 2, CY = GAME_HEIGHT / 2;
const GAP = 20;
const segs = this.segCache[routeId];
const playerCol = this.playerColor(seat);
const cards = [];
for (let c = 0; c < (payment.colorCount ?? 0); c++) cards.push(payment.color);
for (let c = 0; c < (payment.locos ?? 0); c++) cards.push('locomotive');
const N = cards.length;
const totalW = N * 270 + (N - 1) * GAP;
const lineupStartX = CX - totalW / 2 + 135;
const srcForColor = (colorKey) => {
if (seat === 0) return this.handDestForColor(colorKey);
const { x, y } = this.oppPos(seat);
return { x: x - OPP_R + 39, y: y + OPP_R + 20 };
};
// Phase 1: cards fly to lineup one at a time
const cardObjs = [];
for (let i = 0; i < N; i++) {
const colorKey = cards[i];
const src = srcForColor(colorKey);
const img = this.add.image(src.x, src.y, 'ttr-cards', TTR_CARD_FRAME[colorKey] ?? TTR_CARD_FRAME.back)
.setDisplaySize(270, 390)
.setDepth(ANIM_DEPTH + i);
cardObjs.push(img);
await new Promise((res) => this.tweens.add({
targets: img,
x: lineupStartX + i * (270 + GAP), y: CY,
duration: 400, ease: 'Cubic.easeOut', onComplete: res,
}));
}
// Phase 2: hold
await this.delay(500);
// Phase 3: transform all cards to train cars simultaneously
await Promise.all(cardObjs.map((img) => this._transformToTrainCar(img, playerCol.hex)));
// Phase 4: brief pause as train cars
await this.delay(150);
// Phase 5: fly to route segments simultaneously
await Promise.all(segs.map((seg, i) => {
const img = cardObjs[i];
if (!img) return Promise.resolve();
return new Promise((res) => this.tweens.add({
targets: img,
x: seg.cx, y: seg.cy,
scaleX: seg.w / 120, scaleY: 16 / 40,
rotation: seg.angle,
duration: 600, ease: 'Cubic.easeIn', onComplete: res,
}));
}));
cardObjs.forEach((img) => img.destroy());
}
async _transformToTrainCar(img, tintColor) {
await new Promise((res) => this.tweens.add({
targets: img, scaleX: 0, scaleY: 0, duration: 200, ease: 'Cubic.easeIn', onComplete: res,
}));
img.setTexture('ttr-train-car').setTint(tintColor);
await new Promise((res) => this.tweens.add({
targets: img, scaleX: 1, scaleY: 1, duration: 200, ease: 'Cubic.easeOut', onComplete: res,
}));
}
async animateMarketSlideUp(fromSlot, lastSlot) {
const mkStep = CARD_W + 10;
const targets = [];
for (let j = fromSlot + 1; j <= lastSlot; j++) {
if (this.marketSlotObjs[j]) targets.push(...this.marketSlotObjs[j]);
}
if (targets.length === 0) return;
await new Promise((res) => this.tweens.add({
targets, y: `-=${mkStep}`, duration: 200, ease: 'Cubic.easeInOut', onComplete: res,
}));
}
async animateRefillMarketSlot(slotIndex, color) {
const ANIM_DEPTH = D.banner + 10;
const destX = MK_X;
const destY = MK_Y0 + slotIndex * (CARD_W + 10);
const origScaleX = CARD_W / 270;
const card = this.add.image(PILE_X, MK_Y0, 'ttr-cards', TTR_CARD_FRAME.back)
.setDisplaySize(CARD_W, CARD_H)
.setAngle(-90)
.setDepth(ANIM_DEPTH);
// Slide from deck to market slot
await new Promise((res) => this.tweens.add({
targets: card, x: destX, y: destY, duration: 350, ease: 'Cubic.easeOut', onComplete: res,
}));
// Flip at slot: collapse scaleX (height at -90°), swap frame, restore
await new Promise((res) => this.tweens.add({
targets: card, scaleX: 0, duration: 150, ease: 'Linear', onComplete: res,
}));
card.setFrame(TTR_CARD_FRAME[color] ?? TTR_CARD_FRAME.back);
await new Promise((res) => this.tweens.add({
targets: card, scaleX: origScaleX, duration: 150, ease: 'Linear', onComplete: res,
}));
card.destroy();
}
async animateCardDraw({ srcX, srcY, srcAngle = 0, cardFrame, shouldFlip = false, destX, destY, destW, destH }) {
const ANIM_DEPTH = D.banner + 10;
const CX = GAME_WIDTH / 2;