From 9988b83b544f58a5dde299640852255ff499b985 Mon Sep 17 00:00:00 2001 From: 1brucben <1benjbruce@gmail.com> Date: Sat, 19 Apr 2025 00:32:27 +0200 Subject: [PATCH] fix for empty tile set --- src/core/execution/AttackExecution.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 3acdf50b0..34bfa3e12 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -237,7 +237,17 @@ export class AttackExecution implements Execution { const priorityTiles: { tile: TileRef; weight: number }[] = []; const fallbackTiles: { tile: TileRef; weight: number }[] = []; - for (const tile of this.toConquer) { + const validTiles = this.toConquer.filter((tile) => { + const onBorder = this.mg + .neighbors(tile) + .some((t) => this.mg.owner(t) === this._owner); + return this.mg.owner(tile) === this.target && onBorder; + }); + if (validTiles.length === 0) { + this.retreat(); + return; + } + for (const tile of validTiles) { const neighbors = this.mg.neighbors(tile); const ownedCount = neighbors.filter( (t) => this.mg.owner(t) === this._owner,