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
@@ -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);
});
});