This commit is contained in:
Ryan Barlow
2026-05-27 00:49:15 +01:00
parent 08c19ece4e
commit 030cc5e362
3 changed files with 35 additions and 2 deletions
-2
View File
@@ -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");
+12
View File
@@ -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
@@ -35,6 +35,14 @@ function makeConfig(overrides: Partial<GameConfig> = {}): 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);
});
});