fix(dominion): prevent card interaction during draw animations

- Defer hover and interactivity attachment until cards are fully visible
- Re-enable interactivity after draw/discard animations complete
- Prevents accidental card clicks during animation transitions
This commit is contained in:
Brian Fertig 2026-06-12 10:02:23 -06:00
parent 1e607e5802
commit 01dcfbfd85
1 changed files with 13 additions and 3 deletions

View File

@ -616,8 +616,11 @@ export default class DominionGame extends Phaser.Scene {
this.dynamicLayer.add(face); this.dynamicLayer.add(face);
const hit = this.add.rectangle(x, baseY, HAND_W, HAND_H, 0x000000, 0).setDepth(D.hand + i + 1); const hit = this.add.rectangle(x, baseY, HAND_W, HAND_H, 0x000000, 0).setDepth(D.hand + i + 1);
this.dynamicLayer.add(hit); this.dynamicLayer.add(hit);
// Only attach hover and interactivity once the card is visible (not animating in).
if (!this._animatingIids.has(c.iid)) {
this.attachHover(hit, def); this.attachHover(hit, def);
hit.setInteractive({ useHandCursor: true }); hit.setInteractive({ useHandCursor: true });
}
const hs = { iid: c.iid, id: c.id, def, x, baseY, face, hit, isPlayableAction, isPlayableTreasure }; const hs = { iid: c.iid, id: c.id, def, x, baseY, face, hit, isPlayableAction, isPlayableTreasure };
this.handSprites.push(hs); this.handSprites.push(hs);
@ -2429,7 +2432,14 @@ export default class DominionGame extends Phaser.Scene {
_finishDrawAnim() { _finishDrawAnim() {
this._deckAnimDisplay = null; this._deckAnimDisplay = null;
this._discardAnimDisplay = null; this._discardAnimDisplay = null;
this.handSprites.forEach(s => s.face.setAlpha(1)); this.handSprites.forEach(s => {
s.face.setAlpha(1);
// Re-enable hover and interactivity now that the card is visible.
if (!s.hit.input?.enabled) {
this.attachHover(s.hit, s.def);
s.hit.setInteractive({ useHandCursor: true });
}
});
this._animatingIids.clear(); this._animatingIids.clear();
this._animating = false; this._animating = false;
this._suppressTurnUi = false; this._suppressTurnUi = false;