import { useAtomValue } from "jotai"; import { codeAAtom, codeBAtom, gamingLeftTimeSecondsAtom, scoreAAtom, scoreBAtom, submitResultAAtom, submitResultBAtom, } from "../../states/watch"; import type { PlayerProfile } from "../../types/PlayerProfile"; import BorderedContainer from "../BorderedContainer"; import CodeBlock from "../Gaming/CodeBlock"; import ScoreBar from "../Gaming/ScoreBar"; import SubmitResult from "../Gaming/SubmitResult"; import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; playerProfileA: PlayerProfile; playerProfileB: PlayerProfile; problemTitle: string; problemDescription: string; gameResult: "winA" | "winB" | "draw" | null; }; export default function GolfWatchAppGaming({ gameDisplayName, playerProfileA, playerProfileB, problemTitle, problemDescription, gameResult, }: Props) { const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const codeA = useAtomValue(codeAAtom); const codeB = useAtomValue(codeBAtom); const scoreA = useAtomValue(scoreAAtom); const scoreB = useAtomValue(scoreBAtom); const submitResultA = useAtomValue(submitResultAAtom); const submitResultB = useAtomValue(submitResultBAtom); 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-iosdc-japan"; return (
{playerProfileA.iconPath && ( )}
Player 1
{playerProfileA.displayName}
{scoreA}
{gameDisplayName}
{gameResult ? gameResult === "winA" ? `勝者 ${playerProfileA.displayName}` : gameResult === "winB" ? `勝者 ${playerProfileB.displayName}` : "引き分け" : leftTime}
{scoreB}
Player 2
{playerProfileB.displayName}
{playerProfileB.iconPath && ( )}
{problemTitle}
{problemDescription}
); }