Bilan du match : page, courbe des chances de gagner le match, listes et accès

Page #/matchs/<id>/bilan (en-tête, courbe continue lue au doigt, partie par
partie, jeu, videau, moment décisif, décision à revoir, export SGF, prompt).
Un match tient en une ligne dans Mes parties et la progression ; le bilan et
l'analyse d'une partie de match y renvoient. Test navigateur d'un match en
5 points remonté de 0–4. ADR 0007 et 0013 amendés, plan clos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-13 00:21:24 +01:00
co-authored by Claude Opus 5.5
parent 68664dc3f7
commit 3b0107af1b
26 changed files with 2273 additions and 97 deletions
+34 -6
View File
@@ -10,7 +10,7 @@ import { runAnalysis } from "./domain/analysis/game-analysis.js";
import { Game } from "./domain/game/game.js";
import { linkOf, readPosition } from "./domain/game/position-link.js";
import { levelOf } from "./domain/game/saved-game.js";
import { exportSgf } from "./domain/game/sgf.js";
import { exportMatchSgf, exportSgf } from "./domain/game/sgf.js";
import {
illustratedMove,
MovePractice,
@@ -18,7 +18,12 @@ import {
tutorialBoard,
} from "./domain/learning/tutorial.js";
import { positionBefore } from "./domain/prompts/position.js";
import { conceptExample, exercisesPosition, summaryPosition } from "./domain/prompts/prompts.js";
import {
conceptExample,
exercisesPosition,
matchPosition,
summaryPosition,
} from "./domain/prompts/prompts.js";
import { createWasmEngine } from "./engine/wasm-engine.js";
import { type EngineWorker, startEngineWorker } from "./engine/worker-run.js";
import { createGameSession } from "./storage/game-session.js";
@@ -129,17 +134,28 @@ startApp({
if (game === null) {
throw new Error("partie introuvable");
}
const started = new Date(game.summary.startedAt);
const two = (n: number) => String(n).padStart(2, "0");
const date = `${started.getFullYear()}-${two(started.getMonth() + 1)}-${two(started.getDate())}`;
const { date, time } = fileDate(game.summary.startedAt);
const text = await exportSgf(engine, game.journal, {
playerName: "Vous",
computerName: "Ustagammon",
date,
});
const time = `${two(started.getHours())}${two(started.getMinutes())}`;
return { fileName: `ustagammon-${date}-${time}.sgf`, text };
},
exportMatchSgf: async (ids) => {
const games = await Promise.all(ids.map((id) => storage().library.load(id)));
const first = games[0];
if (first === undefined || games.some((g) => g === null)) {
throw new Error("partie du match introuvable");
}
const { date, time } = fileDate(first?.summary.startedAt ?? 0);
const text = await exportMatchSgf(
engine,
games.flatMap((g) => (g === null ? [] : [g.journal])),
{ playerName: "Vous", computerName: "Ustagammon", date },
);
return { fileName: `ustagammon-match-${date}-${time}.sgf`, text };
},
},
cachedBoard: () => settings.loadBoard(),
saveBoard: (board) => settings.saveBoard(board),
@@ -181,11 +197,23 @@ startApp({
summary: (journal) => summaryPosition(engine, journal),
concept: (journal) => conceptExample(engine, journal, ANALYSIS_PLY),
exercises: (journals) => exercisesPosition(engine, journals),
match: (summary) => matchPosition(engine, summary),
},
startUpdates: (onAvailable) =>
startUpdates(new URL("../sw.js", import.meta.url), worker.ready, onAvailable),
});
/** La date et l'heure d'un début de partie, pour un nom de fichier SGF :
* AAAA-MM-JJ et HHMM. */
function fileDate(time: number): { readonly date: string; readonly time: string } {
const started = new Date(time);
const two = (n: number) => String(n).padStart(2, "0");
return {
date: `${started.getFullYear()}-${two(started.getMonth() + 1)}-${two(started.getDate())}`,
time: `${two(started.getHours())}${two(started.getMinutes())}`,
};
}
/** La valeur, ou undefined si l'obtenir lève une exception. */
function attempt<T>(get: () => T): T | undefined {
try {