From 715d40ec9f863ef9dee5b6648353a9d9aa3c2abf Mon Sep 17 00:00:00 2001 From: 1brucben <1benjbruce@gmail.com> Date: Thu, 8 May 2025 01:58:22 +0200 Subject: [PATCH] pop fix --- src/core/configuration/DefaultConfig.ts | 10 +++++----- src/core/game/GameUpdates.ts | 1 + src/core/game/GameView.ts | 3 +++ src/core/game/PlayerImpl.ts | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index c16fc0e34..924c6bc6f 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -618,10 +618,7 @@ export class DefaultConfig implements Config { let toAdd = 10 + (1400 / max + 1 / 125) * (0.8 * player.troops() + 1.2 * player.workers()); - const adjustedPop = - typeof player.adjustedPopulation === "function" - ? player.adjustedPopulation() - : player.population(); + const adjustedPop = player.adjustedPopulation(); const ratio = 1 - adjustedPop / max; toAdd *= ratio; @@ -647,7 +644,10 @@ export class DefaultConfig implements Config { } } - return Math.min(player.population() + toAdd, max) - player.population(); + return ( + Math.min(player.adjustedPopulation() + toAdd, max) - + player.adjustedPopulation() + ); } goldAdditionRate(player: Player): number { diff --git a/src/core/game/GameUpdates.ts b/src/core/game/GameUpdates.ts index 5f78111f9..4507ca8b2 100644 --- a/src/core/game/GameUpdates.ts +++ b/src/core/game/GameUpdates.ts @@ -99,6 +99,7 @@ export interface PlayerUpdate { tilesOwned: number; gold: number; population: number; + adjustedPopulation: number; workers: number; troops: number; targetTroopRatio: number; diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index 04d7d9666..0edb4e964 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -225,6 +225,9 @@ export class PlayerView { population(): number { return this.data.population; } + adjustedPopulation(): number { + return this.data.adjustedPopulation; + } workers(): number { return this.data.workers; } diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index 429a6abbe..a4e92ab81 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -137,6 +137,7 @@ export class PlayerImpl implements Player { tilesOwned: this.numTilesOwned(), gold: Number(this._gold), population: this.population(), + adjustedPopulation: this.adjustedPopulation(), workers: this.workers(), troops: this.troops(), targetTroopRatio: this.targetTroopRatio(),