From 9477788709127ffd5611caed0fa7ee191326ce00 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 10 Aug 2024 13:31:52 +0900 Subject: feat(frontend): partially implement watch page --- .../GolfWatchApps/GolfWatchAppGaming.tsx | 137 +++++++++++++++++---- 1 file changed, 113 insertions(+), 24 deletions(-) (limited to 'frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx') diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx index 22277f8..470a00c 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -1,41 +1,130 @@ type Props = { problem: string; - codeA: string; - scoreA: number | null; - codeB: string; - scoreB: number | null; + playerInfoA: PlayerInfo; + playerInfoB: PlayerInfo; + leftTimeSeconds: number; +}; + +export type PlayerInfo = { + displayName: string | null; + iconPath: string | null; + score: number | null; + code: string | null; + submissionResult?: SubmissionResult; +}; + +type SubmissionResult = { + status: string; + nextScore: number; + executionResults: ExecutionResult[]; +}; + +type ExecutionResult = { + status: string; + label: string; + output: string; }; export default function GolfWatchAppGaming({ problem, - codeA, - scoreA, - codeB, - scoreB, + playerInfoA, + playerInfoB, + leftTimeSeconds, }: Props) { + const leftTime = (() => { + const m = Math.floor(leftTimeSeconds / 60); + const s = leftTimeSeconds % 60; + return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`; + })(); + const scoreRatio = (() => { + const scoreA = playerInfoA.score ?? 0; + const scoreB = playerInfoB.score ?? 0; + const totalScore = scoreA + scoreB; + return totalScore === 0 ? 50 : (scoreA / totalScore) * 100; + })(); + return ( -
-
-
{problem}
+
+
+
+ {playerInfoA.displayName} +
+
{leftTime}
+
+ {playerInfoB.displayName} +
-
-
-
{scoreA}
-
-
-							{codeA}
-						
+
+
+ {playerInfoA.score ?? "-"} +
+
+
+
+
+ {playerInfoB.score ?? "-"} +
+
+
+
+
+						{playerInfoA.code}
+					
+
+
+
+ {playerInfoA.submissionResult?.status}( + {playerInfoA.submissionResult?.nextScore}) +
+
+
    + {playerInfoA.submissionResult?.executionResults.map( + (result, idx) => ( +
  1. +
    +
    + {result.status} {result.label} +
    +
    {result.output}
    +
    +
  2. + ), + )} +
-
-
{scoreB}
-
-
-							{codeB}
-						
+
+
+						{playerInfoB.code}
+					
+
+
+
+ {playerInfoB.submissionResult?.status}( + {playerInfoB.submissionResult?.nextScore}) +
+
+
    + {playerInfoB.submissionResult?.executionResults.map( + (result, idx) => ( +
  1. +
    +
    + {result.status} {result.label} +
    +
    {result.output}
    +
    +
  2. + ), + )} +
+
{problem}
); } -- cgit v1.2.3-70-g09d2