diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-21 09:23:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-21 09:50:56 +0900 |
| commit | 80ee46c81dda5331f66aa401435447f22ff187cd (patch) | |
| tree | 10830e1e882808b0ecbebd2164fd805160558ca2 /frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx | |
| parent | d379ce3309e5241359b9849fd0170909a140169c (diff) | |
| download | iosdc-japan-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.tar.gz iosdc-japan-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.tar.zst iosdc-japan-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.zip | |
feat(frontend): show game result in 1v1 watch
Diffstat (limited to 'frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx')
| -rw-r--r-- | frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx index 63ad5f3..168f5d9 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx @@ -1,6 +1,8 @@ import { useAtomValue } from "jotai"; import { calcCodeSize, + checkGameResultKind, + gameStateKindAtom, gamingLeftTimeSecondsAtom, latestGameStatesAtom, } from "../../states/watch"; @@ -23,7 +25,6 @@ type Props = { problemTitle: string; problemDescription: string; sampleCode: string; - gameResult: "winA" | "winB" | "draw" | null; }; export default function GolfWatchAppGaming1v1({ @@ -33,16 +34,16 @@ export default function GolfWatchAppGaming1v1({ problemTitle, problemDescription, sampleCode, - gameResult, }: Props) { + const gameStateKind = useAtomValue(gameStateKindAtom); const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const latestGameStates = useAtomValue(latestGameStatesAtom); - const stateA = latestGameStates[`${playerProfileA.id}`]; + const stateA = latestGameStates[`${playerProfileA.id}`] ?? null; const codeA = stateA?.code ?? ""; const scoreA = stateA?.score ?? null; const statusA = stateA?.status ?? "none"; - const stateB = latestGameStates[`${playerProfileB.id}`]; + const stateB = latestGameStates[`${playerProfileB.id}`] ?? null; const codeB = stateB?.code ?? ""; const scoreB = stateB?.score ?? null; const statusB = stateB?.status ?? "none"; @@ -50,10 +51,12 @@ export default function GolfWatchAppGaming1v1({ const codeSizeA = calcCodeSize(codeA); const codeSizeB = calcCodeSize(codeB); - const topBg = gameResult - ? gameResult === "winA" + const gameResultKind = checkGameResultKind(gameStateKind, stateA, stateB); + + const topBg = gameResultKind + ? gameResultKind === "winA" ? "bg-orange-400" - : gameResult === "winB" + : gameResultKind === "winB" ? "bg-purple-400" : "bg-sky-600" : "bg-sky-600"; @@ -76,11 +79,11 @@ export default function GolfWatchAppGaming1v1({ </div> <div className="font-bold text-center"> <div className="text-gray-100">{gameDisplayName}</div> - {gameResult ? ( + {gameResultKind ? ( <div className="text-3xl"> - {gameResult === "winA" + {gameResultKind === "winA" ? `勝者 ${playerProfileA.displayName}` - : gameResult === "winB" + : gameResultKind === "winB" ? `勝者 ${playerProfileB.displayName}` : "引き分け"} </div> |
