From f63bf33c6f6976ead8c9dd061ac3d109e95e8a20 Mon Sep 17 00:00:00 2001 From: Ralex91 <95540504+Ralex91@users.noreply.github.com> Date: Thu, 1 Feb 2024 11:43:50 +0100 Subject: [PATCH] Update Round Result values --- socket/src/utils/round.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/socket/src/utils/round.js b/socket/src/utils/round.js index 728c671..2a28512 100644 --- a/socket/src/utils/round.js +++ b/socket/src/utils/round.js @@ -76,6 +76,7 @@ export const startRound = async (game, io, socket) => { let sortPlayers = game.players.sort((a, b) => b.points - a.points) let rank = sortPlayers.findIndex((p) => p.id === player.id) + 1 + let aheadPlayer = sortPlayers[rank - 2] io.to(player.id).emit("game:status", { name: "SHOW_RESULT", @@ -84,11 +85,8 @@ export const startRound = async (game, io, socket) => { message: isCorrect ? "Nice !" : "Too bad", points: points, myPoints: player.points, - totalPlayer: game.players.length, rank, - aheadOfMe: sortPlayers[rank - 2] - ? sortPlayers[rank - 2].username - : null, + aheadOfMe: aheadPlayer ? aheadPlayer.username : null, }, }) }, 200)