From 4f7a356dcfb19d9c68bc50df7b14c4c465960bb1 Mon Sep 17 00:00:00 2001 From: yena <50291995+nyj001012@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:55:11 +0900 Subject: [PATCH] =?UTF-8?q?feat(histories):=20=EC=8B=9C=EC=83=81=EB=8C=80?= =?UTF-8?q?=20=EB=A0=8C=EB=8D=94=EB=A7=81=20=ED=95=A0=20=EB=95=8C,=20?= =?UTF-8?q?=EB=91=90=20=EB=B2=88=EC=A7=B8=20=EA=B2=BD=EA=B8=B0=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=EB=A7=8C=20=EB=81=9D=EB=82=AC=EC=9D=84=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=203=EB=93=B1=20=EB=A0=8C=EB=8D=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../histories/tournament-histories-details.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/histories/tournament-histories-details.js b/frontend/src/pages/histories/tournament-histories-details.js index 7712f197..b55dd880 100644 --- a/frontend/src/pages/histories/tournament-histories-details.js +++ b/frontend/src/pages/histories/tournament-histories-details.js @@ -176,7 +176,7 @@ export default function TournamentHistoriesDetails(gameId) { * 게임 중인 토너먼트의 결과를 반환합니다. match3가 null인 경우에 호출됩니다. * @param match1 {object} * @param match2 {object} - * @returns {{firstPlayer: {nickname: string, avatar: string, rating: string}, secondPlayer: {nickname: string, avatar: string, rating: string}, others: {player2: {nickname: string, avatar: string, rating: string}}}} 토너먼트 결과 + * @returns {object} 토너먼트 결과 */ const getResultInGame = (match1, match2) => { let result = { @@ -192,23 +192,35 @@ export default function TournamentHistoriesDetails(gameId) { }, others: { player1: {}, - player2: { - nickname: "", - avatar: "anonymous.png", - rating: "?", - }, + player2: {}, }, }; + let anonymous = { + nickname: "", + avatar: "anonymous.png", + rating: "?", + }; if (match1.player1.score === null && match1.player2.score === null) { result.others.player1 = match2.player1.score > match2.player2.score ? match2.player2 : match2.player1; + result.others.player2 = anonymous; } else if (match2.player1.score === null && match2.player2.score === null) { result.others.player1 = match1.player1.score > match1.player2.score ? match1.player2 : match1.player1; + result.others.player2 = anonymous; + } else { + result.others.player1 = + match1.player1.score < match1.player2.score + ? match1.player1 + : match1.player2; + result.others.player2 = + match2.player1.score < match2.player2.score + ? match2.player1 + : match2.player2; } return result; };