diff --git a/src/core/execution/nation/NationStructureBehavior.ts b/src/core/execution/nation/NationStructureBehavior.ts index f7aad3c802..62c31aa860 100644 --- a/src/core/execution/nation/NationStructureBehavior.ts +++ b/src/core/execution/nation/NationStructureBehavior.ts @@ -161,11 +161,6 @@ export class NationStructureBehavior { if (this.tryBuildDefensePost()) { return true; } - // If the attack threshold is met, block other structures even when - // placement failed (no tile found / can't afford). - if (this.defensePostNeeded()) { - return false; - } } if (this.isOnStructureCooldown()) { diff --git a/tests/NationStructureBehavior.test.ts b/tests/NationStructureBehavior.test.ts index 4612c249e7..a41b1298c2 100644 --- a/tests/NationStructureBehavior.test.ts +++ b/tests/NationStructureBehavior.test.ts @@ -519,6 +519,33 @@ describe("NationStructureBehavior.tryBuildDefensePost", () => { }); }); +describe("NationStructureBehavior.handleStructures", () => { + it("does not block economic structures when defense post placement fails", () => { + const game = { + config: () => ({ + gameConfig: () => ({ difficulty: Difficulty.Hard }), + isUnitDisabled: () => false, + startingGold: () => 0n, + }), + unitInfo: () => ({ cost: () => 0n }), + ticks: () => 100, + }; + const player = { + gold: () => 0n, + troops: () => 1000, + incomingAttacks: () => [{ troops: () => 1000, sourceTile: () => null, attacker: () => ({ id: () => "a" }) }], + }; + const behavior = makeBehavior(game, player); + (behavior as any).placementsCount = 1; + vi.spyOn(behavior as any, "tryBuildDefensePost").mockReturnValue(false); + const doHandleSpy = vi.spyOn(behavior as any, "doHandleStructures").mockReturnValue(true); + + const result = behavior.handleStructures(); + expect(result).toBe(true); + expect(doHandleSpy).toHaveBeenCalled(); + }); +}); + // ── defensePostNeeded ──────────────────────────────────────────────────────── describe("NationStructureBehavior.defensePostNeeded", () => {