From 030cc5e362eb4c229033102095358aa7e9a374ed Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Wed, 27 May 2026 00:49:15 +0100 Subject: [PATCH] update --- src/client/SkinTestController.ts | 2 -- src/core/configuration/Config.ts | 12 ++++++++++ .../core/configuration/StartingTroops.test.ts | 23 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/client/SkinTestController.ts b/src/client/SkinTestController.ts index bab761fb2..778068548 100644 --- a/src/client/SkinTestController.ts +++ b/src/client/SkinTestController.ts @@ -70,8 +70,6 @@ export class SkinTestController { private runAttack(): void { if (!this.active) return; - // Wait for the player to exist in the GameView before firing — gives the - // worker time to addPlayer() once the spawn execution runs. if (this.gameView.playerByClientID(this.clientID) === null) { if (++this.lookupRetries >= MAX_PLAYER_LOOKUP_RETRIES) { console.error("Skin test: gave up finding player"); diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index f5c6b7eb9..deb5d8f4a 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -762,6 +762,18 @@ export class Config { } maxTroops(player: Player | PlayerView): number { + // When startingTroops is set for a human with infinite troops, treat the + // configured value as the cap so the troop bar starts at 100% rather than + // a sliver of the infinite-troops ceiling. + const override = this._gameConfig.startingTroops; + if ( + override !== undefined && + override !== null && + player.type() === PlayerType.Human && + this.hasInfiniteTroopsFor(player) + ) { + return override; + } const maxTroops = player.type() === PlayerType.Human && this.hasInfiniteTroopsFor(player) ? 1_000_000_000 diff --git a/tests/core/configuration/StartingTroops.test.ts b/tests/core/configuration/StartingTroops.test.ts index eb266bc23..da74f44f0 100644 --- a/tests/core/configuration/StartingTroops.test.ts +++ b/tests/core/configuration/StartingTroops.test.ts @@ -35,6 +35,14 @@ function makeConfig(overrides: Partial = {}): Config { const humanInfo = (): PlayerInfo => new PlayerInfo("test", PlayerType.Human, "client1", "p1", false, null, []); +const humanPlayer = (troops: number) => + ({ + type: () => PlayerType.Human, + troops: () => troops, + numTilesOwned: () => 0, + units: () => [], + }) as any; + describe("Config.startManpower with startingTroops override", () => { it("uses startingTroops when set", () => { const config = makeConfig({ startingTroops: 10_000_000 }); @@ -46,3 +54,18 @@ describe("Config.startManpower with startingTroops override", () => { expect(config.startManpower(humanInfo())).toBe(1_000_000); }); }); + +describe("Config.maxTroops with startingTroops override", () => { + it("caps maxTroops to startingTroops for infinite-troops human", () => { + const config = makeConfig({ + infiniteTroops: true, + startingTroops: 10_000_000, + }); + expect(config.maxTroops(humanPlayer(10_000_000))).toBe(10_000_000); + }); + + it("uses the 1B infinite-troops ceiling when startingTroops is absent", () => { + const config = makeConfig({ infiniteTroops: true }); + expect(config.maxTroops(humanPlayer(1_000_000))).toBe(1_000_000_000); + }); +});