From 057c3dd784cb405cb10d981c7b026ad3ad6ecbe9 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Tue, 8 Jul 2025 14:13:27 -0700 Subject: [PATCH] fix pop delta number in TopBar (#1373) ## Description: The population delta number was always green, even if it was decreasing. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com> --- src/client/graphics/layers/GameTopBar.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/client/graphics/layers/GameTopBar.ts b/src/client/graphics/layers/GameTopBar.ts index 9ec962b8d..cb5d4dcf7 100644 --- a/src/client/graphics/layers/GameTopBar.ts +++ b/src/client/graphics/layers/GameTopBar.ts @@ -7,7 +7,6 @@ import workerIcon from "../../../../resources/images/WorkerIconWhite.svg"; import { EventBus } from "../../../core/EventBus"; import { GameUpdateType } from "../../../core/game/GameUpdates"; import { GameView } from "../../../core/game/GameView"; -import { UserSettings } from "../../../core/game/UserSettings"; import { renderNumber, renderTroops } from "../../Utils"; import { Layer } from "./Layer"; @@ -15,8 +14,6 @@ import { Layer } from "./Layer"; export class GameTopBar extends LitElement implements Layer { public game: GameView; public eventBus: EventBus; - private _userSettings: UserSettings = new UserSettings(); - private _population = 0; private _troops = 0; private _workers = 0; private _lastPopulationIncreaseRate = 0; @@ -47,12 +44,10 @@ export class GameTopBar extends LitElement implements Layer { private updatePopulationIncrease() { const player = this.game?.myPlayer(); if (player === null) return; - const popIncreaseRate = player.population() - this._population; - if (this.game.ticks() % 5 === 0) { - this._popRateIsIncreasing = - popIncreaseRate >= this._lastPopulationIncreaseRate; - this._lastPopulationIncreaseRate = popIncreaseRate; - } + const popIncreaseRate = this.game.config().populationIncreaseRate(player); + this._popRateIsIncreasing = + popIncreaseRate >= this._lastPopulationIncreaseRate; + this._lastPopulationIncreaseRate = popIncreaseRate; } render() {