aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app')
-rw-r--r--frontend/app/.server/api/schema.d.ts2
-rw-r--r--frontend/app/components/GolfPlayApp.client.tsx6
-rw-r--r--frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx5
3 files changed, 10 insertions, 3 deletions
diff --git a/frontend/app/.server/api/schema.d.ts b/frontend/app/.server/api/schema.d.ts
index 62badcf..6981dea 100644
--- a/frontend/app/.server/api/schema.d.ts
+++ b/frontend/app/.server/api/schema.d.ts
@@ -150,7 +150,7 @@ export interface components {
* @example success
* @enum {string}
*/
- status: "success";
+ status: "success" | "failure" | "timeout" | "internal_error" | "compile_error" | "wrong_answer";
/** @example 100 */
score: number | null;
};
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<number | null>(null);
+ const [lastExecStatus, setLastExecStatus] = useState<string | null>(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") {
diff --git a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
index 9fddb01..1a08b98 100644
--- a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
+++ b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
@@ -5,6 +5,7 @@ type Props = {
onCodeChange: (code: string) => void;
onCodeSubmit: (code: string) => void;
currentScore: number | null;
+ lastExecStatus: string | null;
};
export default function GolfPlayAppGaming({
@@ -12,6 +13,7 @@ export default function GolfPlayAppGaming({
onCodeChange,
onCodeSubmit,
currentScore,
+ lastExecStatus,
}: Props) {
const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -36,7 +38,8 @@ export default function GolfPlayAppGaming({
<div className="mb-4 mt-auto">
<div className="mb-2">
<div className="font-semibold text-green-500">
- Score: {currentScore == null ? "-" : `${currentScore}`}
+ Score: {currentScore == null ? "-" : `${currentScore}`} (
+ {lastExecStatus})
</div>
</div>
<button