mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:30:43 +00:00
Hide dead players from the leaderboard (#2114)
## Description: Update leaderboard logic to exclude dead players. Players (including myPlayer) are only shown if alive. https://github.com/user-attachments/assets/0a5c0422-4844-41ae-ae0b-3d7d8473491c ## 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: aotumuri
This commit is contained in:
@@ -99,13 +99,13 @@ export class Leaderboard extends LitElement implements Layer {
|
||||
const numTilesWithoutFallout =
|
||||
this.game.numLandTiles() - this.game.numTilesWithFallout();
|
||||
|
||||
const playersToShow = this.showTopFive ? sorted.slice(0, 5) : sorted;
|
||||
const alivePlayers = sorted.filter((player) => player.isAlive());
|
||||
const playersToShow = this.showTopFive
|
||||
? alivePlayers.slice(0, 5)
|
||||
: alivePlayers;
|
||||
|
||||
this.players = playersToShow.map((player, index) => {
|
||||
let troops = player.troops() / 10;
|
||||
if (!player.isAlive()) {
|
||||
troops = 0;
|
||||
}
|
||||
const troops = player.troops() / 10;
|
||||
return {
|
||||
name: player.displayName(),
|
||||
position: index + 1,
|
||||
@@ -131,22 +131,21 @@ export class Leaderboard extends LitElement implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
let myPlayerTroops = myPlayer.troops() / 10;
|
||||
if (!myPlayer.isAlive()) {
|
||||
myPlayerTroops = 0;
|
||||
if (myPlayer.isAlive()) {
|
||||
const myPlayerTroops = myPlayer.troops() / 10;
|
||||
this.players.pop();
|
||||
this.players.push({
|
||||
name: myPlayer.displayName(),
|
||||
position: place,
|
||||
score: formatPercentage(
|
||||
myPlayer.numTilesOwned() / this.game.numLandTiles(),
|
||||
),
|
||||
gold: renderNumber(myPlayer.gold()),
|
||||
troops: renderNumber(myPlayerTroops),
|
||||
isMyPlayer: true,
|
||||
player: myPlayer,
|
||||
});
|
||||
}
|
||||
this.players.pop();
|
||||
this.players.push({
|
||||
name: myPlayer.displayName(),
|
||||
position: place,
|
||||
score: formatPercentage(
|
||||
myPlayer.numTilesOwned() / this.game.numLandTiles(),
|
||||
),
|
||||
gold: renderNumber(myPlayer.gold()),
|
||||
troops: renderNumber(myPlayerTroops),
|
||||
isMyPlayer: true,
|
||||
player: myPlayer,
|
||||
});
|
||||
}
|
||||
|
||||
this.requestUpdate();
|
||||
|
||||
Reference in New Issue
Block a user