2026-04-10 16:44:24 +02:00
|
|
|
export function fmt(s: number): string {
|
|
|
|
|
const m = Math.floor(s / 60);
|
|
|
|
|
const sec = Math.floor(s % 60);
|
|
|
|
|
return `${m}:${String(sec).padStart(2, "0")}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function saveGame(data: {
|
|
|
|
|
mode: string;
|
|
|
|
|
startArticle: string;
|
|
|
|
|
targetArticle: string;
|
|
|
|
|
path: string[];
|
|
|
|
|
clicks: number;
|
|
|
|
|
timeSeconds: number;
|
|
|
|
|
won: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
try {
|
|
|
|
|
await fetch("/api/games", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify(data),
|
|
|
|
|
});
|
2026-04-11 22:25:34 +02:00
|
|
|
} catch {
|
|
|
|
|
/* silencieux - pas de compte ou hors ligne */
|
|
|
|
|
}
|
2026-04-10 16:44:24 +02:00
|
|
|
}
|