import { useAtomValue } from "jotai"; import type { components } from "../../api/schema"; import { gamingLeftTimeSecondsAtom } from "../../states/watch"; import Problem from "../Gaming/Problem"; import UserLabel from "../UserLabel"; type RankingEntry = components["schemas"]["RankingEntry"]; type Props = { gameDisplayName: string; ranking: RankingEntry[]; problemTitle: string; problemDescription: string; sampleCode: string; gameResult: "winA" | "winB" | "draw" | null; }; export default function GolfWatchAppGamingMultiplayer({ gameDisplayName, ranking, problemTitle, problemDescription, sampleCode, gameResult, }: Props) { const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const leftTime = (() => { const m = Math.floor(leftTimeSeconds / 60); const s = leftTimeSeconds % 60; return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`; })(); const topBg = gameResult ? gameResult === "winA" ? "bg-orange-400" : gameResult === "winB" ? "bg-purple-400" : "bg-pink-500" : "bg-sky-600"; return (
{gameDisplayName}
{leftTime}
{ranking.map((entry, index) => ( ))}
順位 名前 スコア
{index + 1} {entry.player.display_name} {entry.player.label && ( )} {entry.score}
); }