fix(SCOPONE-0006): remove stale capture handlers when switching card selection

- Track table card images with capture listeners in captureListenerImgs[]
- Clear pointerdown handlers in clearHighlights() before destroying overlays
- Prevents wrong capture executing when selecting a different hand card
This commit is contained in:
Giancarmine Salucci
2026-04-01 10:54:45 +02:00
parent 30897c5eb3
commit 113bb12723

View File

@@ -89,6 +89,7 @@ export class GameScene extends Phaser.Scene {
private selectedGlowTween: Phaser.Tweens.Tween | null = null;
private pendingCaptures: Card[][] = [];
private tableHighlights: Phaser.GameObjects.GameObject[] = [];
private captureListenerImgs: Phaser.GameObjects.Image[] = [];
private aiThinking = false;
private tableCenter!: { x: number; y: number };
@@ -734,6 +735,7 @@ export class GameScene extends Phaser.Scene {
this.tableHighlights.push(hl);
img.setInteractive({ useHandCursor: true });
img.once('pointerdown', () => this.confirmMove(this.selectedCard!, capture));
this.captureListenerImgs.push(img);
}
}
@@ -776,6 +778,7 @@ export class GameScene extends Phaser.Scene {
this.tableHighlights.push(hl);
img.setInteractive({ useHandCursor: true });
img.once('pointerdown', () => this.confirmMove(this.selectedCard!, cap));
this.captureListenerImgs.push(img);
}
}
});
@@ -800,6 +803,8 @@ export class GameScene extends Phaser.Scene {
}
private clearHighlights(): void {
for (const img of this.captureListenerImgs) img.off('pointerdown');
this.captureListenerImgs = [];
for (const h of this.tableHighlights) h.destroy();
this.tableHighlights = [];
}