"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { api } from "./StartGame"; import { GuessMap } from "./GuessMap"; import type { SessionView } from "./Game"; export function Results({ id }: { id: string }) { const [session, setSession] = useState(null), [selected, setSelected] = useState(0), [error, setError] = useState(""); const router = useRouter(); useEffect(() => { api("sessions/" + id) .then((s) => { if (s.round < 5) router.replace("/play/" + id); else setSession(s); }) .catch((e) => setError(e.message)); }, [id, router]); if (error) return

{error}

; if (!session) return

Unpacking your expedition…

; const total = session.rounds.reduce((n, r) => n + (r.result?.score || 0), 0); const current = session.rounds[selected].result; return ( <> EXPEDITION COMPLETE · {session.difficulty.toUpperCase()}

Every guess is a story.

{session.name} · Here’s where your instincts took you.

{total.toLocaleString()} / 25,000

Your five-round journey

{session.rounds.map((r, i) => ( ))}
{session.rounds.map((r, i) => ( ))}
ROUND DISTANCE POINTS
{i + 1} {r.result?.timedOut ? "Timed out" : `${Math.round(r.result?.distance || 0)} blocks`} {r.result?.score.toLocaleString()}
Another adventure → My expeditions
); }