import { useAtomValue } from "jotai"; import { calcCodeSize, gamingLeftTimeSecondsAtom, latestGameStatesAtom, } from "../../states/watch"; import type { PlayerProfile } from "../../types/PlayerProfile"; import FoldableBorderedContainerWithCaption from "../FoldableBorderedContainerWithCaption"; import CodeBlock from "../Gaming/CodeBlock"; import LeftTime from "../Gaming/LeftTime"; import ProblemColumnContent from "../Gaming/ProblemColumnContent"; import RankingTable from "../Gaming/RankingTable"; import ScoreBar from "../Gaming/ScoreBar"; import SubmitStatusLabel from "../SubmitStatusLabel"; import ThreeColumnLayout from "../ThreeColumnLayout"; import TitledColumn from "../TitledColumn"; import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; playerProfileA: PlayerProfile; playerProfileB: PlayerProfile; problemTitle: string; problemDescription: string; sampleCode: string; gameResult: "winA" | "winB" | "draw" | null; }; export default function GolfWatchAppGaming1v1({ gameDisplayName, playerProfileA, playerProfileB, problemTitle, problemDescription, sampleCode, gameResult, }: Props) { const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const latestGameStates = useAtomValue(latestGameStatesAtom); const stateA = latestGameStates[`${playerProfileA.id}`]; const codeA = stateA?.code ?? ""; const scoreA = stateA?.score ?? null; const statusA = stateA?.status ?? "none"; const stateB = latestGameStates[`${playerProfileB.id}`]; const codeB = stateB?.code ?? ""; const scoreB = stateB?.score ?? null; const statusB = stateB?.status ?? "none"; const codeSizeA = calcCodeSize(codeA); const codeSizeB = calcCodeSize(codeB); const topBg = gameResult ? gameResult === "winA" ? "bg-orange-400" : gameResult === "winB" ? "bg-purple-400" : "bg-sky-600" : "bg-sky-600"; return (