Add missing factory in player info panel (#1507)

## Description:

The player info panel is missing the factory count. Also only displays
the units available in the current game.
 
Every unit:
<img width="185" height="238" alt="image"
src="https://github.com/user-attachments/assets/52eca7c8-99e0-4234-98d4-8efe1644a92c"
/>

City only:
<img width="186" height="142" alt="image"
src="https://github.com/user-attachments/assets/87aef9f8-697c-4aa0-8bc5-92f016886a9d"
/>


## 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 have read and accepted the CLA aggreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

IngloriousTom
This commit is contained in:
DevelopingTom
2025-07-26 01:47:54 +02:00
committed by GitHub
parent 932d4f3be2
commit afc5709a1b
2 changed files with 43 additions and 20 deletions
+1
View File
@@ -450,6 +450,7 @@
"gold": "Gold",
"ports": "Ports",
"cities": "Cities",
"factories": "Factories",
"missile_launchers": "Missile launchers",
"sams": "SAMs",
"warships": "Warships",
+42 -20
View File
@@ -170,6 +170,18 @@ export class PlayerInfoOverlay extends LitElement implements Layer {
}
}
private displayUnitCount(
player: PlayerView,
type: UnitType,
description: string,
) {
return !this.game.config().isUnitDisabled(type)
? html`<div class="text-sm opacity-80" translate="no">
${translateText(description)}: ${player.totalUnitLevels(type)}
</div>`
: "";
}
private renderPlayerInfo(player: PlayerView) {
const myPlayer = this.game.myPlayer();
const isFriendly = myPlayer?.isFriendly(player);
@@ -255,26 +267,36 @@ export class PlayerInfoOverlay extends LitElement implements Layer {
${translateText("player_info_overlay.gold")}:
${renderNumber(player.gold())}
</div>
<div class="text-sm opacity-80" translate="no">
${translateText("player_info_overlay.ports")}:
${player.totalUnitLevels(UnitType.Port)}
</div>
<div class="text-sm opacity-80" translate="no">
${translateText("player_info_overlay.cities")}:
${player.totalUnitLevels(UnitType.City)}
</div>
<div class="text-sm opacity-80" translate="no">
${translateText("player_info_overlay.missile_launchers")}:
${player.totalUnitLevels(UnitType.MissileSilo)}
</div>
<div class="text-sm opacity-80" translate="no">
${translateText("player_info_overlay.sams")}:
${player.totalUnitLevels(UnitType.SAMLauncher)}
</div>
<div class="text-sm opacity-80" translate="no">
${translateText("player_info_overlay.warships")}:
${player.units(UnitType.Warship).length}
</div>
${this.displayUnitCount(
player,
UnitType.Port,
"player_info_overlay.ports",
)}
${this.displayUnitCount(
player,
UnitType.City,
"player_info_overlay.cities",
)}
${this.displayUnitCount(
player,
UnitType.Factory,
"player_info_overlay.factories",
)}
${this.displayUnitCount(
player,
UnitType.MissileSilo,
"player_info_overlay.missile_launchers",
)}
${this.displayUnitCount(
player,
UnitType.SAMLauncher,
"player_info_overlay.sams",
)}
${this.displayUnitCount(
player,
UnitType.Warship,
"player_info_overlay.warships",
)}
${relationHtml}
</div>
`;