Update Result rank text

This commit is contained in:
Ralex91
2024-02-01 11:30:33 +01:00
parent 6838f04828
commit fb8c2aa1c3
4 changed files with 15 additions and 10 deletions

View File

@@ -73,10 +73,9 @@ export const startRound = async (game, io, socket) => {
game.players.find((p) => p.id === player.id).points += points
setTimeout(() => {
let rank =
game.players
.sort((a, b) => b.points - a.points)
.findIndex((p) => p.id === player.id) + 1
let sortPlayers = game.players.sort((a, b) => b.points - a.points)
let rank = sortPlayers.findIndex((p) => p.id === player.id) + 1
io.to(player.id).emit("game:status", {
name: "SHOW_RESULT",
@@ -86,7 +85,10 @@ export const startRound = async (game, io, socket) => {
points: points,
myPoints: player.points,
totalPlayer: game.players.length,
rank: rank,
rank,
aheadOfMe: sortPlayers[rank - 2]
? sortPlayers[rank - 2].username
: null,
},
})
}, 200)