@@ -999,7 +999,7 @@ function getCachedPlayer(playerID) {
999
999
}
1000
1000
1001
1001
for ( let i = 0 ; i < cachedPlayers . length ; i ++ ) {
1002
- let player = cachedPlayers [ i ] ;
1002
+ const player = cachedPlayers [ i ] ;
1003
1003
if ( player . id === playerID ) {
1004
1004
return player ;
1005
1005
}
@@ -1073,7 +1073,7 @@ function handleReadyEvent(ready) {
1073
1073
1074
1074
//These two are required for displaying the "game over / win / tie" message.
1075
1075
let countOfRankOnePlayers = 0 ;
1076
- let isSelfRankOne = false ;
1076
+ let selfPlayer ;
1077
1077
for ( let i = 0 ; i < players . length ; i ++ ) {
1078
1078
const player = players [ i ] ;
1079
1079
if ( ! player . connected || player . state === "spectating" ) {
@@ -1082,13 +1082,12 @@ function handleReadyEvent(ready) {
1082
1082
1083
1083
if ( player . rank === 1 ) {
1084
1084
countOfRankOnePlayers ++ ;
1085
- if ( player . id === ownID ) {
1086
- isSelfRankOne = true ;
1087
- }
1085
+ }
1086
+ if ( player . id === ownID ) {
1087
+ selfPlayer = player ;
1088
1088
}
1089
1089
1090
- //Even if we don't want to show a player-entry, we still need to iterate
1091
- //over all players to handle the dialog titles.
1090
+ // We only display the first 5 players on the scoreboard.
1092
1091
if ( player . rank <= 5 ) {
1093
1092
const newScoreboardEntry = document . createElement ( "div" ) ;
1094
1093
newScoreboardEntry . classList . add ( "gameover-scoreboard-entry" ) ;
@@ -1115,14 +1114,15 @@ function handleReadyEvent(ready) {
1115
1114
}
1116
1115
}
1117
1116
1118
- if ( isSelfRankOne ) {
1117
+ if ( selfPlayer . rank === 1 ) {
1119
1118
if ( countOfRankOnePlayers >= 2 ) {
1120
1119
gameOverDialogTitle . innerText = `{{.Translation.Get "game-over-tie"}}` ;
1121
1120
} else {
1122
1121
gameOverDialogTitle . innerText = `{{.Translation.Get "game-over-win"}}` ;
1123
1122
}
1124
1123
} else {
1125
- gameOverDialogTitle . innerText = `{{.Translation.Get "game-over"}}` . format ( player . rank , player . score ) ;
1124
+ gameOverDialogTitle . innerText = `{{.Translation.Get "game-over"}}`
1125
+ . format ( selfPlayer . rank , selfPlayer . score ) ;
1126
1126
}
1127
1127
} else if ( ready . gameState === "ongoing" ) {
1128
1128
// Lack of wordHints implies that word has been chosen yet.
0 commit comments