mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-21 13:05:14 +00:00
update
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user