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:
@@ -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 = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user