From 7df6f271ed5dbeee720995277e542fd0740f5b79 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Thu, 3 Apr 2025 01:24:02 -0400 Subject: [PATCH] maybeSpawnStructure --- src/core/execution/FakeHumanExecution.ts | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 36082ebae..cb04d3bb4 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -434,29 +434,16 @@ export class FakeHumanExecution implements Execution { } return; } - this.maybeSpawnStructure( - UnitType.City, - 2, - (t) => new ConstructionExecution(this.player.id(), t, UnitType.City), - ); + this.maybeSpawnStructure(UnitType.City, 2); if (this.maybeSpawnWarship()) { return; } if (!this.mg.config().disableNukes()) { - this.maybeSpawnStructure( - UnitType.MissileSilo, - 1, - (t) => - new ConstructionExecution(this.player.id(), t, UnitType.MissileSilo), - ); + this.maybeSpawnStructure(UnitType.MissileSilo, 1); } } - private maybeSpawnStructure( - type: UnitType, - maxNum: number, - build: (tile: TileRef) => Execution, - ) { + private maybeSpawnStructure(type: UnitType, maxNum: number) { const units = this.player.units(type); if (units.length >= maxNum) { return; @@ -472,7 +459,9 @@ export class FakeHumanExecution implements Execution { if (canBuild == false) { return; } - this.mg.addExecution(build(tile)); + this.mg.addExecution( + new ConstructionExecution(this.player.id(), tile, type), + ); } private maybeSpawnWarship(): boolean {