From f96fd6dc12a5328d2433047e238248214b090f4b Mon Sep 17 00:00:00 2001
From: FloPinguin <25036848+FloPinguin@users.noreply.github.com>
Date: Tue, 16 Dec 2025 05:22:59 +0100
Subject: [PATCH] =?UTF-8?q?Show=20max=20troops=20in=20PlayerInfoOverlay=20?=
=?UTF-8?q?and=20leaderboard=20=F0=9F=96=8C=EF=B8=8F=20(#2625)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## Description:
In the main discord, people seem to be divided in their opinions about
this.
But lets see what the playtest-people are saying, we can easily roll
this back.
## 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
## Please put your Discord username so you can be contacted if a bug or
regression is found:
FloPinguin
---
resources/lang/en.json | 3 +-
src/client/graphics/layers/Leaderboard.ts | 42 ++++++++++---------
.../graphics/layers/PlayerInfoOverlay.ts | 12 ++++++
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/resources/lang/en.json b/resources/lang/en.json
index 7031576ac..f3f1bda26 100644
--- a/resources/lang/en.json
+++ b/resources/lang/en.json
@@ -557,7 +557,7 @@
"team": "Team",
"owned": "Owned",
"gold": "Gold",
- "troops": "Troops",
+ "maxtroops": "Max troops",
"launchers": "Launchers",
"sams": "SAMs",
"warships": "Warships",
@@ -573,6 +573,7 @@
"team": "Team",
"alliance_timeout": "Alliance ends in",
"troops": "Troops",
+ "maxtroops": "Max troops",
"a_troops": "Attacking troops",
"gold": "Gold",
"ports": "Ports",
diff --git a/src/client/graphics/layers/Leaderboard.ts b/src/client/graphics/layers/Leaderboard.ts
index 21aee6e32..3204d1e56 100644
--- a/src/client/graphics/layers/Leaderboard.ts
+++ b/src/client/graphics/layers/Leaderboard.ts
@@ -1,7 +1,7 @@
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { repeat } from "lit/directives/repeat.js";
-import { translateText } from "../../../client/Utils";
+import { renderTroops, translateText } from "../../../client/Utils";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils";
@@ -12,7 +12,7 @@ interface Entry {
position: number;
score: string;
gold: string;
- troops: string;
+ maxTroops: string;
isMyPlayer: boolean;
isOnSameTeam: boolean;
player: PlayerView;
@@ -44,7 +44,7 @@ export class Leaderboard extends LitElement implements Layer {
private showTopFive = true;
@state()
- private _sortKey: "tiles" | "gold" | "troops" = "tiles";
+ private _sortKey: "tiles" | "gold" | "maxtroops" = "tiles";
@state()
private _sortOrder: "asc" | "desc" = "desc";
@@ -63,7 +63,7 @@ export class Leaderboard extends LitElement implements Layer {
}
}
- private setSort(key: "tiles" | "gold" | "troops") {
+ private setSort(key: "tiles" | "gold" | "maxtroops") {
if (this._sortKey === key) {
this._sortOrder = this._sortOrder === "asc" ? "desc" : "asc";
} else {
@@ -82,14 +82,16 @@ export class Leaderboard extends LitElement implements Layer {
const compare = (a: number, b: number) =>
this._sortOrder === "asc" ? a - b : b - a;
+ const maxTroops = (p: PlayerView) => this.game!.config().maxTroops(p);
+
switch (this._sortKey) {
case "gold":
sorted = sorted.sort((a, b) =>
compare(Number(a.gold()), Number(b.gold())),
);
break;
- case "troops":
- sorted = sorted.sort((a, b) => compare(a.troops(), b.troops()));
+ case "maxtroops":
+ sorted = sorted.sort((a, b) => compare(maxTroops(a), maxTroops(b)));
break;
default:
sorted = sorted.sort((a, b) =>
@@ -106,7 +108,7 @@ export class Leaderboard extends LitElement implements Layer {
: alivePlayers;
this.players = playersToShow.map((player, index) => {
- const troops = player.troops() / 10;
+ const maxTroops = this.game!.config().maxTroops(player);
return {
name: player.displayName(),
position: index + 1,
@@ -114,7 +116,7 @@ export class Leaderboard extends LitElement implements Layer {
player.numTilesOwned() / numTilesWithoutFallout,
),
gold: renderNumber(player.gold()),
- troops: renderNumber(troops),
+ maxTroops: renderTroops(maxTroops),
isMyPlayer: player === myPlayer,
isOnSameTeam:
myPlayer !== null &&
@@ -136,7 +138,7 @@ export class Leaderboard extends LitElement implements Layer {
}
if (myPlayer.isAlive()) {
- const myPlayerTroops = myPlayer.troops() / 10;
+ const myPlayerMaxTroops = this.game!.config().maxTroops(myPlayer);
this.players.pop();
this.players.push({
name: myPlayer.displayName(),
@@ -145,7 +147,7 @@ export class Leaderboard extends LitElement implements Layer {
myPlayer.numTilesOwned() / this.game.numLandTiles(),
),
gold: renderNumber(myPlayer.gold()),
- troops: renderNumber(myPlayerTroops),
+ maxTroops: renderTroops(myPlayerMaxTroops),
isMyPlayer: true,
isOnSameTeam: true,
player: myPlayer,
@@ -181,17 +183,19 @@ export class Leaderboard extends LitElement implements Layer {
>