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