From dc16e903999af89d87364ad6619e7c8b41301da4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 5 Aug 2024 05:35:37 +0900 Subject: feat: show execution result in play page --- frontend/app/components/GolfPlayApp.client.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'frontend/app/components/GolfPlayApp.client.tsx') diff --git a/frontend/app/components/GolfPlayApp.client.tsx b/frontend/app/components/GolfPlayApp.client.tsx index 80e7182..911fae0 100644 --- a/frontend/app/components/GolfPlayApp.client.tsx +++ b/frontend/app/components/GolfPlayApp.client.tsx @@ -73,6 +73,8 @@ export default function GolfPlayApp({ const [currentScore, setCurrentScore] = useState(null); + const [lastExecStatus, setLastExecStatus] = useState(null); + const onCodeChange = useDebouncedCallback((code: string) => { console.log("player:c2s:code"); sendJsonMessage({ @@ -121,13 +123,14 @@ export default function GolfPlayApp({ setGameState("starting"); } } else if (lastJsonMessage.type === "player:s2c:execresult") { - const { score } = lastJsonMessage.data; + const { status, score } = lastJsonMessage.data; if ( score !== null && (currentScore === null || score < currentScore) ) { setCurrentScore(score); } + setLastExecStatus(status); } } else { setGameState("waiting"); @@ -150,6 +153,7 @@ export default function GolfPlayApp({ onCodeChange={onCodeChange} onCodeSubmit={onCodeSubmit} currentScore={currentScore} + lastExecStatus={lastExecStatus} /> ); } else if (gameState === "finished") { -- cgit v1.2.3-70-g09d2