From 2a552c7463fea44203d9363e4c6801c1fa0d87f6 Mon Sep 17 00:00:00 2001 From: student079 <102852555+student079@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:53:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20rank=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20(#225)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/gameServer/src/modules/games/games-utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/be/gameServer/src/modules/games/games-utils.ts b/be/gameServer/src/modules/games/games-utils.ts index 8c849e7..381975f 100644 --- a/be/gameServer/src/modules/games/games-utils.ts +++ b/be/gameServer/src/modules/games/games-utils.ts @@ -91,11 +91,15 @@ export function removePlayerFromGame( gameData: GameDataDto, playerNickname: string, ): void { - gameData.alivePlayers = gameData.alivePlayers.filter( - (player: string) => player !== playerNickname, - ); - - gameData.rank.unshift(playerNickname); + if (gameData.alivePlayers.includes(playerNickname)) { + gameData.alivePlayers = gameData.alivePlayers.filter( + (player: string) => player !== playerNickname, + ); + + if (!gameData.rank.includes(playerNickname)) { + gameData.rank.unshift(playerNickname); + } + } } export function noteToNumber(note: string): number {