From b4ab693aa438f3f1a335369568aabe7849fc1370 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 10 Aug 2024 20:25:59 +0900 Subject: feat: implement watch page --- .../GolfWatchApps/GolfWatchAppGaming.tsx | 82 +++++++++++++++++----- 1 file changed, 66 insertions(+), 16 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 470a00c..992ce7a 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -14,17 +14,57 @@ export type PlayerInfo = { }; type SubmissionResult = { - status: string; - nextScore: number; - executionResults: ExecutionResult[]; + status: + | "running" + | "success" + | "wrong_answer" + | "timeout" + | "compile_error" + | "runtime_error" + | "internal_error"; + preliminaryScore: number; + verificationResults: VerificationResult[]; }; -type ExecutionResult = { - status: string; +type VerificationResult = { + testcase_id: number | null; + status: + | "running" + | "success" + | "wrong_answer" + | "timeout" + | "compile_error" + | "runtime_error" + | "internal_error" + | "canceled"; label: string; - output: string; + stdout: string; + stderr: string; }; +function submissionResultStatusToLabel( + status: SubmissionResult["status"] | null, +) { + switch (status) { + case null: + return "-"; + case "running": + return "Running..."; + case "success": + return "Accepted"; + case "wrong_answer": + return "Wrong Answer"; + case "timeout": + return "Time Limit Exceeded"; + case "compile_error": + return "Compile Error"; + case "runtime_error": + return "Runtime Error"; + case "internal_error": + return "Internal Error"; + } +} + export default function GolfWatchAppGaming({ problem, playerInfoA, @@ -40,7 +80,7 @@ export default function GolfWatchAppGaming({ const scoreA = playerInfoA.score ?? 0; const scoreB = playerInfoB.score ?? 0; const totalScore = scoreA + scoreB; - return totalScore === 0 ? 50 : (scoreA / totalScore) * 100; + return totalScore === 0 ? 50 : (scoreB / totalScore) * 100; })(); return ( @@ -68,7 +108,7 @@ export default function GolfWatchAppGaming({ {playerInfoB.score ?? "-"} -
+
 						{playerInfoA.code}
@@ -76,19 +116,24 @@ export default function GolfWatchAppGaming({
 				
- {playerInfoA.submissionResult?.status}( - {playerInfoA.submissionResult?.nextScore}) + {submissionResultStatusToLabel( + playerInfoA.submissionResult?.status ?? null, + )}{" "} + ({playerInfoA.submissionResult?.preliminaryScore})
    - {playerInfoA.submissionResult?.executionResults.map( + {playerInfoA.submissionResult?.verificationResults.map( (result, idx) => (
  1. {result.status} {result.label}
    -
    {result.output}
    +
    + {result.stdout} + {result.stderr} +
  2. ), @@ -103,19 +148,24 @@ export default function GolfWatchAppGaming({
- {playerInfoB.submissionResult?.status}( - {playerInfoB.submissionResult?.nextScore}) + {submissionResultStatusToLabel( + playerInfoB.submissionResult?.status ?? null, + )}{" "} + ({playerInfoB.submissionResult?.preliminaryScore ?? "-"})
    - {playerInfoB.submissionResult?.executionResults.map( + {playerInfoB.submissionResult?.verificationResults.map( (result, idx) => (
  1. {result.status} {result.label}
    -
    {result.output}
    +
    + {result.stdout} + {result.stderr} +
  2. ), -- cgit v1.2.3-70-g09d2