feat(game): auto-save multiplayer game results when round ends

This commit is contained in:
jessy-david-dev
2026-04-10 16:40:33 +02:00
parent 3fd3f01637
commit 9e13d83251
+18
View File
@@ -110,6 +110,24 @@ export default function WikiRush() {
});
}, [solo.phase]); // eslint-disable-line react-hooks/exhaustive-deps
// Sauvegarder partie multi quand les résultats arrivent
useEffect(() => {
const room = multi.room;
const pid = multi.playerId;
if (!room || !pid || room.phase !== "results") return;
const me = room.players.find((p) => p.id === pid);
if (!me) return;
saveGame({
mode: "multi",
startArticle: room.startArticle,
targetArticle: room.targetArticle,
path: multi.history,
clicks: multi.clicks,
timeSeconds: multi.elapsed,
won: room.roundWinner === pid,
});
}, [multi.room?.phase]); // eslint-disable-line react-hooks/exhaustive-deps
// ---- Actions home ----
async function handleCreateRoom() {