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:
co-authored by
Claude Opus 5.5
parent
68664dc3f7
commit
3b0107af1b
@@ -45,11 +45,8 @@ export interface MatchGame {
|
||||
readonly journal: GameJournal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Un match joué : ses parties dans l'ordre, et où il en est.
|
||||
*
|
||||
* Glossaire : docs/glossaire/match.md
|
||||
*/
|
||||
/** Un match joué : ses parties dans l'ordre, et où il en est (voir
|
||||
* docs/glossaire/match.md). */
|
||||
export interface PlayedMatch {
|
||||
/** L'identifiant du match (version 3 des événements) ; pour un match
|
||||
* d'avant, celui de sa première partie. */
|
||||
@@ -251,9 +248,8 @@ export interface MatchGameRow {
|
||||
/**
|
||||
* Un point de la courbe des chances de gagner le match : le début du
|
||||
* match, puis chaque tour de chaque partie. La fin d'une partie est le
|
||||
* début de la suivante : la courbe est continue d'une partie à l'autre.
|
||||
*
|
||||
* Glossaire : docs/glossaire/chances-de-gagner-le-match.md
|
||||
* début de la suivante : la courbe est continue d'une partie à l'autre
|
||||
* (voir docs/glossaire/chances-de-gagner-le-match.md).
|
||||
*/
|
||||
export interface MatchCurvePoint {
|
||||
readonly game: number;
|
||||
@@ -299,7 +295,8 @@ export interface MatchSummary {
|
||||
/** La chance de vos dés sur tout le match. */
|
||||
readonly luck: LuckSummary;
|
||||
/** Vos décisions de videau comptées (comme le taux d'erreur du
|
||||
* videau), et celles qui diffèrent du moteur, dans l'ordre du bilan. */
|
||||
* videau), et celles qui diffèrent du moteur d'au moins
|
||||
* CUBE_LOSS_SHOWN, dans l'ordre du bilan. */
|
||||
readonly cubeDecisions: number;
|
||||
readonly cubeErrors: readonly CubeError[];
|
||||
readonly decisive: DecisiveMoment | null;
|
||||
@@ -417,7 +414,7 @@ export function summarizeMatch(match: PlayedMatch): MatchSummary {
|
||||
for (const kind of CUBE_ERROR_KINDS) {
|
||||
for (const d of decisions) {
|
||||
const a = d.advice;
|
||||
if (a.kind === "cube" && a.equityLoss < 0 && CUBE_KIND[a.action] === kind) {
|
||||
if (a.kind === "cube" && differs(d) && CUBE_KIND[a.action] === kind) {
|
||||
cubeErrors.push({ ...d, kind });
|
||||
}
|
||||
}
|
||||
@@ -459,6 +456,17 @@ export function summarizeMatch(match: PlayedMatch): MatchSummary {
|
||||
};
|
||||
}
|
||||
|
||||
/** Plus petite perte de chances de gagner le match qui fait d'une décision
|
||||
* de videau une décision « autre que celle du moteur » : 0,05 %, ce qui
|
||||
* s'écrit au moins « −0,1 % ». En dessous, gnubg compte un écart, mais la
|
||||
* ligne dirait « 0,0 % » : elle n'apprendrait rien au joueur. */
|
||||
export const CUBE_LOSS_SHOWN = 0.0005;
|
||||
|
||||
/** La décision diffère de celle du moteur, d'une perte qui se voit. */
|
||||
function differs(d: MatchDecision): boolean {
|
||||
return d.advice.equityLoss < 0 && (d.loss === null || d.loss <= -CUBE_LOSS_SHOWN);
|
||||
}
|
||||
|
||||
/** Le tour qui a fait le plus varier les chances de gagner le match, entre
|
||||
* deux points analysés qui se suivent (le premier en cas d'égalité). */
|
||||
function decisiveMoment(curve: readonly MatchCurvePoint[]): DecisiveMoment | null {
|
||||
|
||||
+34
-6
@@ -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 {
|
||||
|
||||
@@ -33,6 +33,7 @@ import { formatHalfMoves } from "../domain/game/position.js";
|
||||
import { VERDICT_ICONS } from "./advice-view.js";
|
||||
import { askAiLink } from "./ask-ai.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { MATCH_SUMMARY_TEXTS } from "./match-summary-texts.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { boardSvg, createMovePlayer, drawSteps, type MovePlayer } from "./move-board.js";
|
||||
import { percent, REVIEW_TEXTS, signed } from "./review-texts.js";
|
||||
@@ -47,6 +48,19 @@ export interface AnalysisData {
|
||||
/** Le coup choisi (null : le coup à revoir, ou le premier). */
|
||||
readonly turn: number | null;
|
||||
readonly phrases: MasterPhrases | null;
|
||||
/** Une partie de match (étape 1l) : sa place dans le match, le score
|
||||
* au début, et les parties d'avant et d'après (null : partie libre). */
|
||||
readonly match: AnalysisMatch | null;
|
||||
}
|
||||
|
||||
/** La place d'une partie dans son match, pour l'en-tête de l'analyse. */
|
||||
export interface AnalysisMatch {
|
||||
readonly number: number;
|
||||
readonly total: number;
|
||||
/** « 0–2 », vous – l'ordinateur. */
|
||||
readonly score: string;
|
||||
readonly previous: string | null;
|
||||
readonly next: string | null;
|
||||
}
|
||||
|
||||
export interface AnalysisViewOptions {
|
||||
@@ -144,6 +158,29 @@ export function createAnalysisView(options: AnalysisViewOptions): AnalysisView {
|
||||
className: "analysis-title",
|
||||
text: REVIEW_TEXTS.analysisTitle,
|
||||
});
|
||||
// Une partie de match (étape 1l) : « ‹ Partie 2 sur 5 · 0–2 › », pour
|
||||
// passer d'une partie à l'autre. La courbe reste celle de la partie.
|
||||
const matchNav = element(section, "nav", {
|
||||
id: "analysis-match",
|
||||
className: "viewer-nav analysis-match",
|
||||
});
|
||||
matchNav.hidden = true;
|
||||
const previousGame = element(matchNav, "a", {
|
||||
id: "analysis-previous-game",
|
||||
className: "icon-button viewer-step",
|
||||
});
|
||||
previousGame.append(icon("chevron"));
|
||||
previousGame.setAttribute("aria-label", MATCH_SUMMARY_TEXTS.previousGame);
|
||||
const matchTitle = element(matchNav, "p", {
|
||||
id: "analysis-match-title",
|
||||
className: "viewer-turn",
|
||||
});
|
||||
const nextGame = element(matchNav, "a", {
|
||||
id: "analysis-next-game",
|
||||
className: "icon-button viewer-step",
|
||||
});
|
||||
nextGame.append(icon("chevron"));
|
||||
nextGame.setAttribute("aria-label", MATCH_SUMMARY_TEXTS.nextGame);
|
||||
const message = element(section, "p", {
|
||||
id: "analysis-message",
|
||||
className: "analysis-message",
|
||||
@@ -661,6 +698,27 @@ export function createAnalysisView(options: AnalysisViewOptions): AnalysisView {
|
||||
numbers.hidden = true;
|
||||
return;
|
||||
}
|
||||
const match = next.match;
|
||||
matchNav.hidden = match === null;
|
||||
if (match !== null) {
|
||||
matchTitle.textContent = MATCH_SUMMARY_TEXTS.analysisHeader(
|
||||
match.number,
|
||||
match.total,
|
||||
match.score,
|
||||
);
|
||||
for (const [link, id] of [
|
||||
[previousGame, match.previous],
|
||||
[nextGame, match.next],
|
||||
] as const) {
|
||||
if (id === null) {
|
||||
link.removeAttribute("href");
|
||||
link.setAttribute("aria-disabled", "true");
|
||||
} else {
|
||||
link.href = routeHash({ screen: "analysis", game: id, turn: null });
|
||||
link.removeAttribute("aria-disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
turns = gameTurns(next.journal);
|
||||
curve = chanceCurve(next.journal);
|
||||
const summary = summarizeAnalysis(next.journal);
|
||||
|
||||
+317
-24
@@ -28,6 +28,13 @@ import {
|
||||
readyForSummary,
|
||||
summarizeAnalysis,
|
||||
} from "../domain/analysis/game-analysis.js";
|
||||
import {
|
||||
groupMatches,
|
||||
type MatchGame,
|
||||
matchOfGame,
|
||||
type PlayedMatch,
|
||||
summarizeMatch,
|
||||
} from "../domain/analysis/match-analysis.js";
|
||||
import {
|
||||
type MasterPhrases,
|
||||
masterLine,
|
||||
@@ -42,13 +49,13 @@ import {
|
||||
import type { Advice } from "../domain/game/advice.js";
|
||||
import type { Cube } from "../domain/game/cube.js";
|
||||
import type { MoveNotation } from "../domain/game/engine.js";
|
||||
import type { GameJournal } from "../domain/game/events.js";
|
||||
import { currentLine, EMPTY_JOURNAL, type GameJournal } from "../domain/game/events.js";
|
||||
import type { Game, MoveSteps, NewGame, SideBoards } from "../domain/game/game.js";
|
||||
import type { HalfMove } from "../domain/game/position.js";
|
||||
import { type PositionLink, type SharedPosition, setupOf } from "../domain/game/position-link.js";
|
||||
import type { SavedGameSummary } from "../domain/game/saved-game.js";
|
||||
import { otherSide, type Side } from "../domain/game/side.js";
|
||||
import type { GameState } from "../domain/game/state.js";
|
||||
import { type GameState, replay } from "../domain/game/state.js";
|
||||
import {
|
||||
finishedLessons,
|
||||
LESSON_END,
|
||||
@@ -61,7 +68,7 @@ import {
|
||||
import { ADVICE_TEXTS } from "./advice-texts.js";
|
||||
import { type Analyse, createAdviceTracker } from "./advice-tracker.js";
|
||||
import { createAdviceView, VERDICT_ICONS } from "./advice-view.js";
|
||||
import { createAnalysisView } from "./analysis-view.js";
|
||||
import { type AnalysisMatch, createAnalysisView } from "./analysis-view.js";
|
||||
import { createPromptView, type PromptResult } from "./ask-ai.js";
|
||||
import { ASK_AI_TEXTS } from "./ask-ai-texts.js";
|
||||
import {
|
||||
@@ -86,7 +93,7 @@ import {
|
||||
slideChecker,
|
||||
} from "./board-view.js";
|
||||
import { GAMES_TEXTS } from "./games-texts.js";
|
||||
import { createGamesView, type GamesView } from "./games-view.js";
|
||||
import { createGamesView, downloadFile, type GamesView } from "./games-view.js";
|
||||
import { boardGeometry, type Geometry, type Layout, PORTRAIT_ASPECT } from "./geometry.js";
|
||||
import { createHaptics, type Vibrate } from "./haptics.js";
|
||||
import { createHelpView, loadGlossaryEntry } from "./help.js";
|
||||
@@ -100,6 +107,9 @@ import { LESSON_COUNT, type Lesson, lessonSource, outlineOf, parseLesson } from
|
||||
import { LESSON_TEXTS } from "./lesson-texts.js";
|
||||
import { lessonCards, nextLessonCard } from "./lessons-model.js";
|
||||
import { createLessonsView } from "./lessons-view.js";
|
||||
import { matchLineOf } from "./match-line.js";
|
||||
import { MATCH_SUMMARY_TEXTS, matchScoreText } from "./match-summary-texts.js";
|
||||
import { createMatchSummaryView } from "./match-summary-view.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { replacingLink, startNavigation } from "./navigation.js";
|
||||
import { createNewGameView } from "./new-game-view.js";
|
||||
@@ -222,6 +232,11 @@ export interface SavedGamesAccess {
|
||||
readonly saveAnalyses: (id: string, journal: GameJournal) => void;
|
||||
readonly remove: (id: string) => Promise<void>;
|
||||
readonly exportSgf: (id: string) => Promise<{ fileName: string; text: string }>;
|
||||
/** Le fichier SGF d'un match entier, ses parties dans l'ordre (étape
|
||||
* 1l). */
|
||||
readonly exportMatchSgf: (
|
||||
ids: readonly string[],
|
||||
) => Promise<{ fileName: string; text: string }>;
|
||||
}
|
||||
|
||||
/** Ce que la vue d'une position demande au domaine et au moteur. */
|
||||
@@ -289,6 +304,7 @@ export function startApp(options: AppOptions): void {
|
||||
promptVeil: byId("prompt-veil"),
|
||||
analysis: byId("analysis"),
|
||||
progression: byId("progression"),
|
||||
matchSummary: byId("match-summary"),
|
||||
menuAdvice: byId<HTMLButtonElement>("menu-advice"),
|
||||
prompt: byId("prompt"),
|
||||
strips: { computer: stripOf("strip-computer"), player: stripOf("strip-player") },
|
||||
@@ -725,7 +741,7 @@ export function startApp(options: AppOptions): void {
|
||||
show(ui.take, doubled);
|
||||
show(ui.drop, doubled);
|
||||
show(ui.again, over && panelDismissed);
|
||||
ui.again.textContent = afterGameLabel(game);
|
||||
ui.again.textContent = afterGameLabel(game, false);
|
||||
show(ui.replay, shownMove !== null);
|
||||
// Le coup de l'ordinateur montré : sa position se copie en lien.
|
||||
show(ui.copyLink, shownMove !== null && currentLink !== null);
|
||||
@@ -947,7 +963,7 @@ export function startApp(options: AppOptions): void {
|
||||
ui.panelText.textContent = end.title;
|
||||
detail.textContent = end.detail;
|
||||
ui.panelSecondary.textContent = TEXTS.reviewGame;
|
||||
ui.panelPrimary.textContent = afterGameLabel(g);
|
||||
ui.panelPrimary.textContent = afterGameLabel(g, true);
|
||||
ui.panelSettings.hidden = false;
|
||||
ui.panelVeil.dataset.kind = "over";
|
||||
} else if (ask) {
|
||||
@@ -1254,10 +1270,19 @@ export function startApp(options: AppOptions): void {
|
||||
/** Après une partie finie : la partie suivante du match s'il continue,
|
||||
* sinon « Rejouer », une nouvelle partie aux mêmes réglages (un match de
|
||||
* même longueur après un match), tout de suite. */
|
||||
function afterGame(): void {
|
||||
if (game !== null) {
|
||||
newGame(game.nextGame ?? game.rematch);
|
||||
function afterGame(toMatchSummary: boolean): void {
|
||||
if (game === null) {
|
||||
return;
|
||||
}
|
||||
// Le match fini : le panneau de fin de partie et le bilan de la
|
||||
// dernière partie mènent au bilan du match (étape 1l) ; « Rejouer »
|
||||
// reste sous le plateau.
|
||||
const finished = toMatchSummary ? matchSummaryIdOf(game) : null;
|
||||
if (finished !== null) {
|
||||
navigation.go(routeHash({ screen: "matchSummary", match: finished }));
|
||||
return;
|
||||
}
|
||||
newGame(game.nextGame ?? game.rematch);
|
||||
}
|
||||
|
||||
function showBanner(journal: GameJournal): void {
|
||||
@@ -1332,6 +1357,12 @@ export function startApp(options: AppOptions): void {
|
||||
remove: options.games.remove,
|
||||
exportSgf: options.games.exportSgf,
|
||||
onClose: () => leaveSheet(),
|
||||
matches: async () => (await loadMatches()).map(matchLineOf),
|
||||
resumeMatch: (match) => {
|
||||
if (!busy) {
|
||||
void resumeMatch(match);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const helpView = createHelpView(ui.helpContent, ui.helpTabs);
|
||||
@@ -1351,11 +1382,13 @@ export function startApp(options: AppOptions): void {
|
||||
// moteur à part ; la partie regardée (bilan, analyse) et son journal.
|
||||
const reviewRunner = createReviewRunner(options.analyseGame);
|
||||
let reviewed: { id: string; journal: GameJournal; game: Game } | null = null;
|
||||
// Le match de la partie regardée (étape 1l), lu à son ouverture.
|
||||
let reviewedMatch: { id: string; match: PlayedMatch; number: number } | null = null;
|
||||
|
||||
const summaryView = createSummaryView({
|
||||
veil: ui.summaryVeil,
|
||||
close: () => leaveSheet(),
|
||||
again: () => afterGame(),
|
||||
again: () => afterGame(true),
|
||||
});
|
||||
|
||||
const analysisView = createAnalysisView({
|
||||
@@ -1474,6 +1507,16 @@ export function startApp(options: AppOptions): void {
|
||||
}
|
||||
case "glossary":
|
||||
return promptSource.concept(route.term ?? "", game?.journal ?? null);
|
||||
case "matchSummary": {
|
||||
const match = await loadMatch(route.match);
|
||||
if (match === null) {
|
||||
return { message: ASK_AI_TEXTS.missingMatch };
|
||||
}
|
||||
const summary = summarizeMatch(match);
|
||||
return summary.ready
|
||||
? promptSource.match(summary)
|
||||
: { message: ASK_AI_TEXTS.matchNotReady };
|
||||
}
|
||||
case "progression": {
|
||||
// Les parties analysées de l'écran, de la plus ancienne à la
|
||||
// plus récente : rien n'est analysé pour le prompt.
|
||||
@@ -1513,6 +1556,10 @@ export function startApp(options: AppOptions): void {
|
||||
}
|
||||
if (reviewed !== null) {
|
||||
review(reviewed.id, reviewed.journal);
|
||||
if (reviewedMatch?.id !== id) {
|
||||
const found = await matchOf(id, reviewed.journal).catch(() => null);
|
||||
reviewedMatch = found === null ? null : { id, ...found };
|
||||
}
|
||||
}
|
||||
showReview(id, false);
|
||||
}
|
||||
@@ -1538,12 +1585,17 @@ export function startApp(options: AppOptions): void {
|
||||
reviewed = { ...reviewed, journal: live?.journal ?? analysed };
|
||||
}
|
||||
progressionAnalysed(id, live?.journal ?? analysed);
|
||||
matchAnalysed(id, live?.journal ?? analysed);
|
||||
showReview(id, false);
|
||||
render();
|
||||
},
|
||||
// L'écran de progression attend peut-être cette analyse pour
|
||||
// lancer celle de la partie suivante.
|
||||
() => reviewProgression(),
|
||||
// L'écran de progression ou le bilan du match attendent
|
||||
// peut-être cette analyse pour lancer celle de la partie
|
||||
// suivante.
|
||||
() => {
|
||||
reviewProgression();
|
||||
reviewMatch();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1553,8 +1605,17 @@ export function startApp(options: AppOptions): void {
|
||||
// relues à chaque visite, avec leurs analyses rangées. Celles qui n'en
|
||||
// ont pas encore sont analysées en arrière-plan, une à une, la plus
|
||||
// récente d'abord ; rien n'est recalculé pour les autres.
|
||||
const progressionView = createProgressionView({ section: ui.progression });
|
||||
const progressionView = createProgressionView({
|
||||
section: ui.progression,
|
||||
resumeMatch: (match) => {
|
||||
if (!busy) {
|
||||
void resumeMatch(match);
|
||||
}
|
||||
},
|
||||
});
|
||||
let progressionGames: FinishedGame[] | null = null;
|
||||
// Les matchs, pour leurs lignes (étape 1l).
|
||||
let progressionMatches: PlayedMatch[] = [];
|
||||
// Chaque lecture a son numéro : une lecture dépassée n'est pas dessinée.
|
||||
let progressionRequest = 0;
|
||||
// Les parties dont l'analyse a été lancée depuis l'ouverture de l'écran.
|
||||
@@ -1596,13 +1657,14 @@ export function startApp(options: AppOptions): void {
|
||||
progressionGames = null;
|
||||
renderProgression();
|
||||
options.engineReady
|
||||
.then(() => loadProgression())
|
||||
.then(() => Promise.all([loadProgression(), loadMatches()]))
|
||||
.then(
|
||||
(games) => {
|
||||
([games, matches]) => {
|
||||
if (request !== progressionRequest) {
|
||||
return;
|
||||
}
|
||||
progressionGames = games;
|
||||
progressionMatches = matches;
|
||||
renderProgression();
|
||||
reviewProgression();
|
||||
},
|
||||
@@ -1627,7 +1689,11 @@ export function startApp(options: AppOptions): void {
|
||||
progressionView.render(
|
||||
progressionGames === null
|
||||
? null
|
||||
: { entries: progressionEntries(progressionGames), phrases },
|
||||
: {
|
||||
entries: progressionEntries(progressionGames),
|
||||
matches: progressionMatches.map(matchLineOf),
|
||||
phrases,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1636,6 +1702,11 @@ export function startApp(options: AppOptions): void {
|
||||
function progressionAnalysed(id: string, journal: GameJournal): void {
|
||||
if (progressionGames?.some((g) => g.id === id)) {
|
||||
progressionGames = progressionGames.map((g) => (g.id === id ? { ...g, journal } : g));
|
||||
progressionMatches = progressionMatches.map((m) =>
|
||||
m.games.some((g) => g.id === id)
|
||||
? { ...m, games: m.games.map((g) => (g.id === id ? { ...g, journal } : g)) }
|
||||
: m,
|
||||
);
|
||||
renderProgression();
|
||||
}
|
||||
}
|
||||
@@ -1662,6 +1733,173 @@ export function startApp(options: AppOptions): void {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------- Bilan du match (1l)
|
||||
|
||||
// L'écran #/matchs/<id>/bilan : les parties du match, relues à chaque
|
||||
// visite avec leurs analyses rangées ; celles qui n'en ont pas assez
|
||||
// sont analysées en arrière-plan, une à une.
|
||||
const matchSummaryView = createMatchSummaryView({
|
||||
section: ui.matchSummary,
|
||||
stepsBefore: async (gameId, advice) => {
|
||||
const viewed = liveGame(gameId) ?? (await options.games.view(gameId));
|
||||
return viewed === null
|
||||
? null
|
||||
: viewed.stepsBefore(
|
||||
advice.eventId,
|
||||
"player",
|
||||
advice.kind === "move" ? advice.played.halfMoves : [],
|
||||
);
|
||||
},
|
||||
exportSgf: async (summary) => {
|
||||
downloadFile(await options.games.exportMatchSgf(summary.match.games.map((g) => g.id)));
|
||||
},
|
||||
resume: (summary) => void resumeMatch(summary.match),
|
||||
vibrate: () => haptic("curveGame"),
|
||||
});
|
||||
let shownMatch: PlayedMatch | null = null;
|
||||
let matchShownId: string | null = null;
|
||||
let matchRequest = 0;
|
||||
// Les parties dont l'analyse a été lancée depuis l'ouverture de l'écran.
|
||||
const matchTried = new Set<string>();
|
||||
|
||||
/** Les parties de match enregistrées, avec leur journal (celui de la
|
||||
* partie à l'écran, s'il s'agit d'elle), réunies en matchs. */
|
||||
async function loadMatches(): Promise<PlayedMatch[]> {
|
||||
const list = await options.games.list();
|
||||
const games = await Promise.all(
|
||||
list
|
||||
.filter((summary) => summary.match !== undefined)
|
||||
.map(async (summary): Promise<MatchGame | null> => {
|
||||
const journal =
|
||||
liveGame(summary.id)?.journal ?? (await options.games.journal(summary.id));
|
||||
return journal === null
|
||||
? null
|
||||
: {
|
||||
id: summary.id,
|
||||
startedAt: summary.startedAt,
|
||||
updatedAt: summary.updatedAt,
|
||||
journal,
|
||||
};
|
||||
}),
|
||||
);
|
||||
return groupMatches(games.filter((g): g is MatchGame => g !== null)).matches;
|
||||
}
|
||||
|
||||
/** Un match par son identifiant (null s'il n'existe pas). */
|
||||
async function loadMatch(id: string): Promise<PlayedMatch | null> {
|
||||
if (shownMatch?.id === id) {
|
||||
return shownMatch;
|
||||
}
|
||||
return (await loadMatches()).find((m) => m.id === id) ?? null;
|
||||
}
|
||||
|
||||
/** Le match d'une partie et sa place dans le match (null : partie
|
||||
* libre, ou partie qu'on ne sait rattacher à aucun match). */
|
||||
async function matchOf(
|
||||
gameId: string,
|
||||
journal: GameJournal,
|
||||
): Promise<{ match: PlayedMatch; number: number } | null> {
|
||||
const start = journal.events[0];
|
||||
if (start?.type !== "GameStarted" || start.match === undefined) {
|
||||
return null;
|
||||
}
|
||||
return matchOfGame(await loadMatches(), gameId);
|
||||
}
|
||||
|
||||
function showMatchSummary(id: string): void {
|
||||
const request = ++matchRequest;
|
||||
matchShownId = id;
|
||||
matchTried.clear();
|
||||
shownMatch = null;
|
||||
matchSummaryView.show(null);
|
||||
options.engineReady
|
||||
.then(() => loadMatches())
|
||||
.then(
|
||||
(matches) => {
|
||||
if (request !== matchRequest) {
|
||||
return;
|
||||
}
|
||||
shownMatch = matches.find((m) => m.id === id) ?? null;
|
||||
if (shownMatch === null) {
|
||||
matchSummaryView.show(null, true);
|
||||
return;
|
||||
}
|
||||
renderMatchSummary();
|
||||
reviewMatch();
|
||||
},
|
||||
() => {
|
||||
if (request === matchRequest) {
|
||||
matchSummaryView.show(null, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
if (phrases === null) {
|
||||
phrasesLoading.then(
|
||||
() => renderMatchSummary(),
|
||||
() => undefined,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function renderMatchSummary(): void {
|
||||
if (navigation.route.screen !== "matchSummary" || shownMatch === null) {
|
||||
return;
|
||||
}
|
||||
matchSummaryView.show({ summary: summarizeMatch(shownMatch), phrases });
|
||||
// La feuille du prompt attendait l'analyse : elle se met à jour.
|
||||
const route = navigation.route;
|
||||
if (isAiRoute(route) && promptView.isOpen && !promptView.ready) {
|
||||
showPrompt(route);
|
||||
}
|
||||
}
|
||||
|
||||
/** Une analyse rangée : le match, s'il est à l'écran, se met à jour. */
|
||||
function matchAnalysed(id: string, journal: GameJournal): void {
|
||||
if (shownMatch?.games.some((g) => g.id === id)) {
|
||||
shownMatch = {
|
||||
...shownMatch,
|
||||
games: shownMatch.games.map((g) => (g.id === id ? { ...g, journal } : g)),
|
||||
};
|
||||
renderMatchSummary();
|
||||
}
|
||||
}
|
||||
|
||||
/** Lance l'analyse de la prochaine partie du match à l'écran à qui il
|
||||
* en manque (rien si une analyse tourne déjà : à sa fin, elle rappelle
|
||||
* cette fonction). */
|
||||
function reviewMatch(): void {
|
||||
if (
|
||||
navigation.route.screen !== "matchSummary" ||
|
||||
shownMatch === null ||
|
||||
reviewRunner.running !== null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const next = shownMatch.games.find(
|
||||
(g) => !matchTried.has(g.id) && missingAnalyses(g.journal).length > 0,
|
||||
);
|
||||
if (next !== undefined) {
|
||||
matchTried.add(next.id);
|
||||
review(next.id, next.journal);
|
||||
}
|
||||
}
|
||||
|
||||
/** « Reprendre le match » : sa dernière partie à l'écran ; si elle est
|
||||
* finie, la partie suivante commence. */
|
||||
async function resumeMatch(match: PlayedMatch): Promise<void> {
|
||||
const last = match.games.at(-1);
|
||||
if (last === undefined || busy) {
|
||||
return;
|
||||
}
|
||||
const other = await options.games.open(last.id);
|
||||
hideBanner();
|
||||
navigation.replace("#/");
|
||||
await act(() => showGame(other));
|
||||
if (other.state.phase === "over" && other.nextGame !== null) {
|
||||
afterGame(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** L'analyse en cours d'une partie qui n'est ni regardée ni à l'écran
|
||||
* s'arrête : le moteur à part revient au conseil du maître. */
|
||||
function stopForeignReview(): void {
|
||||
@@ -1696,8 +1934,16 @@ export function startApp(options: AppOptions): void {
|
||||
journal: shown.journal,
|
||||
game: shown.game,
|
||||
end: shown.game.state.phase === "over" ? endParts(shown.game) : null,
|
||||
afterLabel: live === null ? null : afterGameLabel(live),
|
||||
afterLabel: live === null ? null : afterGameLabel(live, true),
|
||||
phrases,
|
||||
match:
|
||||
reviewedMatch?.id === id
|
||||
? {
|
||||
id: reviewedMatch.match.id,
|
||||
number: reviewedMatch.number,
|
||||
length: reviewedMatch.match.length,
|
||||
}
|
||||
: null,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
@@ -1710,11 +1956,30 @@ export function startApp(options: AppOptions): void {
|
||||
game: shown.game,
|
||||
turn: route.turn,
|
||||
phrases,
|
||||
match: analysisMatch(id),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** La place de la partie id dans son match, pour l'en-tête de
|
||||
* l'analyse (null : partie libre). */
|
||||
function analysisMatch(id: string): AnalysisMatch | null {
|
||||
if (reviewedMatch?.id !== id) {
|
||||
return null;
|
||||
}
|
||||
const { match, number } = reviewedMatch;
|
||||
const games = match.games;
|
||||
const start = replay(currentLine(games[number - 1]?.journal ?? EMPTY_JOURNAL)).match;
|
||||
return {
|
||||
number,
|
||||
total: games.length,
|
||||
score: start === null ? "" : matchScoreText(start.score),
|
||||
previous: games[number - 2]?.id ?? null,
|
||||
next: games[number]?.id ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* La partie à l'écran vient de finir : son analyse part en
|
||||
* arrière-plan, et le bilan remplace le panneau de fin de partie dès
|
||||
@@ -1863,7 +2128,7 @@ export function startApp(options: AppOptions): void {
|
||||
selected = null;
|
||||
void settle(true);
|
||||
},
|
||||
again: () => afterGame(),
|
||||
again: () => afterGame(false),
|
||||
// Le menu a son adresse : l'ouvrir, c'est aller à #/menu (comme son
|
||||
// lien) ; le refermer, revenir à l'écran d'avant.
|
||||
menu: () => {
|
||||
@@ -1907,6 +2172,8 @@ export function startApp(options: AppOptions): void {
|
||||
navigation.leave((r) => r.screen === "lessons");
|
||||
} else if (route.screen === "progression") {
|
||||
navigation.leave((r) => r.screen === "progression");
|
||||
} else if (route.screen === "matchSummary") {
|
||||
navigation.leave((r) => r.screen === "matchSummary");
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1983,7 +2250,7 @@ export function startApp(options: AppOptions): void {
|
||||
if (ui.panelVeil.dataset.kind === "doubled") {
|
||||
actions.take();
|
||||
} else {
|
||||
afterGame();
|
||||
afterGame(true);
|
||||
}
|
||||
};
|
||||
// « Changer les réglages » : un lien vers l'écran « Nouvelle partie » ;
|
||||
@@ -2069,6 +2336,7 @@ export function startApp(options: AppOptions): void {
|
||||
const choosing = below.screen === "newGame";
|
||||
const analysing = below.screen === "analysis";
|
||||
const progression = below.screen === "progression";
|
||||
const matchPage = below.screen === "matchSummary";
|
||||
const page =
|
||||
help ||
|
||||
position ||
|
||||
@@ -2078,7 +2346,8 @@ export function startApp(options: AppOptions): void {
|
||||
lesson ||
|
||||
choosing ||
|
||||
analysing ||
|
||||
progression;
|
||||
progression ||
|
||||
matchPage;
|
||||
const wasPage = ui.game.hidden;
|
||||
const wasScreen = ui.root.dataset.screen;
|
||||
ui.game.hidden = page;
|
||||
@@ -2090,6 +2359,7 @@ export function startApp(options: AppOptions): void {
|
||||
ui.lesson.hidden = !lesson;
|
||||
ui.analysis.hidden = !analysing;
|
||||
ui.progression.hidden = !progression;
|
||||
ui.matchSummary.hidden = !matchPage;
|
||||
const opening = choosing && ui.newGameSection.hidden;
|
||||
ui.newGameSection.hidden = !choosing;
|
||||
ui.root.classList.toggle("page-open", page);
|
||||
@@ -2137,6 +2407,15 @@ export function startApp(options: AppOptions): void {
|
||||
if (progression && wasScreen !== "progression") {
|
||||
showProgression();
|
||||
}
|
||||
// Le bilan du match aussi (étape 1l) : ses parties ont pu être
|
||||
// analysées entre-temps.
|
||||
if (below.screen === "matchSummary") {
|
||||
if (wasScreen !== "matchSummary" || matchShownId !== below.match) {
|
||||
showMatchSummary(below.match);
|
||||
}
|
||||
} else {
|
||||
matchShownId = null;
|
||||
}
|
||||
|
||||
// La marche à suivre pour installer : une feuille, comme le menu.
|
||||
if (route.screen === "install" && ui.installVeil.hidden) {
|
||||
@@ -2197,7 +2476,7 @@ export function startApp(options: AppOptions): void {
|
||||
() => openReview(id),
|
||||
() => undefined,
|
||||
);
|
||||
} else if (route.screen !== "progression") {
|
||||
} else if (route.screen !== "progression" && route.screen !== "matchSummary") {
|
||||
stopForeignReview();
|
||||
}
|
||||
if (route.screen === "games") {
|
||||
@@ -3150,11 +3429,25 @@ function bandText(prompt: string, crawford: boolean): string {
|
||||
}
|
||||
|
||||
/** Le bouton qui suit une partie finie : « Partie suivante » dans un match
|
||||
* qui continue, sinon « Rejouer » (mêmes réglages). */
|
||||
function afterGameLabel(game: Game): string {
|
||||
* qui continue, sinon « Rejouer » (mêmes réglages) ; à la fin d'un match,
|
||||
* dans le panneau de fin de partie et le bilan (toMatchSummary), « Bilan du
|
||||
* match » (étape 1l). */
|
||||
function afterGameLabel(game: Game, toMatchSummary: boolean): string {
|
||||
if (toMatchSummary && matchSummaryIdOf(game) !== null) {
|
||||
return MATCH_SUMMARY_TEXTS.seeMatchSummary;
|
||||
}
|
||||
return game.nextGame === null ? MATCH_TEXTS.replay : MATCH_TEXTS.nextGame;
|
||||
}
|
||||
|
||||
/** L'identifiant du match que cette partie vient de finir (null : partie
|
||||
* libre, match qui continue, ou match d'avant l'identifiant). */
|
||||
function matchSummaryIdOf(game: Game): string | null {
|
||||
const state = game.state;
|
||||
return state.phase === "over" && state.matchAfter?.over === true
|
||||
? (state.match?.id ?? null)
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Le résultat d'une partie finie, sur une ligne (consigne, une fois le
|
||||
* panneau fermé). */
|
||||
function resultText(game: Game): string {
|
||||
|
||||
@@ -22,11 +22,15 @@ export const ASK_AI_TEXTS = {
|
||||
analysis: "Analyse",
|
||||
glossary: "Glossaire",
|
||||
progression: "Progression",
|
||||
matchSummary: "Bilan du match",
|
||||
},
|
||||
failed: "Le prompt n'a pas pu être préparé.",
|
||||
noAdvice: "Pas de prompt pour cette décision : le maître ne l'a pas encore analysée.",
|
||||
notReady: "Le maître analyse encore la partie : le prompt sera prêt avec le bilan.",
|
||||
missingGame: "Cette partie n'est plus sur ce téléphone.",
|
||||
missingMatch: "Ce match n'est plus sur ce téléphone.",
|
||||
matchNotReady:
|
||||
"Le maître analyse encore les parties du match : le prompt sera prêt avec le bilan.",
|
||||
missingTerm: "Ce terme n'est pas dans le glossaire.",
|
||||
noAnalysedGame:
|
||||
"Pas encore d'exercices : le maître n'a analysé aucune partie terminée. Ils seront prêts avec la première.",
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
// (#/parties/<id>, ses branches dépliées) : l'écran de jeu l'ouvre et la
|
||||
// ferme selon l'adresse (show, hide), et « Branches » est un vrai lien.
|
||||
|
||||
import type { PlayedMatch } from "../domain/analysis/match-analysis.js";
|
||||
import { branches } from "../domain/game/branches.js";
|
||||
import type { GameJournal } from "../domain/game/events.js";
|
||||
import type { SavedGameSummary } from "../domain/game/saved-game.js";
|
||||
import { GAMES_TEXTS } from "./games-texts.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { type MatchLine, renderMatchLine } from "./match-line.js";
|
||||
import { routeHash } from "./router.js";
|
||||
|
||||
export interface GamesViewOptions {
|
||||
@@ -36,6 +38,11 @@ export interface GamesViewOptions {
|
||||
/** La croix ou le voile touché : quitter la feuille (l'écran de jeu
|
||||
* change d'adresse, puis appelle hide). */
|
||||
readonly onClose: () => void;
|
||||
/** Les matchs (étape 1l) : chacun tient en une ligne, à la place de
|
||||
* ses parties. */
|
||||
readonly matches: () => Promise<readonly MatchLine[]>;
|
||||
/** « Reprendre » sur la ligne d'un match en cours. */
|
||||
readonly resumeMatch: (match: PlayedMatch) => void;
|
||||
}
|
||||
|
||||
export interface GamesView {
|
||||
@@ -93,13 +100,35 @@ export function createGamesView(options: GamesViewOptions): GamesView {
|
||||
};
|
||||
|
||||
async function render(): Promise<void> {
|
||||
const games = await options.list();
|
||||
list.replaceChildren(...games.map((game) => gameItem(game, game.id === options.shownId())));
|
||||
const [games, matches] = await Promise.all([
|
||||
options.list(),
|
||||
options.matches().catch((): readonly MatchLine[] => []),
|
||||
]);
|
||||
// Un match tient en une ligne, à la place de ses parties, à la date
|
||||
// de sa dernière action ; les parties libres gardent la leur.
|
||||
const inMatch = new Set(matches.flatMap((line) => line.match.games.map((g) => g.id)));
|
||||
const items = [
|
||||
...games
|
||||
.filter((game) => !inMatch.has(game.id))
|
||||
.map((game) => ({
|
||||
at: game.updatedAt,
|
||||
item: () => gameItem(game, game.id === options.shownId()),
|
||||
})),
|
||||
...matches.map((line) => ({ at: line.match.updatedAt, item: () => matchItem(line) })),
|
||||
].sort((a, b) => b.at - a.at);
|
||||
list.replaceChildren(...items.map((entry) => entry.item()));
|
||||
if (games.length === 0) {
|
||||
message.textContent = GAMES_TEXTS.empty;
|
||||
}
|
||||
}
|
||||
|
||||
function matchItem(line: MatchLine): HTMLElement {
|
||||
const item = element("li", "games-item games-match");
|
||||
item.dataset.match = line.match.id;
|
||||
renderMatchLine(item, line, () => options.resumeMatch(line.match));
|
||||
return item;
|
||||
}
|
||||
|
||||
function gameItem(game: SavedGameSummary, shown: boolean): HTMLElement {
|
||||
const item = element("li", "games-item");
|
||||
item.dataset.id = game.id;
|
||||
@@ -126,7 +155,7 @@ export function createGamesView(options: GamesViewOptions): GamesView {
|
||||
...(game.status === "over" ? [summaryLink(game.id)] : []),
|
||||
button(
|
||||
GAMES_TEXTS.exportSgf,
|
||||
run(async () => download(await options.exportSgf(game.id))),
|
||||
run(async () => downloadFile(await options.exportSgf(game.id))),
|
||||
"secondary",
|
||||
"export",
|
||||
),
|
||||
@@ -276,7 +305,7 @@ function button(
|
||||
}
|
||||
|
||||
/** Fait télécharger un fichier texte au navigateur. */
|
||||
function download(file: { fileName: string; text: string }): void {
|
||||
export function downloadFile(file: { fileName: string; text: string }): void {
|
||||
const url = URL.createObjectURL(new Blob([file.text], { type: "application/x-go-sgf" }));
|
||||
const link = element("a");
|
||||
link.href = url;
|
||||
|
||||
@@ -10,7 +10,10 @@ export type HapticEvent =
|
||||
| "checkerHit"
|
||||
| "computerDoubles"
|
||||
| "gameWon"
|
||||
| "gameLost";
|
||||
| "gameLost"
|
||||
/** Bilan du match : le doigt passe d'une partie à l'autre sur la
|
||||
* courbe (étape 1l). */
|
||||
| "curveGame";
|
||||
|
||||
/** Motifs en millisecondes (vibration, pause, vibration…). */
|
||||
export const HAPTIC_PATTERNS: Readonly<Record<HapticEvent, readonly number[]>> = {
|
||||
@@ -19,6 +22,7 @@ export const HAPTIC_PATTERNS: Readonly<Record<HapticEvent, readonly number[]>> =
|
||||
computerDoubles: [40, 60, 40],
|
||||
gameWon: [30, 50, 30, 50, 60],
|
||||
gameLost: [60],
|
||||
curveGame: [8],
|
||||
};
|
||||
|
||||
/** navigator.vibrate, s'il existe. */
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// Un match en une ligne, dans « Mes parties » et la progression (étape 1l ;
|
||||
// charte, ecrans-etape-1.md, « Bilan du match », accès) : le titre (« Match
|
||||
// en 5 points · gagné 5–4 »), un trait par partie, la date, le nombre de
|
||||
// parties et le niveau, le taux d'erreur du match à droite ; la ligne ouvre
|
||||
// le bilan du match. Un match en cours a « Reprendre » à côté.
|
||||
//
|
||||
// Copyright (C) 2026 les auteurs d'Ustagammon.
|
||||
// Licence : GPLv3 ou ultérieure (voir LICENSE).
|
||||
|
||||
import { readyForSummary } from "../domain/analysis/game-analysis.js";
|
||||
import { type PlayedMatch, summarizeMatch } from "../domain/analysis/match-analysis.js";
|
||||
import { errorRateMillis } from "../domain/analysis/progression.js";
|
||||
import { currentLine } from "../domain/game/events.js";
|
||||
import { computerLevelOf } from "../domain/game/level.js";
|
||||
import { replay } from "../domain/game/state.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { MATCH_SUMMARY_TEXTS as T } from "./match-summary-texts.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { PROGRESSION_TEXTS } from "./progression-texts.js";
|
||||
import { routeHash } from "./router.js";
|
||||
|
||||
/** Un match et son taux d'erreur (null : analyse pas encore finie). */
|
||||
export interface MatchLine {
|
||||
readonly match: PlayedMatch;
|
||||
readonly errorRate: number | null;
|
||||
}
|
||||
|
||||
/** La ligne d'un match : son taux d'erreur, celui du bilan du match, dès
|
||||
* que toutes ses parties ont leur bilan. */
|
||||
export function matchLineOf(match: PlayedMatch): MatchLine {
|
||||
const ready = match.games.every((g) => readyForSummary(g.journal));
|
||||
return { match, errorRate: ready ? summarizeMatch(match).errorRate.perDecision : null };
|
||||
}
|
||||
|
||||
/** Dessine la ligne d'un match dans parent ; resume : « Reprendre », pour
|
||||
* un match en cours. */
|
||||
export function renderMatchLine(
|
||||
parent: HTMLElement,
|
||||
line: MatchLine,
|
||||
resume: (() => void) | null,
|
||||
): HTMLElement {
|
||||
const { match } = line;
|
||||
const box = document.createElement("div");
|
||||
box.className = "match-line";
|
||||
box.dataset.match = match.id;
|
||||
const link = document.createElement("a");
|
||||
link.className = "progression-game match-line-link";
|
||||
link.href = routeHash({ screen: "matchSummary", match: match.id });
|
||||
const text = document.createElement("span");
|
||||
text.className = "progression-text";
|
||||
const title = document.createElement("strong");
|
||||
title.textContent = T.listTitle(match);
|
||||
const strokes = document.createElement("span");
|
||||
strokes.className = "match-strokes";
|
||||
strokes.setAttribute("aria-hidden", "true");
|
||||
for (const game of match.games) {
|
||||
const state = replay(currentLine(game.journal));
|
||||
const stroke = document.createElement("span");
|
||||
stroke.className =
|
||||
state.result === null
|
||||
? "match-stroke"
|
||||
: `match-stroke ${state.result.winner === "player" ? "won" : "lost"}`;
|
||||
strokes.append(stroke);
|
||||
}
|
||||
if (!match.over) {
|
||||
const next = document.createElement("span");
|
||||
next.className = "match-stroke next";
|
||||
strokes.append(next);
|
||||
}
|
||||
const level = computerLevelOf(match.level);
|
||||
const caption = document.createElement("span");
|
||||
caption.className = "caption";
|
||||
caption.textContent = [
|
||||
T.listCaption(
|
||||
PROGRESSION_TEXTS.date(match.startedAt),
|
||||
match.games.length,
|
||||
level === null ? match.level : MATCH_TEXTS.levels[level].name,
|
||||
),
|
||||
...(match.inferred ? [T.listInferred] : []),
|
||||
].join(" · ");
|
||||
text.append(title, strokes, caption);
|
||||
const rate = document.createElement("span");
|
||||
rate.className = "progression-rate";
|
||||
if (line.errorRate === null) {
|
||||
rate.classList.add("pending");
|
||||
rate.textContent = PROGRESSION_TEXTS.rateLoading;
|
||||
} else {
|
||||
const millis = errorRateMillis(line.errorRate);
|
||||
rate.dataset.rate = String(line.errorRate);
|
||||
const strong = document.createElement("strong");
|
||||
strong.textContent = T.errorRate(millis);
|
||||
const unit = document.createElement("span");
|
||||
unit.className = "caption";
|
||||
unit.textContent = PROGRESSION_TEXTS.rateLabel;
|
||||
rate.append(strong, unit);
|
||||
rate.setAttribute("aria-label", T.errorRateLabel(millis));
|
||||
}
|
||||
link.append(text, rate, icon("chevron"));
|
||||
box.append(link);
|
||||
if (!match.over && resume !== null) {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.className = "match-resume";
|
||||
button.textContent = T.resume;
|
||||
button.onclick = () => resume();
|
||||
box.append(button);
|
||||
}
|
||||
parent.append(box);
|
||||
return box;
|
||||
}
|
||||
@@ -0,0 +1,766 @@
|
||||
// Le bilan d'un match entier (#/matchs/<id>/bilan, étape 1l ; charte,
|
||||
// ecrans-etape-1.md, « Bilan du match ») : une page qui défile. L'en-tête,
|
||||
// la courbe des chances de gagner le match à travers toutes les parties,
|
||||
// « Partie par partie », votre jeu sur le match, le videau, le moment
|
||||
// décisif, la décision à revoir, l'export SGF, puis la barre d'actions.
|
||||
//
|
||||
// Copyright (C) 2026 les auteurs d'Ustagammon.
|
||||
// Licence : GPLv3 ou ultérieure (voir LICENSE).
|
||||
//
|
||||
// Tout ce qu'elle affiche vient du bilan du match (domain/analysis/
|
||||
// match-analysis.ts), donc des analyses du moteur rangées dans chaque
|
||||
// partie, et des phrases du maître. La courbe est dessinée à la main en
|
||||
// SVG ; la bulle de lecture y est un lien SVG vers la décision (pas de
|
||||
// style en ligne : CSP stricte).
|
||||
|
||||
import {
|
||||
cubeKindsWithoutError,
|
||||
formatMatchLoss,
|
||||
type MatchCurvePoint,
|
||||
type MatchSummary,
|
||||
} from "../domain/analysis/match-analysis.js";
|
||||
import {
|
||||
decisiveSentence,
|
||||
diceWords,
|
||||
type MasterPhrases,
|
||||
masterWords,
|
||||
matchCubeAgreements,
|
||||
matchCubeSentence,
|
||||
nothingToReview,
|
||||
} from "../domain/analysis/phrases.js";
|
||||
import { errorRateMillis } from "../domain/analysis/progression.js";
|
||||
import type { Advice } from "../domain/game/advice.js";
|
||||
import type { MoveSteps } from "../domain/game/game.js";
|
||||
import { COMPUTER_LEVELS } from "../domain/game/level.js";
|
||||
import { VERDICT_ICONS } from "./advice-view.js";
|
||||
import { askAiLink } from "./ask-ai.js";
|
||||
import { icon } from "./icons.js";
|
||||
import {
|
||||
CUBE_ERROR_WORDS,
|
||||
matchScoreText,
|
||||
MATCH_SUMMARY_TEXTS as T,
|
||||
} from "./match-summary-texts.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { boardSvg, drawSteps } from "./move-board.js";
|
||||
import { percent, REVIEW_TEXTS } from "./review-texts.js";
|
||||
import { routeHash } from "./router.js";
|
||||
|
||||
/** Ce que montre la page. */
|
||||
export interface MatchSummaryData {
|
||||
readonly summary: MatchSummary;
|
||||
readonly phrases: MasterPhrases | null;
|
||||
}
|
||||
|
||||
export interface MatchSummaryViewOptions {
|
||||
/** La page (index.html) ; son contenu est construit ici. */
|
||||
readonly section: HTMLElement;
|
||||
/** Le plateau d'avant une décision d'une partie du match. */
|
||||
readonly stepsBefore: (gameId: string, advice: Advice) => Promise<MoveSteps | null>;
|
||||
/** « Exporter le match (SGF) ». */
|
||||
readonly exportSgf: (summary: MatchSummary) => Promise<void>;
|
||||
/** « Reprendre le match » : la dernière partie, à l'écran. */
|
||||
readonly resume: (summary: MatchSummary) => void;
|
||||
/** Une vibration légère, à chaque changement de partie sur la courbe. */
|
||||
readonly vibrate: () => void;
|
||||
}
|
||||
|
||||
export interface MatchSummaryView {
|
||||
/** Dessine la page (null : le match se lit ; missing : il n'existe
|
||||
* pas). */
|
||||
show(data: MatchSummaryData | null, missing?: boolean): void;
|
||||
hide(): void;
|
||||
}
|
||||
|
||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||
/** Hauteur de la courbe (au moins 150 px de zone tactile, charte) et ses
|
||||
* marges : les scores au-dessus, les noms des parties en dessous. */
|
||||
const CURVE_HEIGHT = 196;
|
||||
const PAD = { left: 40, right: 12, top: 26, bottom: 26 };
|
||||
const BUBBLE = { width: 210, height: 44 };
|
||||
|
||||
function element<K extends keyof HTMLElementTagNameMap>(
|
||||
parent: HTMLElement,
|
||||
tag: K,
|
||||
options: { id?: string; className?: string; text?: string } = {},
|
||||
): HTMLElementTagNameMap[K] {
|
||||
const child = document.createElement(tag);
|
||||
if (options.id !== undefined) {
|
||||
child.id = options.id;
|
||||
}
|
||||
if (options.className !== undefined) {
|
||||
child.className = options.className;
|
||||
}
|
||||
if (options.text !== undefined) {
|
||||
child.textContent = options.text;
|
||||
}
|
||||
parent.append(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
function svgElement<K extends keyof SVGElementTagNameMap>(
|
||||
parent: Element,
|
||||
tag: K,
|
||||
attributes: Record<string, string | number>,
|
||||
): SVGElementTagNameMap[K] {
|
||||
const child = document.createElementNS(SVG_NS, tag);
|
||||
for (const [name, value] of Object.entries(attributes)) {
|
||||
child.setAttribute(name, String(value));
|
||||
}
|
||||
parent.append(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
/** L'adresse d'une décision : l'analyse de sa partie, sur son coup. */
|
||||
function decisionHref(gameId: string, turn: number | null): string {
|
||||
return routeHash({ screen: "analysis", game: gameId, turn });
|
||||
}
|
||||
|
||||
const DICE_SIDE = {
|
||||
veryLucky: "for-2",
|
||||
lucky: "for-1",
|
||||
none: "even",
|
||||
unlucky: "against-1",
|
||||
veryUnlucky: "against-2",
|
||||
} as const;
|
||||
|
||||
export function createMatchSummaryView(options: MatchSummaryViewOptions): MatchSummaryView {
|
||||
const { section } = options;
|
||||
let drawn = "";
|
||||
let redrawCurve: (() => void) | null = null;
|
||||
window.addEventListener("resize", () => {
|
||||
if (!section.hidden) {
|
||||
redrawCurve?.();
|
||||
}
|
||||
});
|
||||
|
||||
function show(data: MatchSummaryData | null, missing = false): void {
|
||||
const key =
|
||||
data === null
|
||||
? `none|${missing}`
|
||||
: JSON.stringify({
|
||||
id: data.summary.match.id,
|
||||
phrases: data.phrases !== null,
|
||||
ready: data.summary.ready,
|
||||
games: data.summary.match.games.map((g) => g.id),
|
||||
curve: data.summary.curve.map((p) => p.chance),
|
||||
errors: data.summary.cubeErrors.map((e) => e.loss),
|
||||
review: data.summary.toReview?.advice.eventId ?? null,
|
||||
rate: data.summary.errorRate.perDecision,
|
||||
});
|
||||
if (key === drawn) {
|
||||
return;
|
||||
}
|
||||
drawn = key;
|
||||
section.replaceChildren();
|
||||
redrawCurve = null;
|
||||
delete section.dataset.ready;
|
||||
if (data === null) {
|
||||
element(section, "h1", { className: "progression-title", text: T.title });
|
||||
const status = element(section, "p", {
|
||||
id: "match-status",
|
||||
className: "progression-summary",
|
||||
text: missing ? T.missing : T.loading,
|
||||
});
|
||||
status.setAttribute("role", "status");
|
||||
return;
|
||||
}
|
||||
render(data);
|
||||
}
|
||||
|
||||
function render(data: MatchSummaryData): void {
|
||||
const { summary, phrases } = data;
|
||||
const { match } = summary;
|
||||
section.dataset.match = match.id;
|
||||
// Paysage : deux colonnes (charte) ; en portrait, l'une sous l'autre.
|
||||
const left = element(section, "div", { className: "match-column match-main" });
|
||||
const right = element(section, "div", { className: "match-column match-side" });
|
||||
|
||||
// 1. L'en-tête.
|
||||
const head = element(left, "header", { className: "match-head" });
|
||||
element(head, "p", {
|
||||
id: "match-overline",
|
||||
className: "overline",
|
||||
text: T.overline(match),
|
||||
});
|
||||
element(head, "h1", {
|
||||
id: "match-title",
|
||||
className: "progression-title",
|
||||
text: T.headline(match),
|
||||
});
|
||||
element(head, "p", {
|
||||
id: "match-sentence",
|
||||
className: "progression-summary",
|
||||
text: T.sentence(summary),
|
||||
});
|
||||
if (match.inferred) {
|
||||
element(head, "p", { id: "match-inferred", className: "caption", text: T.inferred });
|
||||
}
|
||||
if (!summary.ready) {
|
||||
element(head, "p", {
|
||||
id: "match-analysing",
|
||||
className: "muted",
|
||||
text: T.analysing,
|
||||
}).setAttribute("role", "status");
|
||||
}
|
||||
|
||||
// 2. La courbe.
|
||||
curveCard(left, summary);
|
||||
|
||||
// 3. Partie par partie.
|
||||
gamesCard(left, summary);
|
||||
|
||||
// 4. Votre jeu sur le match.
|
||||
if (phrases !== null) {
|
||||
playCard(right, summary, phrases);
|
||||
cubeCard(right, summary, phrases);
|
||||
decisiveCard(right, summary, phrases);
|
||||
reviewCard(right, summary, phrases);
|
||||
}
|
||||
|
||||
// 8. L'export, puis la barre d'actions.
|
||||
const exportBox = element(right, "p", { className: "match-export" });
|
||||
const exportButton = element(exportBox, "button", {
|
||||
id: "match-export",
|
||||
className: "link-button",
|
||||
text: T.exportSgf,
|
||||
});
|
||||
exportButton.type = "button";
|
||||
const exportHint = element(exportBox, "span", {
|
||||
className: "caption",
|
||||
text: ` ${T.exportHint}`,
|
||||
});
|
||||
exportButton.onclick = () => {
|
||||
exportHint.textContent = ` ${T.exportHint}`;
|
||||
options.exportSgf(summary).catch((error: unknown) => {
|
||||
exportHint.textContent = ` ${T.exportFailed(error instanceof Error ? error.message : String(error))}`;
|
||||
});
|
||||
};
|
||||
const bar = element(right, "div", { className: "panel-actions match-actions" });
|
||||
const firstGame = match.games[0];
|
||||
if (firstGame !== undefined) {
|
||||
const again = element(bar, "a", {
|
||||
id: "match-review",
|
||||
className: "button secondary",
|
||||
text: T.reviewMatch,
|
||||
});
|
||||
again.href = decisionHref(firstGame.id, 1);
|
||||
}
|
||||
if (match.over) {
|
||||
const start = element(bar, "a", {
|
||||
id: "match-primary",
|
||||
className: "button",
|
||||
text: T.newMatch,
|
||||
});
|
||||
start.href = routeHash({ screen: "newGame" });
|
||||
} else {
|
||||
const resume = element(bar, "button", {
|
||||
id: "match-primary",
|
||||
text: T.resumeMatch,
|
||||
});
|
||||
resume.type = "button";
|
||||
resume.onclick = () => options.resume(summary);
|
||||
}
|
||||
section.dataset.ready = String(summary.ready);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ Courbe
|
||||
|
||||
function curveCard(parent: HTMLElement, summary: MatchSummary): void {
|
||||
const card = element(parent, "section", {
|
||||
id: "match-curve-card",
|
||||
className: "analysis-card match-curve-card",
|
||||
});
|
||||
element(card, "h2", { className: "overline", text: T.curveTitle });
|
||||
const svg = document.createElementNS(SVG_NS, "svg");
|
||||
svg.id = "match-curve";
|
||||
svg.setAttribute("class", "analysis-curve match-curve");
|
||||
svg.setAttribute("role", "img");
|
||||
svg.setAttribute("tabindex", "0");
|
||||
card.append(svg);
|
||||
const legend = element(card, "ul", { className: "match-legend" });
|
||||
for (const [mark, text] of [
|
||||
["decisive", T.legendDecisive],
|
||||
["review", T.legendReview],
|
||||
[summary.match.winner === "player" ? "end won" : "end", T.legendEnd],
|
||||
] as const) {
|
||||
const item = element(legend, "li");
|
||||
const dot = element(item, "span", { className: `match-mark ${mark}` });
|
||||
dot.setAttribute("aria-hidden", "true");
|
||||
item.append(text);
|
||||
}
|
||||
const points = summary.curve;
|
||||
const known = points.filter((p) => p.chance !== null);
|
||||
if (known.length < points.length) {
|
||||
element(card, "p", { className: "caption", text: T.pending });
|
||||
}
|
||||
const chances = known.map((p) => p.chance as number);
|
||||
const decisive = summary.decisive;
|
||||
svg.setAttribute(
|
||||
"aria-label",
|
||||
known.length === 0
|
||||
? T.pending
|
||||
: T.curveLabel(
|
||||
percent(chances[0] ?? 0.5),
|
||||
percent(Math.min(...chances)),
|
||||
percent(chances.at(-1) ?? 0.5),
|
||||
decisive === null ? "" : T.curveDecisive(decisive.game, decisive.turn),
|
||||
),
|
||||
);
|
||||
svg.dataset.points = JSON.stringify(points.map((p) => [p.game, p.turn, p.chance]));
|
||||
let selected: number | null = null;
|
||||
const draw = () => drawCurve(svg, summary, selected);
|
||||
redrawCurve = draw;
|
||||
draw();
|
||||
|
||||
// Lecture au doigt : glisser choisit le point sous le doigt (une
|
||||
// vibration légère à chaque changement de partie) ; lâcher garde la
|
||||
// bulle, qui ouvre la décision.
|
||||
const indexAt = (clientX: number): number => {
|
||||
const box = svg.getBoundingClientRect();
|
||||
const inner = Math.max(1, box.width - PAD.left - PAD.right);
|
||||
const step = points.length > 1 ? inner / (points.length - 1) : inner;
|
||||
const i = Math.round((clientX - box.left - PAD.left) / step);
|
||||
return Math.min(points.length - 1, Math.max(0, i));
|
||||
};
|
||||
const choose = (index: number) => {
|
||||
if (index === selected) {
|
||||
return;
|
||||
}
|
||||
const before = selected === null ? null : points[selected]?.game;
|
||||
selected = index;
|
||||
if (before !== undefined && before !== null && before !== points[index]?.game) {
|
||||
options.vibrate();
|
||||
}
|
||||
draw();
|
||||
};
|
||||
let dragging = false;
|
||||
svg.addEventListener("pointerdown", (event) => {
|
||||
if ((event.target as Element).closest(".match-bubble") !== null) {
|
||||
return;
|
||||
}
|
||||
dragging = true;
|
||||
svg.setPointerCapture?.(event.pointerId);
|
||||
choose(indexAt(event.clientX));
|
||||
});
|
||||
svg.addEventListener("pointermove", (event) => {
|
||||
if (dragging) {
|
||||
choose(indexAt(event.clientX));
|
||||
}
|
||||
});
|
||||
for (const end of ["pointerup", "pointercancel"] as const) {
|
||||
svg.addEventListener(end, () => {
|
||||
dragging = false;
|
||||
});
|
||||
}
|
||||
svg.addEventListener("keydown", (event) => {
|
||||
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const from = selected ?? (event.key === "ArrowLeft" ? points.length : -1);
|
||||
choose(
|
||||
Math.min(
|
||||
points.length - 1,
|
||||
Math.max(0, from + (event.key === "ArrowLeft" ? -1 : 1)),
|
||||
),
|
||||
);
|
||||
} else if (event.key === "Enter" && selected !== null) {
|
||||
const point = points[selected];
|
||||
if (point !== undefined) {
|
||||
event.preventDefault();
|
||||
location.hash = decisionHref(point.gameId, point.turn);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------- Partie par partie
|
||||
|
||||
function gamesCard(parent: HTMLElement, summary: MatchSummary): void {
|
||||
const card = element(parent, "section", { id: "match-games", className: "match-games" });
|
||||
element(card, "h2", { className: "overline", text: T.gamesTitle });
|
||||
const list = element(card, "ol", { className: "progression-list match-game-list" });
|
||||
for (const row of summary.rows) {
|
||||
const li = element(list, "li", { className: "progression-item" });
|
||||
li.dataset.game = String(row.number);
|
||||
const link = element(li, "a", { className: "progression-game match-game" });
|
||||
link.href = routeHash({ screen: "summary", game: row.id });
|
||||
const result = T.gameResult(row.result, row.cube);
|
||||
const points = T.gamePoints(row.result);
|
||||
const after = row.scoreAfter === null ? "" : matchScoreText(row.scoreAfter);
|
||||
link.setAttribute("aria-label", T.gameRowLabel(row.number, result, points, after));
|
||||
const text = element(link, "span", { className: "progression-text" });
|
||||
element(text, "strong", {
|
||||
text: `${T.gameRow(row.number)}${row.crawford ? ` · ${T.crawford}` : ""}`,
|
||||
});
|
||||
element(text, "span", {
|
||||
className: "caption",
|
||||
text: points === "" ? result : `${result} · ${points}`,
|
||||
});
|
||||
const score = element(link, "span", { className: "match-game-score", text: after });
|
||||
score.setAttribute("aria-hidden", "true");
|
||||
link.append(icon("chevron"));
|
||||
}
|
||||
element(card, "p", { className: "caption", text: T.scoreReminder });
|
||||
}
|
||||
|
||||
// ------------------------------------------------- Votre jeu
|
||||
|
||||
function playCard(parent: HTMLElement, summary: MatchSummary, phrases: MasterPhrases): void {
|
||||
const card = element(parent, "section", { id: "match-play", className: "analysis-card" });
|
||||
element(card, "h2", { className: "overline", text: T.playTitle });
|
||||
const tiles = element(card, "div", { className: "match-tiles" });
|
||||
for (const [key, rate] of [
|
||||
["all", summary.errorRate],
|
||||
["chequer", summary.chequer],
|
||||
["cube", summary.cube],
|
||||
] as const) {
|
||||
const tile = element(tiles, "div", { className: "match-tile" });
|
||||
tile.dataset.tile = key;
|
||||
element(tile, "span", { className: "caption", text: T.tiles[key] });
|
||||
element(tile, "strong", {
|
||||
text: rate.decisions === 0 ? "–" : String(errorRateMillis(rate.perDecision)),
|
||||
});
|
||||
element(tile, "span", {
|
||||
className: "caption",
|
||||
text: rate.decisions === 0 ? T.tileNone : T.tileUnit,
|
||||
});
|
||||
}
|
||||
const box = element(card, "div", { className: "summary-gauges" });
|
||||
const level = summary.errorRate.level;
|
||||
const levelName = MATCH_TEXTS.levels[level].name;
|
||||
const play = element(box, "div", { id: "match-gauge-play", className: "gauge" });
|
||||
play.setAttribute("aria-label", REVIEW_TEXTS.playGauge(levelName));
|
||||
play.setAttribute("role", "img");
|
||||
element(play, "span", { className: "gauge-name", text: REVIEW_TEXTS.yourPlay });
|
||||
const track = element(play, "span", { className: "gauge-track" });
|
||||
element(track, "span", {
|
||||
className: `gauge-fill level-${COMPUTER_LEVELS.indexOf(level) + 1}`,
|
||||
});
|
||||
element(play, "span", { className: "gauge-value", text: levelName });
|
||||
const words = diceWords(phrases, summary.luck.rating);
|
||||
const dice = element(box, "div", { id: "match-gauge-dice", className: "gauge" });
|
||||
dice.setAttribute("aria-label", REVIEW_TEXTS.diceGauge(words));
|
||||
dice.setAttribute("role", "img");
|
||||
element(dice, "span", { className: "gauge-name", text: REVIEW_TEXTS.theDice });
|
||||
const centred = element(dice, "span", { className: "gauge-track centred" });
|
||||
element(centred, "span", {
|
||||
className: `gauge-fill dice ${DICE_SIDE[summary.luck.rating]}`,
|
||||
});
|
||||
element(dice, "span", { className: "gauge-value", text: words });
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- Le videau
|
||||
|
||||
function cubeCard(parent: HTMLElement, summary: MatchSummary, phrases: MasterPhrases): void {
|
||||
const card = element(parent, "section", { id: "match-cube", className: "analysis-card" });
|
||||
element(card, "h2", { className: "overline", text: T.cubeTitle });
|
||||
element(card, "p", {
|
||||
id: "match-cube-sentence",
|
||||
className: "match-sentence",
|
||||
text: matchCubeSentence(phrases, summary.cubeDecisions, summary.cubeErrors.length),
|
||||
});
|
||||
if (summary.cubeErrors.length > 0) {
|
||||
const list = element(card, "ul", { className: "match-cube-list" });
|
||||
for (const error of summary.cubeErrors) {
|
||||
const li = element(list, "li", { className: "match-cube-item" });
|
||||
li.dataset.kind = error.kind;
|
||||
const link = element(li, "a", { className: "match-cube-row" });
|
||||
link.href = decisionHref(error.gameId, error.turn);
|
||||
const where = T.cubeWhere(error.game, error.turn, matchScoreText(error.score));
|
||||
const loss = error.loss === null ? T.cubeLossPending : formatMatchLoss(error.loss);
|
||||
link.setAttribute(
|
||||
"aria-label",
|
||||
T.cubeRowLabel(CUBE_ERROR_WORDS[error.kind], where, loss),
|
||||
);
|
||||
const text = element(link, "span", { className: "progression-text" });
|
||||
element(text, "strong", { text: CUBE_ERROR_WORDS[error.kind] });
|
||||
element(text, "span", { className: "caption", text: where });
|
||||
const value = element(link, "span", { className: "match-loss", text: loss });
|
||||
value.dataset.verdict = error.advice.skill === "none" ? "good" : error.advice.skill;
|
||||
value.setAttribute("aria-hidden", "true");
|
||||
link.append(icon("chevron"));
|
||||
}
|
||||
}
|
||||
for (const sentence of matchCubeAgreements(phrases, cubeKindsWithoutError(summary))) {
|
||||
element(card, "p", { className: "match-agreement caption", text: sentence });
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------- Le moment décisif
|
||||
|
||||
function decisiveCard(
|
||||
parent: HTMLElement,
|
||||
summary: MatchSummary,
|
||||
phrases: MasterPhrases,
|
||||
): void {
|
||||
const card = element(parent, "section", {
|
||||
id: "match-decisive",
|
||||
className: "analysis-card",
|
||||
});
|
||||
element(card, "h2", { className: "overline", text: T.decisiveTitle });
|
||||
const moment = summary.decisive;
|
||||
if (moment === null) {
|
||||
element(card, "p", { className: "muted", text: T.decisiveNone });
|
||||
return;
|
||||
}
|
||||
element(card, "p", {
|
||||
id: "match-decisive-sentence",
|
||||
className: "match-sentence",
|
||||
text: decisiveSentence(phrases, moment),
|
||||
});
|
||||
const link = element(card, "a", {
|
||||
id: "match-decisive-link",
|
||||
className: "link-button",
|
||||
text: T.seeThisMove,
|
||||
});
|
||||
link.href = decisionHref(moment.gameId, moment.turn);
|
||||
}
|
||||
|
||||
// ------------------------------------------- La décision à revoir
|
||||
|
||||
function reviewCard(parent: HTMLElement, summary: MatchSummary, phrases: MasterPhrases): void {
|
||||
const card = element(parent, "section", {
|
||||
id: "match-to-review",
|
||||
className: "summary-review analysis-card",
|
||||
});
|
||||
element(card, "h2", { className: "overline", text: T.reviewTitle });
|
||||
const reviewed = summary.toReview;
|
||||
if (reviewed === null) {
|
||||
element(card, "p", { className: "summary-none", text: nothingToReview(phrases) });
|
||||
return;
|
||||
}
|
||||
const advice = reviewed.advice;
|
||||
const words = masterWords(phrases, advice);
|
||||
const body = element(card, "div", { className: "summary-review-body" });
|
||||
const box = element(body, "div", { className: "summary-board-box" });
|
||||
const svg = boardSvg(box, "match-board", "summary-board");
|
||||
svg.setAttribute("aria-label", REVIEW_TEXTS.toReviewBoard);
|
||||
void options
|
||||
.stepsBefore(reviewed.gameId, advice)
|
||||
.then((steps) => {
|
||||
if (steps !== null) {
|
||||
drawSteps(svg, steps, steps.halfMoves.length, true, "match-");
|
||||
}
|
||||
})
|
||||
.catch(() => undefined);
|
||||
const text = element(body, "div", { className: "summary-review-text" });
|
||||
const verdict = element(text, "p", { className: "summary-verdict" });
|
||||
verdict.dataset.verdict = words.verdict;
|
||||
verdict.append(icon(VERDICT_ICONS[words.verdict]), `${words.word} · ${words.context}`);
|
||||
element(text, "p", {
|
||||
className: "caption",
|
||||
text: T.reviewWhere(reviewed.game, reviewed.turn, matchScoreText(reviewed.score)),
|
||||
});
|
||||
if (reviewed.loss !== null) {
|
||||
const loss = element(text, "p", {
|
||||
id: "match-review-loss",
|
||||
className: "match-loss",
|
||||
text: T.lossOf(formatMatchLoss(reviewed.loss)),
|
||||
});
|
||||
loss.dataset.verdict = words.verdict;
|
||||
}
|
||||
element(text, "p", {
|
||||
className: "summary-master",
|
||||
text:
|
||||
advice.kind === "move"
|
||||
? REVIEW_TEXTS.yourMove(advice.played.notation)
|
||||
: REVIEW_TEXTS.yourDecision(REVIEW_TEXTS.cubeActions[advice.action]),
|
||||
});
|
||||
element(text, "p", { className: "summary-master", text: words.title });
|
||||
const links = element(card, "div", { className: "summary-review-actions" });
|
||||
const revisit = element(links, "a", {
|
||||
id: "match-revisit",
|
||||
className: "button secondary",
|
||||
text: T.review,
|
||||
});
|
||||
revisit.href = decisionHref(reviewed.gameId, reviewed.turn);
|
||||
const slot = element(links, "div", { className: "ask-ai-slot" });
|
||||
askAiLink(
|
||||
slot,
|
||||
"match-ask-ai",
|
||||
routeHash({ screen: "matchSummary", match: summary.match.id, ai: true }),
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
show,
|
||||
hide() {
|
||||
drawn = "";
|
||||
redrawCurve = null;
|
||||
section.replaceChildren();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* La courbe : un point par décision (le début du match, puis chaque tour de
|
||||
* chaque partie), une seule ligne de 0 à 100 % ; un trait vertical entre
|
||||
* les parties, le score au début de chacune au-dessus, son nom court en
|
||||
* dessous ; la partie Crawford sur fond creusé ; la ligne des 50 % en
|
||||
* pointillés ; trois marques (moment décisif, décision à revoir, fin) ; la
|
||||
* bulle du point choisi.
|
||||
*/
|
||||
function drawCurve(svg: SVGSVGElement, summary: MatchSummary, selected: number | null): void {
|
||||
const width = Math.round(svg.getBoundingClientRect().width || 360);
|
||||
const height = CURVE_HEIGHT;
|
||||
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
||||
svg.replaceChildren();
|
||||
const points = summary.curve;
|
||||
const inner = width - PAD.left - PAD.right;
|
||||
const step = points.length > 1 ? inner / (points.length - 1) : 0;
|
||||
const x = (i: number) => PAD.left + i * step;
|
||||
const y = (chance: number) => PAD.top + (1 - chance) * (height - PAD.top - PAD.bottom);
|
||||
|
||||
// Les parties : de leur premier point (le dernier de la précédente) à
|
||||
// leur dernier.
|
||||
const spans = summary.rows.map((row) => {
|
||||
const indexes = points.flatMap((p, i) => (p.game === row.number ? [i] : []));
|
||||
const first = indexes[0] ?? 0;
|
||||
const last = indexes.at(-1) ?? first;
|
||||
return { row, from: row.number === 1 ? first : Math.max(0, first - 1), to: last };
|
||||
});
|
||||
for (const span of spans) {
|
||||
if (span.row.crawford) {
|
||||
svgElement(svg, "rect", {
|
||||
x: x(span.from),
|
||||
y: PAD.top,
|
||||
width: Math.max(2, x(span.to) - x(span.from)),
|
||||
height: height - PAD.top - PAD.bottom,
|
||||
class: "match-crawford",
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const level of [1, 0.5, 0]) {
|
||||
svgElement(svg, "line", {
|
||||
x1: PAD.left,
|
||||
x2: width - PAD.right,
|
||||
y1: y(level),
|
||||
y2: y(level),
|
||||
class: level === 0.5 ? "curve-half" : "curve-axis",
|
||||
});
|
||||
const label = svgElement(svg, "text", {
|
||||
x: PAD.left - 6,
|
||||
y: y(level) + 4,
|
||||
class: "curve-label",
|
||||
"text-anchor": "end",
|
||||
});
|
||||
label.textContent = percent(level);
|
||||
}
|
||||
for (const span of spans) {
|
||||
if (span.row.number > 1) {
|
||||
svgElement(svg, "line", {
|
||||
x1: x(span.from),
|
||||
x2: x(span.from),
|
||||
y1: PAD.top,
|
||||
y2: height - PAD.bottom,
|
||||
class: "match-separator",
|
||||
});
|
||||
}
|
||||
const middle = (x(span.from) + x(span.to)) / 2;
|
||||
const score = svgElement(svg, "text", {
|
||||
x: middle,
|
||||
y: PAD.top - 9,
|
||||
class: "curve-label match-score",
|
||||
"text-anchor": "middle",
|
||||
});
|
||||
score.textContent = matchScoreText(span.row.scoreBefore);
|
||||
const name = svgElement(svg, "text", {
|
||||
x: middle,
|
||||
y: height - 8,
|
||||
class: "curve-label",
|
||||
"text-anchor": "middle",
|
||||
});
|
||||
name.textContent = T.gameShort(span.row.number);
|
||||
}
|
||||
|
||||
const known = points.flatMap((p, i) => (p.chance === null ? [] : [{ i, p, c: p.chance }]));
|
||||
if (known.length > 0) {
|
||||
svgElement(svg, "polyline", {
|
||||
points: known.map(({ i, c }) => `${x(i)},${y(c)}`).join(" "),
|
||||
class: "curve-line",
|
||||
});
|
||||
}
|
||||
const indexOf = (game: number, turn: number) =>
|
||||
points.findIndex((p) => p.game === game && p.turn === turn);
|
||||
const mark = (i: number, cls: string, r: number) => {
|
||||
const c = points[i]?.chance;
|
||||
if (i >= 0 && c !== null && c !== undefined) {
|
||||
svgElement(svg, "circle", { cx: x(i), cy: y(c), r, class: cls }).setAttribute(
|
||||
"aria-hidden",
|
||||
"true",
|
||||
);
|
||||
}
|
||||
};
|
||||
const decisive = summary.decisive;
|
||||
if (decisive !== null) {
|
||||
mark(indexOf(decisive.game, decisive.turn), "match-mark-ring", 8);
|
||||
}
|
||||
const reviewed = summary.toReview;
|
||||
if (reviewed !== null) {
|
||||
mark(indexOf(reviewed.game, reviewed.turn), "match-mark-review", 5);
|
||||
}
|
||||
if (summary.match.over) {
|
||||
mark(
|
||||
points.length - 1,
|
||||
summary.match.winner === "player" ? "match-mark-end won" : "match-mark-end",
|
||||
5,
|
||||
);
|
||||
}
|
||||
|
||||
// Le point choisi : un trait qui suit le doigt, et la bulle.
|
||||
const point = selected === null ? undefined : points[selected];
|
||||
if (selected !== null && point !== undefined) {
|
||||
svgElement(svg, "line", {
|
||||
x1: x(selected),
|
||||
x2: x(selected),
|
||||
y1: PAD.top,
|
||||
y2: height - PAD.bottom,
|
||||
class: "curve-cursor",
|
||||
});
|
||||
bubble(svg, summary, point, x(selected), width);
|
||||
}
|
||||
}
|
||||
|
||||
/** La bulle du point choisi : partie, coup, score, chances ; un lien SVG
|
||||
* vers la décision dans l'analyse. */
|
||||
function bubble(
|
||||
svg: SVGSVGElement,
|
||||
summary: MatchSummary,
|
||||
point: MatchCurvePoint,
|
||||
cx: number,
|
||||
width: number,
|
||||
): void {
|
||||
const row = summary.rows[point.game - 1];
|
||||
const score = row === undefined ? "" : matchScoreText(row.scoreBefore);
|
||||
const chance = point.chance === null ? REVIEW_TEXTS.curveUnknown : percent(point.chance);
|
||||
const link = svgElement(svg, "a", {
|
||||
href: decisionHref(point.gameId, point.turn),
|
||||
class: "match-bubble",
|
||||
id: "match-bubble",
|
||||
});
|
||||
link.setAttribute(
|
||||
"aria-label",
|
||||
`${T.bubble(point.game, point.turn, score, chance)}. ${T.bubbleOpen}`,
|
||||
);
|
||||
const left = Math.min(Math.max(4, cx - BUBBLE.width / 2), width - BUBBLE.width - 4);
|
||||
svgElement(link, "rect", {
|
||||
x: left,
|
||||
y: 2,
|
||||
width: BUBBLE.width,
|
||||
height: BUBBLE.height,
|
||||
rx: 8,
|
||||
class: "match-bubble-box",
|
||||
});
|
||||
const line1 = svgElement(link, "text", {
|
||||
x: left + 10,
|
||||
y: 19,
|
||||
class: "match-bubble-text",
|
||||
});
|
||||
line1.textContent = T.bubble(point.game, point.turn, score, chance);
|
||||
const line2 = svgElement(link, "text", {
|
||||
x: left + 10,
|
||||
y: 36,
|
||||
class: "match-bubble-hint",
|
||||
});
|
||||
line2.textContent = T.bubbleOpen;
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
// (domain/analysis/progression.ts), et la redessine quand une analyse en
|
||||
// arrière-plan se termine.
|
||||
|
||||
import type { PlayedMatch } from "../domain/analysis/match-analysis.js";
|
||||
import type { MasterPhrases } from "../domain/analysis/phrases.js";
|
||||
import { progressionSentence } from "../domain/analysis/phrases.js";
|
||||
import {
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
} from "../domain/analysis/progression.js";
|
||||
import { computerLevelOf } from "../domain/game/level.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { type MatchLine, renderMatchLine } from "./match-line.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { PROGRESSION_TEXTS } from "./progression-texts.js";
|
||||
import { routeHash } from "./router.js";
|
||||
@@ -31,12 +33,17 @@ import { routeHash } from "./router.js";
|
||||
export interface ProgressionData {
|
||||
/** Les parties terminées, de la plus ancienne à la plus récente. */
|
||||
readonly entries: readonly ProgressionEntry[];
|
||||
/** Les matchs (étape 1l) : chacun tient en une ligne dans la liste, à
|
||||
* la place de ses parties (la courbe garde un point par partie). */
|
||||
readonly matches: readonly MatchLine[];
|
||||
/** Les phrases du maître (null : pas encore lues). */
|
||||
readonly phrases: MasterPhrases | null;
|
||||
}
|
||||
|
||||
export interface ProgressionViewOptions {
|
||||
readonly section: HTMLElement;
|
||||
/** « Reprendre » sur la ligne d'un match en cours. */
|
||||
readonly resumeMatch: (match: PlayedMatch) => void;
|
||||
}
|
||||
|
||||
export interface ProgressionView {
|
||||
@@ -129,6 +136,12 @@ export function createProgressionView(options: ProgressionViewOptions): Progress
|
||||
e.level,
|
||||
e.errorRate?.perDecision ?? null,
|
||||
]),
|
||||
matches: data.matches.map((m) => [
|
||||
m.match.id,
|
||||
m.match.games.map((g) => g.id),
|
||||
m.match.score,
|
||||
m.errorRate,
|
||||
]),
|
||||
},
|
||||
);
|
||||
if (key === drawn) {
|
||||
@@ -211,9 +224,29 @@ export function createProgressionView(options: ProgressionViewOptions): Progress
|
||||
|
||||
element(body, "h3", { className: "overline", text: PROGRESSION_TEXTS.listTitle });
|
||||
const list = element(body, "ol", { id: "progression-list", className: "progression-list" });
|
||||
// La plus récente d'abord, comme « Mes parties ».
|
||||
for (const entry of [...data.entries].reverse()) {
|
||||
list.append(item(entry));
|
||||
// La plus récente d'abord, comme « Mes parties » ; un match en une
|
||||
// ligne, à la date de sa partie la plus récente de la liste.
|
||||
const shown = new Set(data.entries.map((e) => e.id));
|
||||
const matches = data.matches.filter((m) => m.match.games.some((g) => shown.has(g.id)));
|
||||
const inMatch = new Set(matches.flatMap((m) => m.match.games.map((g) => g.id)));
|
||||
const lines = [
|
||||
...data.entries
|
||||
.filter((entry) => !inMatch.has(entry.id))
|
||||
.map((entry) => ({ at: entry.startedAt, add: () => list.append(item(entry)) })),
|
||||
...matches.map((line) => ({
|
||||
at: Math.max(
|
||||
...line.match.games.filter((g) => shown.has(g.id)).map((g) => g.startedAt),
|
||||
),
|
||||
add: () => {
|
||||
const li = document.createElement("li");
|
||||
li.className = "progression-item progression-match";
|
||||
renderMatchLine(li, line, () => options.resumeMatch(line.match));
|
||||
list.append(li);
|
||||
},
|
||||
})),
|
||||
].sort((a, b) => b.at - a.at);
|
||||
for (const line of lines) {
|
||||
line.add();
|
||||
}
|
||||
section.dataset.ready = String(waiting === 0);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Copyright (C) 2026 les auteurs d'Ustagammon.
|
||||
// Licence : GPLv3 ou ultérieure (voir LICENSE).
|
||||
|
||||
import type { MatchSummary } from "../domain/analysis/match-analysis.js";
|
||||
import type { MasterPhrases } from "../domain/analysis/phrases.js";
|
||||
import type { Advice } from "../domain/game/advice.js";
|
||||
import type { GameJournal } from "../domain/game/events.js";
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
conceptPrompt,
|
||||
decisionPrompt,
|
||||
exercisesPrompt,
|
||||
matchPrompt,
|
||||
summaryPrompt,
|
||||
} from "../domain/prompts/prompts.js";
|
||||
import {
|
||||
@@ -44,6 +46,9 @@ export interface PromptsAccess {
|
||||
/** La position de la plus coûteuse des erreurs de ces parties (null :
|
||||
* aucune imprécision ni erreur). */
|
||||
readonly exercises: (journals: readonly GameJournal[]) => Promise<PromptPosition | null>;
|
||||
/** La position que montre le prompt du bilan du match (décision à
|
||||
* revoir, ou position finale). */
|
||||
readonly match: (summary: MatchSummary) => Promise<PromptPosition>;
|
||||
}
|
||||
|
||||
export interface PromptSourceOptions {
|
||||
@@ -63,6 +68,8 @@ export interface PromptSource {
|
||||
/** Le prompt « Créer des exercices » (progression, étape 1h), sur les
|
||||
* parties analysées, de la plus ancienne à la plus récente. */
|
||||
exercises(journals: readonly GameJournal[]): Promise<PromptResult>;
|
||||
/** Le prompt « Bilan de mon match » (étape 1l). */
|
||||
match(summary: MatchSummary): Promise<PromptResult>;
|
||||
}
|
||||
|
||||
async function fetchText(url: string): Promise<string> {
|
||||
@@ -128,6 +135,14 @@ export function createPromptSource(options: PromptSourceOptions): PromptSource {
|
||||
}
|
||||
return { text: exercisesPrompt(all, phrases, { journals, position }) };
|
||||
},
|
||||
async match(summary) {
|
||||
const [all, phrases, position] = await Promise.all([
|
||||
templates(),
|
||||
options.phrases(),
|
||||
options.access.match(summary),
|
||||
]);
|
||||
return { text: matchPrompt(all, phrases, { summary, position }) };
|
||||
},
|
||||
async concept(term, journal) {
|
||||
const [all, entry, example] = await Promise.all([
|
||||
templates(),
|
||||
|
||||
+21
-1
@@ -54,6 +54,9 @@ export type Route =
|
||||
readonly turn: number | null;
|
||||
readonly ai?: boolean;
|
||||
}
|
||||
/** #/matchs/<identifiant>/bilan : le bilan d'un match entier (étape
|
||||
* 1l) ; son prompt pour une IA : #/matchs/<identifiant>/bilan/ia. */
|
||||
| { readonly screen: "matchSummary"; readonly match: string; readonly ai?: boolean }
|
||||
/** #/progression : l'historique des parties et la courbe du taux
|
||||
* d'erreur (étape 1h) ; le prompt « Créer des exercices » :
|
||||
* #/progression/ia. */
|
||||
@@ -114,6 +117,12 @@ export function parseRoute(hash: string): Route {
|
||||
if (head === "parties" && rest.length > 1) {
|
||||
return gameReviewRoute(rest) ?? unknown;
|
||||
}
|
||||
if (head === "matchs") {
|
||||
const [match = "", part, ...more] = rest;
|
||||
return NAME.test(match) && part === "bilan" && more.length === 0
|
||||
? { screen: "matchSummary", match }
|
||||
: unknown;
|
||||
}
|
||||
if (rest.length > 1) {
|
||||
return unknown;
|
||||
}
|
||||
@@ -156,7 +165,15 @@ export function parseRoute(hash: string): Route {
|
||||
/** Les écrans qui ont une feuille de prompt pour une IA. */
|
||||
export type AiRoute = Extract<
|
||||
Route,
|
||||
{ screen: "explanation" | "summary" | "analysis" | "glossary" | "progression" }
|
||||
{
|
||||
screen:
|
||||
| "explanation"
|
||||
| "summary"
|
||||
| "analysis"
|
||||
| "glossary"
|
||||
| "progression"
|
||||
| "matchSummary";
|
||||
}
|
||||
>;
|
||||
|
||||
/** L'écran, avec sa feuille de prompt ouverte (null : écran sans prompt). */
|
||||
@@ -166,6 +183,7 @@ function aiRoute(route: Route): AiRoute | null {
|
||||
case "summary":
|
||||
case "analysis":
|
||||
case "progression":
|
||||
case "matchSummary":
|
||||
return route.ai === true ? null : { ...route, ai: true };
|
||||
case "glossary":
|
||||
return route.term === null || route.ai === true ? null : { ...route, ai: true };
|
||||
@@ -316,6 +334,8 @@ function screenHash(route: Route): string {
|
||||
: `#/parties/${route.game}/analyse/${route.turn}`;
|
||||
case "progression":
|
||||
return "#/progression";
|
||||
case "matchSummary":
|
||||
return `#/matchs/${route.match}/bilan`;
|
||||
case "menu":
|
||||
return "#/menu";
|
||||
case "newGame":
|
||||
|
||||
@@ -30,6 +30,7 @@ import { COMPUTER_LEVELS } from "../domain/game/level.js";
|
||||
import { VERDICT_ICONS } from "./advice-view.js";
|
||||
import { askAiLink, clearSheet } from "./ask-ai.js";
|
||||
import { icon } from "./icons.js";
|
||||
import { MATCH_SUMMARY_TEXTS } from "./match-summary-texts.js";
|
||||
import { MATCH_TEXTS } from "./match-texts.js";
|
||||
import { boardSvg, drawSteps } from "./move-board.js";
|
||||
import { REVIEW_TEXTS } from "./review-texts.js";
|
||||
@@ -49,6 +50,13 @@ export interface SummaryData {
|
||||
* l'écran des choix. */
|
||||
readonly afterLabel: string | null;
|
||||
readonly phrases: MasterPhrases | null;
|
||||
/** Une partie de match (étape 1l) : sa place et le bilan du match
|
||||
* (null : partie libre, ou partie rattachée à aucun match). */
|
||||
readonly match: {
|
||||
readonly id: string;
|
||||
readonly number: number;
|
||||
readonly length: number;
|
||||
} | null;
|
||||
}
|
||||
|
||||
export interface SummaryViewOptions {
|
||||
@@ -137,6 +145,7 @@ export function createSummaryView(options: SummaryViewOptions): SummaryView {
|
||||
data.end?.title ?? "",
|
||||
data.end?.detail ?? "",
|
||||
data.afterLabel ?? "",
|
||||
JSON.stringify(data.match),
|
||||
ready,
|
||||
JSON.stringify(shown),
|
||||
].join("|");
|
||||
@@ -166,6 +175,7 @@ export function createSummaryView(options: SummaryViewOptions): SummaryView {
|
||||
return;
|
||||
}
|
||||
title.textContent = data.end.title;
|
||||
matchLine(data);
|
||||
const reading = element(panel, "p", {
|
||||
id: "summary-reading",
|
||||
className: "summary-reading",
|
||||
@@ -191,6 +201,25 @@ export function createSummaryView(options: SummaryViewOptions): SummaryView {
|
||||
actions(data);
|
||||
}
|
||||
|
||||
/** « Partie 2 du match en 5 points · Bilan du match » (charte, « Bilan
|
||||
* du match », accès). */
|
||||
function matchLine(data: SummaryData): void {
|
||||
const match = data.match;
|
||||
if (match === null) {
|
||||
return;
|
||||
}
|
||||
const line = element(panel, "p", {
|
||||
id: "summary-match",
|
||||
className: "caption summary-match",
|
||||
});
|
||||
line.append(`${MATCH_SUMMARY_TEXTS.gameOfMatch(match.number, match.length)} · `);
|
||||
const link = element(line, "a", {
|
||||
id: "summary-match-link",
|
||||
text: MATCH_SUMMARY_TEXTS.seeMatchSummary,
|
||||
});
|
||||
link.href = routeHash({ screen: "matchSummary", match: match.id });
|
||||
}
|
||||
|
||||
function counts(summary: GameSummary): void {
|
||||
const box = element(panel, "div", { id: "summary-counts", className: "summary-counts" });
|
||||
box.setAttribute("role", "list");
|
||||
|
||||
@@ -399,3 +399,22 @@ test("le prompt « Bilan de mon match » cite le videau en chances de gagner le
|
||||
assert.match(prompt, /partie 4, coup 1\) : la position avant ma décision/);
|
||||
assert.equal(position.positionId, "wN1tAwADAAAAAA");
|
||||
});
|
||||
|
||||
test("une décision de videau dont la perte s'écrirait 0,0 % n'est pas listée", () => {
|
||||
const fourth = comeback[3] as MatchGame;
|
||||
const review = fourth.journal.review;
|
||||
assert.ok(review?.matchLosses !== undefined);
|
||||
const tiny = Object.fromEntries(Object.keys(review.matchLosses).map((id) => [id, -0.0004]));
|
||||
const games = comeback.map((g, i) =>
|
||||
i === 3 ? { ...g, journal: { ...g.journal, review: { ...review, matchLosses: tiny } } } : g,
|
||||
);
|
||||
const match = groupMatches(games).matches[0];
|
||||
assert.ok(match !== undefined);
|
||||
const summary = summarizeMatch(match);
|
||||
assert.equal(summary.cubeErrors.length, 0);
|
||||
assert.equal(summary.cubeDecisions, 1);
|
||||
assert.equal(
|
||||
matchCubeSentence(phrases, summary.cubeDecisions, 0),
|
||||
"Une seule décision de videau, comme je l'aurais prise.",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -49,6 +49,9 @@ const TABLE: [string, Route][] = [
|
||||
// La progression (étape 1h) et son prompt « Créer des exercices ».
|
||||
["#/progression", { screen: "progression" }],
|
||||
["#/progression/ia", { screen: "progression", ai: true }],
|
||||
// Le bilan d'un match entier (étape 1l) et son prompt.
|
||||
["#/matchs/mh3k2-a1b2c3/bilan", { screen: "matchSummary", match: "mh3k2-a1b2c3" }],
|
||||
["#/matchs/mh3k2-a1b2c3/bilan/ia", { screen: "matchSummary", match: "mh3k2-a1b2c3", ai: true }],
|
||||
["#/menu", { screen: "menu" }],
|
||||
["#/nouvelle-partie", { screen: "newGame" }],
|
||||
["#/explication/12", { screen: "explanation", event: "12" }],
|
||||
@@ -131,6 +134,11 @@ test("une adresse inconnue est reconnue comme telle", () => {
|
||||
"#/parties/ab/ia",
|
||||
"#/explication/12/ia/ia",
|
||||
"#/progression/x",
|
||||
"#/matchs",
|
||||
"#/matchs/m1",
|
||||
"#/matchs/M1/bilan",
|
||||
"#/matchs/m1/bilan/x",
|
||||
"#/matchs/m1/analyse",
|
||||
"#/progression/ia/ia",
|
||||
]) {
|
||||
assert.equal(parseRoute(hash).screen, "unknown", hash);
|
||||
|
||||
@@ -227,3 +227,45 @@ cours :
|
||||
- Une leçon est terminée quand tous ses exercices sont réussis ; ce n'est
|
||||
pas enregistré à part, mais déduit des exercices réussis et du texte de la
|
||||
leçon : ajouter un exercice à une leçon la fait repasser « en cours ».
|
||||
|
||||
### 2026-11-13 — Version 3 des événements : l'identifiant de match
|
||||
|
||||
Avec l'analyse d'un match entier (étape 1l), les parties d'un même match
|
||||
doivent se retrouver. Jusqu'ici, rien ne les reliait : chaque partie a son
|
||||
journal (amendement du 2026-11-09), et la suivante ne fait que reprendre le
|
||||
score que la précédente a laissé.
|
||||
|
||||
- Le format des événements passe à la version 3 (`EVENT_VERSION`,
|
||||
`app/src/domain/game/events.ts`) : le match de `GameStarted` porte
|
||||
l'identifiant du match (`match.id`), commun à toutes ses parties. La
|
||||
session de jeu (`app/src/storage/game-session.ts`) donne au match
|
||||
l'identifiant de sa première partie ; la partie suivante le reprend
|
||||
(`nextGameOf`). Le domaine ne tire toujours pas de hasard.
|
||||
- La migration (`migrateJournal`) passe un journal des versions 1 et 2 à la
|
||||
version 3 en changeant seulement le numéro : une partie de match de la
|
||||
version 2 reste sans identifiant, il n'est pas inventé. Testé dans
|
||||
`app/tests/match-analysis.test.ts` et `app/tests/game.test.ts`.
|
||||
- Les matchs joués avant sont rattachés à la lecture, sans rien réécrire
|
||||
(`groupMatches`, `app/src/domain/analysis/match-analysis.ts`) : à partir
|
||||
d'une partie à 0–0, la suivante doit avoir la même longueur et le même
|
||||
niveau, commencer au score où la précédente a fini (partie Crawford
|
||||
comprise), après elle et moins de 12 heures après sa dernière action.
|
||||
Deux candidates, ou une candidate qui pourrait suivre deux parties :
|
||||
la chaîne s'arrête, et les parties restantes gardent leur ligne à part
|
||||
dans « Mes parties ». Un match ainsi rattaché le dit dans les listes et
|
||||
dans son bilan.
|
||||
- Le résumé d'une partie enregistrée gagne `match.id` (facultatif, absent
|
||||
avant la version 3), recalculé à chaque enregistrement. Le schéma
|
||||
IndexedDB ne change pas (version 1).
|
||||
- L'analyse de partie (`review`, amendement du 2026-11-10) gagne deux tables
|
||||
facultatives, pour les parties de match : `matchChances`, les chances du
|
||||
joueur de gagner le match au début de la partie (sous l'identifiant de
|
||||
`GameStarted`), après chaque coup et après la partie (`GameEnded`) ; et
|
||||
`matchLosses`, les chances de gagner le match que chaque décision du
|
||||
joueur lui a coûtées. Les deux viennent du moteur
|
||||
(`engine_match_chances_of` : table d'équité de match de gnubg et
|
||||
`eq2mwc`, comparés à gnubg de bureau dans `tests/reference/`). Le domaine
|
||||
ne lit aucune table d'équité. `REVIEW_VERSION` ne change pas : une
|
||||
analyse enregistrée avant n'a pas ces tables, et l'analyse en
|
||||
arrière-plan les complète ; une table mal formée, ou ses entrées hors du
|
||||
journal, est oubliée à la reprise.
|
||||
|
||||
@@ -244,3 +244,37 @@ Ajoutées avec l'écran de progression (étape 1h), dans le même schéma :
|
||||
la feuille le dit, jamais une page cassée.
|
||||
- Comme « Mes parties », ces adresses n'ont de sens que sur l'appareil qui
|
||||
a joué les parties : ce ne sont pas des liens à partager.
|
||||
|
||||
### 2026-11-13 — Adresses du bilan d'un match
|
||||
|
||||
Ajoutées avec l'analyse d'un match entier (étape 1l), dans le même schéma :
|
||||
|
||||
| Écran | Adresse |
|
||||
| --- | --- |
|
||||
| Bilan d'un match entier | `#/matchs/<id>/bilan` |
|
||||
| Prompt « Bilan de mon match », depuis ce bilan | `#/matchs/<id>/bilan/ia` |
|
||||
|
||||
- `<id>` est l'identifiant du match (ADR 0007, amendement du 2026-11-13) :
|
||||
celui de sa première partie. Pour un match joué avant l'identifiant de
|
||||
match, c'est aussi l'identifiant de sa première partie, retrouvée par le
|
||||
rattachement d'après les scores et les dates.
|
||||
- Le bilan du match est une page, comme la progression : la barre du haut,
|
||||
Échap et le retour du téléphone suffisent. Il s'ouvre depuis la fin de la
|
||||
dernière partie d'un match (« Bilan du match » remplace l'action
|
||||
principale du panneau de fin de partie et du bilan de cette partie), depuis
|
||||
la ligne « Partie n du match en N points · Bilan du match » du bilan de
|
||||
chaque partie de match, et depuis « Mes parties » et la progression, où un
|
||||
match tient en une ligne.
|
||||
- Chaque partie du bilan du match mène à son bilan
|
||||
(`#/parties/<id>/bilan`), chaque décision (lignes du videau, moment
|
||||
décisif, décision à revoir, bulle de la courbe) à l'analyse de sa partie
|
||||
(`#/parties/<id>/analyse/<coup>`). L'analyse d'une partie de match a en
|
||||
tête « Partie 2 sur 5 · 0–2 », avec ‹ et › vers l'analyse des parties
|
||||
voisines.
|
||||
- Le prompt suit la règle des prompts (amendement du 2026-11-10) : sa
|
||||
propre feuille au-dessus du bilan du match (« ‹ Bilan du match »).
|
||||
Rechargée, l'adresse recalcule le prompt à partir des analyses
|
||||
enregistrées ; tant que l'analyse du match n'est pas finie, la feuille le
|
||||
dit.
|
||||
- Comme « Mes parties », ces adresses n'ont de sens que sur l'appareil qui a
|
||||
joué le match. Un match absent donne un message, jamais une page cassée.
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ Repris du cadrage (modules, écrans clés, IA générative en V1) et des ADR 001
|
||||
| 1h. Progression (fait) | Historique des parties et courbe du taux d'erreur | 1b, 1e |
|
||||
| 1i. Plateau soigné | Dessin du plateau aligné sur la charte (`docs/identite/charte/board.js`), animations des pions, glisser-déposer en plus du toucher, double toucher pour le seul coup évident | 0e.3 |
|
||||
| 1k. Retours des joueurs, 2e lot | Crawford signalé sur la barre ; abandon (simple, gammon, backgammon) accepté ou refusé par l'ordinateur selon GNU Backgammon (plan `2026-11-12-retours-joueurs-2.md`) | 1c, 1e |
|
||||
| 1l. Analyse du match | Bilan et courbe d'un match entier (chances de gagner le match), erreurs de videau sur tout le match, prompt et export SGF du match (plan `2026-11-12-analyse-du-match.md`) | 1c, 1e, 1f |
|
||||
| 1l. Analyse du match (fait) | Bilan et courbe d'un match entier (chances de gagner le match), erreurs de videau sur tout le match, prompt et export SGF du match | 1c, 1e, 1f |
|
||||
| 1j. Plan de test | `docs/guide-test-etape-1.md` : parcours du débutant et du joueur de club sur le téléphone, avec ce qu'il faut rapporter | toutes |
|
||||
|
||||
## Orientation donnée par Pierre
|
||||
|
||||
@@ -41,6 +41,7 @@ exportée. `make test` vérifie le lien dans les deux sens : chaque fiche avec
|
||||
| [Blot](blot.md) | Blot |
|
||||
| [Branche](branche.md) | Branch |
|
||||
| [Chance](chance.md) | Luck |
|
||||
| [Chances de gagner le match](chances-de-gagner-le-match.md) | Match winning chances |
|
||||
| [Compte de points](compte-de-points.md) | Pip count |
|
||||
| [Conseil du maître](conseil-du-maitre.md) | Advice |
|
||||
| [Coup](coup.md) | Move |
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
term: Chances de gagner le match
|
||||
english: Match winning chances
|
||||
code: MatchChances
|
||||
---
|
||||
# Chances de gagner le match
|
||||
|
||||
**En bref** : en match, vos chances de remporter le match entier, et non la seule partie en cours, de 0 à 100 %.
|
||||
|
||||
En match, ce qui compte est le match : gagner une partie d'un point ne vaut
|
||||
pas la même chose à 0–0 qu'à 3–4. GNU Backgammon le mesure en chances de
|
||||
gagner le match (en anglais *match winning chances*, MWC). Avant chaque
|
||||
partie, elles se lisent dans sa table d'équité de match (Kazaross-XG2), qui
|
||||
donne vos chances à chaque score ; pendant la partie, le moteur évalue la
|
||||
position et les convertit avec le videau et le score.
|
||||
|
||||
Le bilan du match trace ces chances d'un bout à l'autre du match : la fin
|
||||
d'une partie est le début de la suivante. Une erreur s'y compte aussi en
|
||||
chances de gagner le match perdues, à une décimale (« −1,2 % »), jamais en
|
||||
[équité](equite.md) : c'est ainsi que GNU Backgammon compte les erreurs dans
|
||||
ses statistiques de match. Une même erreur de [videau](videau.md) coûte plus
|
||||
ou moins selon le score.
|
||||
|
||||
Voir aussi : [Match](match.md), [Courbe des chances de gagner](courbe-des-chances.md), [Équité](equite.md), [Règle de Crawford](regle-de-crawford.md)
|
||||
@@ -1,42 +0,0 @@
|
||||
# Analyse d'un match entier
|
||||
|
||||
- **Date** : 2026-11-12
|
||||
- **Étape** : 1 (demande de Pierre)
|
||||
- **Statut** : prévu (après le 2e lot de retours des joueurs, et une fois les maquettes de la session « identité » disponibles)
|
||||
- **Exécutant** : sous-agent general-purpose, dans un worktree
|
||||
|
||||
## Objectif
|
||||
|
||||
Demande de Pierre du 2026-11-12 : « proposer une analyse complète du match, notamment pour l'utilisation du videau (pas que l'analyse d'une manche) ». Il cite son propre exemple : mené 4-0 après deux parties, il a gagné le match en 5 points trois parties plus tard.
|
||||
|
||||
Aujourd'hui, chaque partie d'un match a son bilan et son analyse (1e), mais rien ne montre le match dans son ensemble.
|
||||
|
||||
## Consignes
|
||||
|
||||
Respecter les ADR 0007, 0008, 0011 et 0013. Suivre les règles et maquettes de la session « identité ».
|
||||
|
||||
1. **Bilan du match.** Une adresse (par exemple `#/matchs/<id>/bilan`) donne :
|
||||
- le résultat et le déroulé du score, partie par partie ;
|
||||
- le taux d'erreur du joueur sur tout le match, à la manière de gnubg (statistiques du match) ;
|
||||
- les erreurs de videau regroupées : doubles manqués, mauvais doubles, prises et refus fautifs ;
|
||||
- le moment décisif ;
|
||||
- « le coup à revoir » du match.
|
||||
2. **Courbe du match.** Elle suit les chances de gagner le match (MWC, tables d'équité de match du moteur) à travers toutes les parties, et non les chances de gagner la partie. Toucher un point ouvre la décision.
|
||||
3. **Données.**
|
||||
- Réutiliser les analyses déjà rangées dans les journaux de chaque partie (`review`).
|
||||
- Relier les parties d'un même match. Aujourd'hui, une partie = un journal (choix de 1c). Il faut un identifiant de match commun, avec un format durable et une migration testée. Les matchs déjà joués sont rattachés si c'est possible, sinon on le dit honnêtement.
|
||||
- Les équités de match viennent du moteur. Le domaine ne fait aucun calcul de table d'équité.
|
||||
4. **Accès.** Depuis le bilan de la dernière partie d'un match, « Voir l'analyse du match ». Depuis « Mes parties » et la progression, le match apparaît comme une entrée.
|
||||
5. **Prompt.** Un gabarit « bilan de mon match », avec un bouton « Demander à une IA » (1f).
|
||||
6. **Export SGF.** Exporter le match entier : MI et toutes les parties.
|
||||
7. **Tests.** Scénario Gherkin d'un match en 5 points avec dés imposés, où le joueur remonte après avoir été mené. Tests unitaires de l'agrégation, référence MWC comparée à gnubg de bureau.
|
||||
|
||||
Tests : `make lint`, `make test`, `make test-browser`, captures pour la recette design.
|
||||
|
||||
## Critères de réussite
|
||||
|
||||
Sur un match joué jusqu'au bout, le bilan du match reprend les erreurs de videau de toutes les parties, et la courbe des chances de gagner le match est continue d'une partie à l'autre. Les trois commandes passent.
|
||||
|
||||
## Résultat
|
||||
|
||||
À remplir à la clôture.
|
||||
+17
-4
@@ -23,10 +23,15 @@
|
||||
# progression gardée), captures dans build/browser-shots/lecons/. La
|
||||
# progression (tests/browser/progression.mjs : cas vide, trois parties, courbe
|
||||
# égale aux taux des bilans, ligne de l'accueil, « Créer des exercices »),
|
||||
# captures dans build/browser-shots/progression/.
|
||||
# captures dans build/browser-shots/progression/. Le bilan d'un match entier
|
||||
# (tests/browser/match-bilan.mjs : un match en 5 points avec dés imposés, où
|
||||
# le joueur remonte après avoir été mené ; courbe continue, bilan, analyse,
|
||||
# « Mes parties », export SGF, prompt), captures dans
|
||||
# build/browser-shots/match-bilan/.
|
||||
#
|
||||
# BROWSERS=chromium et SCRIPTS=accueil (ou play, match, maitre, bilan,
|
||||
# prompts, nouvelle-partie, retours-joueurs, lecons, progression) restreignent le test.
|
||||
# prompts, nouvelle-partie, retours-joueurs, lecons, progression, match-bilan)
|
||||
# restreignent le test.
|
||||
#
|
||||
# Outils : l'image de Playwright (navigateurs) et le paquet playwright,
|
||||
# installé une fois par npm dans build/browser-tools/ (réseau nécessaire la
|
||||
@@ -39,7 +44,7 @@ cd "$(dirname "$0")/.."
|
||||
image="${PLAYWRIGHT_IMAGE:?lancer via make test-browser}"
|
||||
browsers="${BROWSERS:-chromium firefox}"
|
||||
# Les scripts à lancer (tests/browser/<nom>.mjs), tous par défaut.
|
||||
scripts="${SCRIPTS:-play accueil match maitre bilan prompts nouvelle-partie retours-joueurs lecons progression}"
|
||||
scripts="${SCRIPTS:-play accueil match maitre bilan prompts nouvelle-partie retours-joueurs lecons progression match-bilan}"
|
||||
|
||||
unset MAKEFLAGS MFLAGS MAKELEVEL
|
||||
make -s package >/dev/null
|
||||
@@ -78,7 +83,8 @@ rm -rf build/browser-shots
|
||||
mkdir -p build/browser-shots
|
||||
cp tests/browser/play.mjs tests/browser/accueil.mjs tests/browser/match.mjs tests/browser/recette.mjs \
|
||||
tests/browser/maitre.mjs tests/browser/bilan.mjs tests/browser/prompts.mjs tests/browser/nouvelle-partie.mjs \
|
||||
tests/browser/retours-joueurs.mjs tests/browser/lecons.mjs tests/browser/progression.mjs "$tools/"
|
||||
tests/browser/retours-joueurs.mjs tests/browser/lecons.mjs tests/browser/progression.mjs \
|
||||
tests/browser/match-bilan.mjs "$tools/"
|
||||
status=0
|
||||
for browser in $browsers; do
|
||||
# Réseau de l'hôte : le site est sur 127.0.0.1. Le service worker
|
||||
@@ -155,5 +161,12 @@ for browser in $browsers; do
|
||||
-v "$PWD/$tools:/tools" -v "$PWD/build/browser-shots:/shots" -w /tools "$image" \
|
||||
node progression.mjs "http://localhost:$port/" "$browser" /shots || status=1
|
||||
fi
|
||||
if [[ " $scripts " == *" match-bilan "* ]]; then
|
||||
# Le bilan d'un match entier (étape 1l) ; captures dans
|
||||
# build/browser-shots/match-bilan/.
|
||||
docker run --rm --init --ipc=host --network host --user "$(id -u):$(id -g)" -e HOME=/tmp \
|
||||
-v "$PWD/$tools:/tools" -v "$PWD/build/browser-shots:/shots" -w /tools "$image" \
|
||||
node match-bilan.mjs "http://localhost:$port/" "$browser" /shots || status=1
|
||||
fi
|
||||
done
|
||||
exit "$status"
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
// match-bilan.mjs -- le bilan d'un match entier (étape 1l) : un match en 5
|
||||
// points joué par l'interface avec des dés imposés, où le joueur est mené
|
||||
// puis remonte et gagne ; puis la courbe continue des chances de gagner le
|
||||
// match, le bilan, la courbe touchée, l'analyse d'une partie de match,
|
||||
// « Mes parties » et l'export SGF (plan 2026-11-12-analyse-du-match.md ;
|
||||
// charte, ecrans-etape-1.md, « Bilan du match »).
|
||||
//
|
||||
// Copyright (C) 2026 les auteurs d'Ustagammon.
|
||||
// Licence : GPLv3 ou ultérieure (voir LICENSE).
|
||||
//
|
||||
// Usage : node match-bilan.mjs <adresse du site> <chromium|firefox> <dossier des captures>
|
||||
// Lancé par tests/browser.sh. Les dés sont imposés à chaque jet : d'abord
|
||||
// 2-1 pour le joueur et 6-5 pour l'ordinateur, jusqu'à ce que l'ordinateur
|
||||
// mène d'au moins deux points ; puis l'inverse, jusqu'à la fin du match.
|
||||
// Le joueur ne double jamais, passe les doubles de l'ordinateur quand il
|
||||
// est mené et les prend ensuite, et joue le premier pion jouable vers sa
|
||||
// première case d'arrivée. Le jet d'ouverture vient d'une graine fixe.
|
||||
// Captures (Chromium) dans <dossier des captures>/match-bilan/, en 412×915
|
||||
// et 915×412 : le bilan du match, la courbe touchée, « Mes parties » avec
|
||||
// le match, et l'en-tête de l'analyse d'une partie du match.
|
||||
|
||||
import { mkdirSync, readFileSync } from "node:fs";
|
||||
import { chromium, firefox } from "playwright";
|
||||
import { hiddenUnderActionBar, tallButtons } from "./recette.mjs";
|
||||
|
||||
const [base, browserName, shots] = process.argv.slice(2);
|
||||
const browserType = { chromium, firefox }[browserName];
|
||||
if (!base || !browserType || !shots) {
|
||||
console.error("usage : node match-bilan.mjs <adresse> <chromium|firefox> <dossier des captures>");
|
||||
process.exit(2);
|
||||
}
|
||||
const full = browserName === "chromium";
|
||||
const dir = `${shots}/match-bilan`;
|
||||
mkdirSync(dir, { recursive: true });
|
||||
const PORTRAIT = { width: 412, height: 915 };
|
||||
const LANDSCAPE = { width: 915, height: 412 };
|
||||
const SIZES = [PORTRAIT, LANDSCAPE];
|
||||
// Les dés : [joueur, ordinateur], selon que l'ordinateur doit mener ou que
|
||||
// le joueur remonte.
|
||||
const LEADING = { player: [2, 1], computer: [6, 5] };
|
||||
const COMEBACK = { player: [6, 5], computer: [2, 1] };
|
||||
|
||||
const problems = [];
|
||||
const log = (text) => console.log(`[${browserName}] ${text}`);
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
let captures = 0;
|
||||
|
||||
function check(condition, message) {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
const browser = await browserType.launch();
|
||||
const context = await browser.newContext({
|
||||
viewport: PORTRAIT,
|
||||
deviceScaleFactor: 1,
|
||||
locale: "fr-FR",
|
||||
reducedMotion: "reduce",
|
||||
acceptDownloads: true,
|
||||
});
|
||||
await context.addInitScript(() => {
|
||||
// Les dés imposés d'abord (un dé par valeur), puis une graine fixe.
|
||||
window.__dice = [];
|
||||
let state = 11;
|
||||
Math.random = () => {
|
||||
const die = window.__dice.shift();
|
||||
if (die !== undefined) {
|
||||
return (die - 0.5) / 6;
|
||||
}
|
||||
state = (state * 1103515245 + 12345) % 2147483648;
|
||||
return state / 2147483648;
|
||||
};
|
||||
window.__csp = [];
|
||||
document.addEventListener("securitypolicyviolation", (e) =>
|
||||
window.__csp.push(`${e.effectiveDirective} ${e.blockedURI}`),
|
||||
);
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.on("pageerror", (error) => problems.push(`erreur de la page : ${error.message}`));
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") {
|
||||
problems.push(`console : ${message.text()}`);
|
||||
}
|
||||
});
|
||||
|
||||
/** Attend une condition dans la page (sans page.waitForFunction, qui passe
|
||||
* par eval, interdit par la politique de sécurité du site). */
|
||||
async function until(what, fn, arg, ms = 180_000) {
|
||||
for (let waited = 0; waited < ms; waited += 100) {
|
||||
if (await page.evaluate(fn, arg)) {
|
||||
return;
|
||||
}
|
||||
await sleep(100);
|
||||
}
|
||||
await page.screenshot({ path: `${dir}/${browserName}-bloque.png` }).catch(() => {});
|
||||
throw new Error(`attente trop longue : ${what}`);
|
||||
}
|
||||
|
||||
/** Une capture de la recette en portrait et en paysage (Chromium
|
||||
* seulement), après les règles communes. */
|
||||
async function capture(name, before = async () => {}) {
|
||||
if (!full) {
|
||||
return;
|
||||
}
|
||||
for (const size of SIZES) {
|
||||
await page.setViewportSize(size);
|
||||
await sleep(300);
|
||||
await before();
|
||||
const hidden = await hiddenUnderActionBar(page);
|
||||
check(hidden.length === 0,
|
||||
`${name} ${size.width}x${size.height} : caché sous la barre d'action : ${hidden.join(", ")}`);
|
||||
const tall = await tallButtons(page);
|
||||
check(tall.length === 0, `${name} ${size.width}x${size.height} : boutons étirés : ${tall.join(", ")}`);
|
||||
await page.screenshot({ path: `${dir}/${name}-${size.width}x${size.height}.png`, fullPage: true });
|
||||
captures++;
|
||||
}
|
||||
await page.setViewportSize(PORTRAIT);
|
||||
await sleep(300);
|
||||
}
|
||||
|
||||
/** Les dés à imposer : vide la file, puis y met ceux-ci. */
|
||||
const setDice = (dice) => page.evaluate((d) => {
|
||||
window.__dice.length = 0;
|
||||
window.__dice.push(...d);
|
||||
}, dice);
|
||||
/** Ajoute les dés du prochain jet de l'ordinateur, s'ils manquent. */
|
||||
const ensureComputerDice = (dice) => page.evaluate((d) => {
|
||||
if (window.__dice.length < 2) {
|
||||
window.__dice.push(...d);
|
||||
}
|
||||
}, dice);
|
||||
|
||||
/** Le score du match tel que l'écran le montre. */
|
||||
const score = () => page.evaluate(() => ({
|
||||
computer: Number(document.querySelector("#strip-computer .match-score")?.textContent ?? "0"),
|
||||
player: Number(document.querySelector("#strip-player .match-score")?.textContent ?? "0"),
|
||||
}));
|
||||
|
||||
/** Ce que le joueur a à faire (comme tests/browser/match.mjs). */
|
||||
async function todo() {
|
||||
for (let i = 0; i < 1200; i++) {
|
||||
const what = await page.evaluate(() => {
|
||||
if (document.body.classList.contains("busy")) {
|
||||
return null;
|
||||
}
|
||||
const panel = document.getElementById("panel-veil");
|
||||
if (!panel.hidden) {
|
||||
return panel.dataset.kind;
|
||||
}
|
||||
if (!document.getElementById("summary-veil").hidden) {
|
||||
return "over";
|
||||
}
|
||||
const usable = (id) => {
|
||||
const b = document.getElementById(id);
|
||||
return !b.hidden && !b.disabled;
|
||||
};
|
||||
for (const id of ["take", "skip", "confirm", "roll"]) {
|
||||
if (usable(id)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return document.querySelector(".hit.can-move") ? "move" : null;
|
||||
});
|
||||
if (what !== null) {
|
||||
return what;
|
||||
}
|
||||
await sleep(100);
|
||||
}
|
||||
await page.screenshot({ path: `${dir}/${browserName}-bloque.png` }).catch(() => {});
|
||||
throw new Error(`rien à faire depuis 120 s : « ${await page.textContent("#info")} »`);
|
||||
}
|
||||
|
||||
// ------------------------------------------------- Le match, joué
|
||||
|
||||
await page.goto(`${base}#/nouvelle-partie`);
|
||||
await until("moteur chargé", () => !document.getElementById("new-game-start").disabled);
|
||||
await page.click("#new-game-match");
|
||||
await page.click("#new-game-length-5");
|
||||
await page.click("#new-game-level-beginner");
|
||||
await page.click("#new-game-start");
|
||||
await until("match commencé", () => location.hash === "#/" && !document.body.classList.contains("busy"));
|
||||
|
||||
let games = 1;
|
||||
let deepest = { player: 0, computer: 0 };
|
||||
let dice = LEADING;
|
||||
let actions = 0;
|
||||
for (;;) {
|
||||
check(actions++ < 20000, "le match ne finit pas");
|
||||
const what = await todo();
|
||||
if (what === "over") {
|
||||
await page.evaluate(() => {
|
||||
window.__dice.length = 0;
|
||||
});
|
||||
await until("bilan de la partie prêt", () =>
|
||||
document.getElementById("summary")?.dataset.ready === "true", null, 300_000);
|
||||
const primary = await page.textContent("#summary-primary");
|
||||
const now = await page.evaluate(() => {
|
||||
const detail = document.getElementById("summary-reading").textContent;
|
||||
const m = /vous (\d+), l'ordinateur (\d+)/.exec(detail);
|
||||
return m === null ? null : { player: Number(m[1]), computer: Number(m[2]) };
|
||||
});
|
||||
check(now !== null, "score du match absent du bilan de la partie");
|
||||
log(`partie ${games} : ${await page.textContent("#summary-title")} ; vous ${now.player}, l'ordinateur ${now.computer}`);
|
||||
// Le bilan d'une partie de match renvoie au bilan du match.
|
||||
const line = await page.textContent("#summary-match");
|
||||
check(line.startsWith(`Partie ${games} du match en 5 points · Bilan du match`),
|
||||
`ligne du match dans le bilan de la partie : « ${line} »`);
|
||||
if (now.computer - now.player > deepest.computer - deepest.player) {
|
||||
deepest = now;
|
||||
}
|
||||
if (primary === "Bilan du match") {
|
||||
check(now.player >= 5 && now.computer < 5, `le joueur devait gagner le match : ${JSON.stringify(now)}`);
|
||||
break;
|
||||
}
|
||||
check(primary === "Partie suivante", `fin de partie : « ${primary} »`);
|
||||
// L'ordinateur mène d'au moins deux points : le joueur remonte.
|
||||
dice = now.computer - now.player >= 2 ? COMEBACK : LEADING;
|
||||
await page.click("#summary-primary");
|
||||
games++;
|
||||
await until("partie suivante", () => !document.body.classList.contains("busy") &&
|
||||
document.getElementById("summary-veil").hidden);
|
||||
continue;
|
||||
}
|
||||
if (what === "doubled" || what === "take") {
|
||||
// Mené, le joueur passe ; ensuite il prend.
|
||||
if (dice === LEADING) {
|
||||
await page.click(what === "doubled" ? "#panel-secondary" : "#drop");
|
||||
} else {
|
||||
await ensureComputerDice(dice.computer);
|
||||
await page.click(what === "doubled" ? "#panel-primary" : "#take");
|
||||
}
|
||||
} else if (what === "roll") {
|
||||
await setDice([...dice.player, ...dice.computer]);
|
||||
await page.click("#roll");
|
||||
} else if (what === "skip" || what === "confirm") {
|
||||
await ensureComputerDice(dice.computer);
|
||||
await page.click(`#${what}`);
|
||||
} else if (what === "move") {
|
||||
await page.click(".hit.can-move");
|
||||
if ((await page.locator(".hit.can-land").count()) > 0) {
|
||||
await page.click(".hit.can-land");
|
||||
}
|
||||
}
|
||||
}
|
||||
check(deepest.computer - deepest.player >= 2, `le joueur n'a jamais été mené : ${JSON.stringify(deepest)}`);
|
||||
log(`match gagné en ${games} parties, après avoir été mené ${deepest.player} à ${deepest.computer} (${actions} actions)`);
|
||||
|
||||
// ----------------------------------------------- Le bilan du match
|
||||
|
||||
await page.click("#summary-primary");
|
||||
await until("bilan du match", () => /^#\/matchs\/[a-z0-9-]+\/bilan$/.test(location.hash) &&
|
||||
document.getElementById("match-title") !== null);
|
||||
const matchHash = await page.evaluate(() => location.hash);
|
||||
// Toutes les analyses : la courbe complète, en chances de gagner le match.
|
||||
await until("courbe complète", () => {
|
||||
const svg = document.getElementById("match-curve");
|
||||
const points = svg === null ? [] : JSON.parse(svg.dataset.points ?? "[]");
|
||||
return document.getElementById("match-summary").dataset.ready === "true" &&
|
||||
points.length > 0 && points.every((p) => p[2] !== null);
|
||||
}, null, 900_000);
|
||||
const bilan = await page.evaluate(() => ({
|
||||
overline: document.getElementById("match-overline").textContent,
|
||||
title: document.getElementById("match-title").textContent,
|
||||
sentence: document.getElementById("match-sentence").textContent,
|
||||
points: JSON.parse(document.getElementById("match-curve").dataset.points),
|
||||
lines: document.querySelectorAll("#match-curve polyline").length,
|
||||
label: document.getElementById("match-curve").getAttribute("aria-label"),
|
||||
rows: [...document.querySelectorAll("#match-games .match-game-score")].map((e) => e.textContent),
|
||||
tiles: [...document.querySelectorAll(".match-tile strong")].map((e) => e.textContent),
|
||||
cube: document.getElementById("match-cube-sentence")?.textContent ?? "",
|
||||
decisive: document.getElementById("match-decisive-sentence")?.textContent ?? "",
|
||||
review: document.getElementById("match-to-review") !== null,
|
||||
exportText: document.getElementById("match-export")?.textContent,
|
||||
gameIds: [...document.querySelectorAll("#match-games a")].map((a) =>
|
||||
/^#\/parties\/([a-z0-9-]+)\/bilan$/.exec(a.getAttribute("href"))?.[1]),
|
||||
}));
|
||||
log(`bilan : ${bilan.title} ; ${bilan.sentence} ; ${bilan.points.length} points ; videau : ${bilan.cube}`);
|
||||
check(bilan.overline.startsWith("Fin du match · 5 points · "), `en-tête : « ${bilan.overline} »`);
|
||||
check(bilan.title === "Vous gagnez le match", `titre : « ${bilan.title} »`);
|
||||
check(new RegExp(`^5 à \\d, en \\S+ parties?, après avoir été mené ${deepest.player} à ${deepest.computer}\\.$`)
|
||||
.test(bilan.sentence) || /après avoir été mené \d à \d\.$/.test(bilan.sentence),
|
||||
`phrase de l'en-tête : « ${bilan.sentence} »`);
|
||||
// La courbe : une seule ligne, du début du match (50 %) à sa fin (100 %),
|
||||
// les parties dans l'ordre, chacune à la suite de la précédente.
|
||||
check(bilan.lines === 1, `${bilan.lines} lignes sur la courbe au lieu d'une`);
|
||||
check(bilan.points[0][2] === 0.5 && bilan.points.at(-1)[2] === 1,
|
||||
`courbe : début ${bilan.points[0][2]}, fin ${bilan.points.at(-1)[2]}`);
|
||||
const order = bilan.points.map((p) => p[0]);
|
||||
check(order.every((g, i) => i === 0 || g === order[i - 1] || g === order[i - 1] + 1) && order.at(-1) === games,
|
||||
`courbe : parties dans le désordre ${JSON.stringify(order)}`);
|
||||
check(bilan.points.every((p) => p[2] >= 0 && p[2] <= 1), "courbe : chances hors de 0 à 100 %");
|
||||
check(/^Courbe de vos chances de gagner le match : 50\s% au départ/.test(bilan.label),
|
||||
`libellé de la courbe : « ${bilan.label} »`);
|
||||
check(bilan.gameIds.length === games && bilan.gameIds.every((id) => id !== undefined),
|
||||
`liens des parties : ${JSON.stringify(bilan.gameIds)}`);
|
||||
check(bilan.rows.length === games && bilan.rows.at(-1).startsWith("5–"),
|
||||
`partie par partie : ${JSON.stringify(bilan.rows)}`);
|
||||
check(bilan.tiles.length === 3, "tuiles du jeu");
|
||||
check(/décision|Aucune décision/.test(bilan.cube), `phrase du videau : « ${bilan.cube} »`);
|
||||
check(/vos chances de gagner le match passent de \d+\s% à \d+\s%\. C'est le plus grand écart du match\.$/
|
||||
.test(bilan.decisive), `moment décisif : « ${bilan.decisive} »`);
|
||||
check(bilan.exportText === "Exporter le match (SGF)", "lien d'export");
|
||||
// En match, les pertes s'écrivent en chances de gagner le match, jamais en
|
||||
// équité.
|
||||
const losses = await page.evaluate(() =>
|
||||
[...document.querySelectorAll("#match-summary .match-loss")].map((e) => e.textContent));
|
||||
check(losses.every((t) => /^−?\d+,\d\s%( de chances de gagner le match)?$/.test(t)),
|
||||
`pertes : ${JSON.stringify(losses)}`);
|
||||
await capture("1-bilan-du-match");
|
||||
|
||||
// La courbe touchée : la bulle (partie, coup, score, chances), un lien vers
|
||||
// la décision.
|
||||
const touchCurve = async () => {
|
||||
const box = await page.locator("#match-curve").boundingBox();
|
||||
await page.mouse.move(box.x + box.width * 0.55, box.y + box.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(box.x + box.width * 0.6, box.y + box.height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await until("bulle de la courbe", () => document.getElementById("match-bubble") !== null, null, 10_000);
|
||||
};
|
||||
await page.locator("#match-curve").scrollIntoViewIfNeeded();
|
||||
await touchCurve();
|
||||
const bubble = await page.evaluate(() => ({
|
||||
href: document.getElementById("match-bubble").getAttribute("href"),
|
||||
text: document.querySelector("#match-bubble .match-bubble-text").textContent,
|
||||
}));
|
||||
check(/^#\/parties\/[a-z0-9-]+\/analyse\/\d+$/.test(bubble.href), `lien de la bulle : ${bubble.href}`);
|
||||
check(/^Partie \d, coup \d+ · \d–\d · \d+\s%$/.test(bubble.text), `bulle : « ${bubble.text} »`);
|
||||
await capture("2-courbe-touchee", async () => {
|
||||
await page.locator("#match-curve").scrollIntoViewIfNeeded();
|
||||
await touchCurve();
|
||||
});
|
||||
// Au clavier aussi : ← → d'une décision à l'autre.
|
||||
await page.focus("#match-curve");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
check(await page.evaluate(() => document.getElementById("match-bubble") !== null), "bulle au clavier");
|
||||
|
||||
// Toucher la bulle ouvre la décision, dans l'analyse de sa partie : en tête,
|
||||
// la partie dans le match, avec ‹ et ›.
|
||||
await page.locator("#match-curve").scrollIntoViewIfNeeded();
|
||||
await touchCurve();
|
||||
await page.click("#match-bubble");
|
||||
await until("analyse d'une partie du match", () =>
|
||||
/^#\/parties\/[a-z0-9-]+\/analyse\/\d+$/.test(location.hash) &&
|
||||
!document.getElementById("analysis-match").hidden);
|
||||
const header = await page.textContent("#analysis-match-title");
|
||||
check(new RegExp(`^Partie \\d sur ${games} · \\d–\\d$`).test(header), `en-tête de l'analyse : « ${header} »`);
|
||||
await capture("3-analyse-partie-de-match", async () => {
|
||||
await page.evaluate(() => window.scrollTo(0, 0));
|
||||
});
|
||||
// « › » mène à la partie suivante, « ‹ » à la précédente.
|
||||
const before = await page.evaluate(() => location.hash);
|
||||
const nextHref = await page.getAttribute("#analysis-next-game", "href");
|
||||
const previousHref = await page.getAttribute("#analysis-previous-game", "href");
|
||||
check(nextHref !== null || previousHref !== null, "aucune partie voisine dans l'en-tête de l'analyse");
|
||||
await page.click(nextHref !== null ? "#analysis-next-game" : "#analysis-previous-game");
|
||||
await until("autre partie du match", (h) => location.hash !== h &&
|
||||
/^Partie \d sur/.test(document.getElementById("analysis-match-title").textContent), before);
|
||||
|
||||
// « Mes parties » : le match tient en une ligne.
|
||||
await page.goto(`${base}#/parties`);
|
||||
await until("Mes parties", () => document.querySelector("#games .games-match") !== null);
|
||||
const line = await page.evaluate((ids) => {
|
||||
const item = document.querySelector("#games .games-match");
|
||||
return {
|
||||
title: item.querySelector("strong").textContent,
|
||||
strokes: item.querySelectorAll(".match-stroke").length,
|
||||
won: item.querySelectorAll(".match-stroke.won").length,
|
||||
href: item.querySelector("a").getAttribute("href"),
|
||||
// Les parties du match n'ont plus leur propre ligne.
|
||||
others: ids.filter((id) => document.querySelector(`#games .games-item[data-id="${id}"]`) !== null)
|
||||
.length,
|
||||
};
|
||||
}, bilan.gameIds);
|
||||
check(/^Match en 5 points · gagné 5–\d$/.test(line.title), `ligne du match : « ${line.title} »`);
|
||||
check(line.strokes === games && line.won >= 2, `traits du match : ${JSON.stringify(line)}`);
|
||||
check(line.href === matchHash, `la ligne du match ouvre ${line.href}`);
|
||||
check(line.others === 0, `${line.others} parties du match listées à part`);
|
||||
await capture("4-mes-parties");
|
||||
|
||||
// La progression : le match en une ligne aussi.
|
||||
await page.goto(`${base}#/progression`);
|
||||
await until("progression", () => document.querySelector("#progression-list .match-line") !== null);
|
||||
|
||||
// Retour au bilan du match : export SGF du match entier.
|
||||
await page.goto(`${base}${matchHash}`);
|
||||
await until("bilan du match relu", () => document.getElementById("match-export") !== null);
|
||||
const [download] = await Promise.all([page.waitForEvent("download"), page.click("#match-export")]);
|
||||
const sgf = readFileSync(await download.path(), "utf8");
|
||||
const infos = [...sgf.matchAll(/MI\[length:5\]\[game:(\d+)\]/g)].map((m) => Number(m[1]));
|
||||
check(JSON.stringify(infos) === JSON.stringify([...Array(games).keys()]),
|
||||
`export SGF : parties ${JSON.stringify(infos)}`);
|
||||
check(download.suggestedFilename().startsWith("ustagammon-match-"), `nom du fichier : ${download.suggestedFilename()}`);
|
||||
|
||||
// « Demander à une IA » : le prompt « Bilan de mon match ».
|
||||
await page.click("#match-ask-ai");
|
||||
await until("prompt du match", () => /\/bilan\/ia$/.test(location.hash) &&
|
||||
(document.getElementById("prompt-text")?.textContent ?? "").includes("match en 5 points"));
|
||||
const prompt = await page.textContent("#prompt-text");
|
||||
check(prompt.includes("j'ai gagné le match 5 à") && prompt.includes("Le videau :"), "prompt du match incomplet");
|
||||
|
||||
const csp = await page.evaluate(() => window.__csp);
|
||||
check(csp.length === 0, `violations de la politique de sécurité : ${csp.join(", ")}`);
|
||||
await browser.close();
|
||||
if (problems.length > 0) {
|
||||
throw new Error(problems.join("\n"));
|
||||
}
|
||||
log(`bilan du match : ${captures} captures dans ${dir}`);
|
||||
@@ -301,7 +301,9 @@ for (;;) {
|
||||
});
|
||||
check(settingsLink?.text === "Changer les réglages" && settingsLink.href === "#/nouvelle-partie",
|
||||
`lien « Changer les réglages » : ${JSON.stringify(settingsLink)}`);
|
||||
if (primary === "Rejouer") {
|
||||
// À la fin du match, le bilan de la dernière partie mène au bilan
|
||||
// du match (étape 1l) ; « Rejouer » reste sous le plateau.
|
||||
if (primary === "Bilan du match") {
|
||||
check(/gagne(z)? le match$/.test(title) && detail.includes("Score final"),
|
||||
`fin du match : ${title} ; ${detail}`);
|
||||
const [, player, computer] = /vous (\d+), l'ordinateur (\d+)/.exec(detail) ?? [];
|
||||
|
||||
+265
@@ -3948,3 +3948,268 @@ html.landscape .prompting .prompt-text {
|
||||
.viewer-actions {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ------------------------------------------- Bilan du match (1l) */
|
||||
|
||||
/* Charte, ecrans-etape-1.md, « Bilan du match » : une page qui défile ; en
|
||||
* paysage, deux colonnes (l'en-tête, la courbe et les parties à gauche ; le
|
||||
* jeu, le videau, le moment décisif, la décision à revoir et les actions à
|
||||
* droite). */
|
||||
.match-summary {
|
||||
max-width: var(--page-width);
|
||||
}
|
||||
|
||||
html.landscape .match-summary {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
column-gap: var(--space-6);
|
||||
align-items: start;
|
||||
max-width: 60rem;
|
||||
}
|
||||
|
||||
.match-column {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.match-head .overline {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
|
||||
.match-head .progression-title {
|
||||
margin-top: var(--space-1);
|
||||
}
|
||||
|
||||
/* La courbe : la zone tactile est tout son cadre. */
|
||||
.match-curve {
|
||||
height: 196px;
|
||||
}
|
||||
|
||||
.match-crawford { fill: var(--surface-sunken); }
|
||||
.match-separator { stroke: var(--border); stroke-width: 1; }
|
||||
.match-score { fill: var(--text); font-weight: 700; }
|
||||
.match-mark-ring { fill: none; stroke: var(--last-move); stroke-width: 3; }
|
||||
.match-mark-review { fill: var(--verdict-bad); }
|
||||
.match-mark-end { fill: var(--text); }
|
||||
.match-mark-end.won { fill: var(--verdict-good); }
|
||||
|
||||
.match-bubble { cursor: pointer; }
|
||||
.match-bubble-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; }
|
||||
.match-bubble-text { fill: var(--text); font-size: 13px; font-weight: 700; }
|
||||
.match-bubble-hint { fill: var(--accent); font-size: 12px; text-decoration: underline; }
|
||||
|
||||
/* La légende : trois marques, sans autre couleur. */
|
||||
.match-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1) var(--space-3);
|
||||
margin: var(--space-2) 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.match-legend li {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.match-mark {
|
||||
display: inline-block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.match-mark.decisive { border: 3px solid var(--last-move); }
|
||||
.match-mark.review { background: var(--verdict-bad); }
|
||||
.match-mark.end { background: var(--text); }
|
||||
.match-mark.end.won { background: var(--verdict-good); }
|
||||
|
||||
/* « Partie par partie » : une ligne de 52 px par partie, le score après
|
||||
* la partie en chiffres gras à droite. */
|
||||
.match-games {
|
||||
margin: 0 0 var(--space-4);
|
||||
}
|
||||
|
||||
.match-games > .caption {
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
|
||||
.match-game {
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.match-game-score {
|
||||
flex: none;
|
||||
font-size: 22px;
|
||||
line-height: 26px;
|
||||
font-weight: 800;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* « Votre jeu sur le match » : trois tuiles, puis les jauges. */
|
||||
.match-tiles {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: var(--space-2);
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.match-tile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: var(--space-2);
|
||||
background: var(--surface-sunken);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.match-tile strong {
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.match-sentence {
|
||||
margin: 0 0 var(--space-2);
|
||||
}
|
||||
|
||||
.match-cube-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
margin: 0 0 var(--space-2);
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.match-cube-row {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
min-height: 52px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.match-cube-row > .icon {
|
||||
flex: none;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* Une perte, colorée comme le verdict. */
|
||||
.match-loss {
|
||||
flex: none;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.match-loss[data-verdict="doubtful"] { color: var(--verdict-doubtful); }
|
||||
.match-loss[data-verdict="bad"],
|
||||
.match-loss[data-verdict="veryBad"] { color: var(--verdict-bad); }
|
||||
|
||||
.match-agreement {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.match-summary .summary-review {
|
||||
padding-top: var(--space-3);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.match-summary .summary-verdict {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.match-summary .summary-master {
|
||||
margin: var(--space-1) 0 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.match-export {
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
.match-actions {
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.match-actions > * {
|
||||
flex: 1 1 0;
|
||||
height: var(--button-height);
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
/* Sous l'en-tête du bilan d'une partie de match. */
|
||||
.summary-match {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.summary-match a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 44px;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
/* En tête de l'analyse d'une partie de match : « ‹ Partie 2 sur 5 · 0–2 › ». */
|
||||
.analysis-match {
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
#analysis-previous-game .icon {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.analysis-match .viewer-step:not([href]) {
|
||||
opacity: 0.35;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Un match en une ligne (« Mes parties », progression) : un trait par
|
||||
* partie, vert si vous l'avez gagnée ; en pointillés, la partie à venir
|
||||
* d'un match en cours. */
|
||||
.match-line {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.match-line-link {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.match-strokes {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
.match-stroke {
|
||||
width: 18px;
|
||||
height: 0;
|
||||
border-top: 4px solid var(--border-strong);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.match-stroke.won { border-top-color: var(--verdict-good); }
|
||||
.match-stroke.next { border-top: 3px dashed var(--border-strong); }
|
||||
|
||||
.match-resume {
|
||||
flex: none;
|
||||
margin-right: var(--space-2);
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.games-match .match-line {
|
||||
padding: var(--space-1) 0;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@
|
||||
parties terminées, construite par app/src/ui/progression-view.ts. -->
|
||||
<section id="progression" class="analysis progression page" hidden></section>
|
||||
|
||||
<!-- Le bilan d'un match entier (#/matchs/<id>/bilan, étape 1l), construit
|
||||
par app/src/ui/match-summary-view.ts. -->
|
||||
<section id="match-summary" class="analysis match-summary page" hidden></section>
|
||||
|
||||
<!-- L'aide : un onglet par adresse (#/aide, #/glossaire, #/a-propos). -->
|
||||
<section id="help" class="help page" hidden>
|
||||
<!-- La barre haute de l'aide reste en vue quand la page défile. -->
|
||||
|
||||
Reference in New Issue
Block a user