From 2760b1110fd3f3440d57f8f8666734ff643986ae Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 4 Jan 2025 13:51:12 -0800 Subject: [PATCH] fix calculate cluster conquering itself because removeCluster changed tile ownership --- src/core/execution/PlayerExecution.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/execution/PlayerExecution.ts b/src/core/execution/PlayerExecution.ts index 9640fb244..11a60a89c 100644 --- a/src/core/execution/PlayerExecution.ts +++ b/src/core/execution/PlayerExecution.ts @@ -148,6 +148,11 @@ export class PlayerExecution implements Execution { private removeCluster(cluster: Set) { const arr = Array.from(cluster) + if (arr.some(t => t.owner() != this.player)) { + // Other removeCluster operations could change tile owners, + // so double check. + return + } const mode = getMode(arr.flatMap(t => t.neighbors()).filter(t => t.hasOwner() && t.owner() != this.player).map(t => t.owner().id())) if (!this.mg.hasPlayer(mode)) { consolex.warn('mode is not found')