Recette 1l : libellés de la courbe à 12 px, moment décisif en fin de match, ligne du match, Crawford, tuiles
La courbe du match suit sa taille réelle (viewBox recalculé, redessinée à chaque changement de taille) ; un contrôle de la recette vérifie les 12 px. Le moment décisif sur la fin du match garde l'anneau or seul. Ligne du match alignée à gauche, « contre Débutant ». « · Crawford » dans l'en-tête de l'analyse. Une seule légende sous les tuiles, avec la fiche. « Sur ce double passé ». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
36bb9be384
commit
991a52787d
@@ -59,6 +59,8 @@ export interface AnalysisMatch {
|
||||
readonly total: number;
|
||||
/** « 0–2 », vous – l'ordinateur. */
|
||||
readonly score: string;
|
||||
/** C'est la partie Crawford du match. */
|
||||
readonly crawford: boolean;
|
||||
readonly previous: string | null;
|
||||
readonly next: string | null;
|
||||
}
|
||||
@@ -705,6 +707,7 @@ export function createAnalysisView(options: AnalysisViewOptions): AnalysisView {
|
||||
match.number,
|
||||
match.total,
|
||||
match.score,
|
||||
match.crawford,
|
||||
);
|
||||
for (const [link, id] of [
|
||||
[previousGame, match.previous],
|
||||
|
||||
@@ -2089,6 +2089,7 @@ export function startApp(options: AppOptions): void {
|
||||
number,
|
||||
total: games.length,
|
||||
score: start === null ? "" : matchScoreText(start.score),
|
||||
crawford: start?.crawford ?? false,
|
||||
previous: games[number - 2]?.id ?? null,
|
||||
next: games[number]?.id ?? null,
|
||||
};
|
||||
|
||||
@@ -72,6 +72,8 @@ export const MATCH_SUMMARY_TEXTS = {
|
||||
legendDecisive: "Moment décisif",
|
||||
legendReview: "Décision à revoir",
|
||||
legendEnd: "Fin du match",
|
||||
/** Le moment décisif tombe sur la fin du match : une seule marque. */
|
||||
legendDecisiveEnd: "Moment décisif, fin du match",
|
||||
bubble: (game: number, turn: number | null, score: string, chance: string) =>
|
||||
turn === null
|
||||
? `Début du match · ${score} · ${chance}`
|
||||
@@ -106,8 +108,8 @@ export const MATCH_SUMMARY_TEXTS = {
|
||||
// Votre jeu
|
||||
playTitle: "Votre jeu sur le match",
|
||||
tiles: { all: "Tout le match", chequer: "Les pions", cube: "Le videau" },
|
||||
tileUnit: "millièmes par décision",
|
||||
tileNone: "aucune décision",
|
||||
tilesCaption: "Taux d'erreur, en millièmes par décision",
|
||||
tilesHow: "Comment le lire",
|
||||
|
||||
// Le videau
|
||||
cubeTitle: "Le videau",
|
||||
@@ -145,8 +147,8 @@ export const MATCH_SUMMARY_TEXTS = {
|
||||
/** Sous l'en-tête du bilan d'une partie de match. */
|
||||
gameOfMatch: (n: number, length: number) => `Partie ${n} du match en ${length} points`,
|
||||
/** En tête de l'analyse d'une partie de match : « Partie 2 sur 5 · 0–2 ». */
|
||||
analysisHeader: (n: number, total: number, score: string) =>
|
||||
`Partie ${n} sur ${total} · ${score}`,
|
||||
analysisHeader: (n: number, total: number, score: string, crawford: boolean) =>
|
||||
`Partie ${n} sur ${total} · ${score}${crawford ? " · Crawford" : ""}`,
|
||||
previousGame: "Partie précédente",
|
||||
nextGame: "Partie suivante",
|
||||
|
||||
@@ -159,7 +161,7 @@ export const MATCH_SUMMARY_TEXTS = {
|
||||
return `Match en ${match.length} points · ${state}`;
|
||||
},
|
||||
listCaption: (date: string, games: number, level: string) =>
|
||||
`${date} · ${games} partie${games > 1 ? "s" : ""} · ${level}`,
|
||||
`${date} · ${games} partie${games > 1 ? "s" : ""} · contre ${level}`,
|
||||
listInferred: "rattaché d'après les scores",
|
||||
resume: "Reprendre",
|
||||
errorRate: (millis: number) => `${millis}`,
|
||||
|
||||
@@ -278,11 +278,18 @@ export function createMatchSummaryView(options: MatchSummaryViewOptions): MatchS
|
||||
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) {
|
||||
// Le moment décisif sur la fin du match : l'anneau or seul.
|
||||
const marks: [string, string][] = decisiveAtEnd(summary)
|
||||
? [
|
||||
["decisive", T.legendDecisiveEnd],
|
||||
["review", T.legendReview],
|
||||
]
|
||||
: [
|
||||
["decisive", T.legendDecisive],
|
||||
["review", T.legendReview],
|
||||
[summary.match.winner === "player" ? "end won" : "end", T.legendEnd],
|
||||
];
|
||||
for (const [mark, text] of marks) {
|
||||
const item = element(legend, "li");
|
||||
const dot = element(item, "span", { className: `match-mark ${mark}` });
|
||||
dot.setAttribute("aria-hidden", "true");
|
||||
@@ -311,6 +318,20 @@ export function createMatchSummaryView(options: MatchSummaryViewOptions): MatchS
|
||||
const draw = () => drawCurve(svg, summary, selected);
|
||||
redrawCurve = draw;
|
||||
draw();
|
||||
// Le tracé suit la taille réelle de la courbe (une unité du viewBox
|
||||
// pour un pixel, les libellés à leur taille) : il se redessine dès
|
||||
// qu'elle change, quand la page devient visible ou tourne.
|
||||
if (typeof ResizeObserver !== "undefined") {
|
||||
let size = "";
|
||||
new ResizeObserver(() => {
|
||||
const box = svg.getBoundingClientRect();
|
||||
const now = `${Math.round(box.width)}x${Math.round(box.height)}`;
|
||||
if (box.width > 0 && now !== size) {
|
||||
size = now;
|
||||
draw();
|
||||
}
|
||||
}).observe(svg);
|
||||
}
|
||||
|
||||
// Lecture au doigt : glisser choisit le point sous le doigt (une
|
||||
// vibration légère à chaque changement de partie) ; lâcher garde la
|
||||
@@ -420,11 +441,14 @@ export function createMatchSummaryView(options: MatchSummaryViewOptions): MatchS
|
||||
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 unit = element(card, "p", {
|
||||
id: "match-tiles-caption",
|
||||
className: "caption match-tiles-caption",
|
||||
});
|
||||
unit.append(`${T.tilesCaption} · `);
|
||||
const how = element(unit, "a", { id: "match-tiles-glossary", text: T.tilesHow });
|
||||
how.href = routeHash({ screen: "glossary", term: "taux-d-erreur" });
|
||||
const box = element(card, "div", { className: "summary-gauges" });
|
||||
const level = summary.errorRate.level;
|
||||
const levelName = MATCH_TEXTS.levels[level].name;
|
||||
@@ -601,8 +625,9 @@ export function createMatchSummaryView(options: MatchSummaryViewOptions): MatchS
|
||||
* 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;
|
||||
const box = svg.getBoundingClientRect();
|
||||
const width = Math.round(box.width || 360);
|
||||
const height = Math.round(box.height || CURVE_HEIGHT);
|
||||
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
||||
svg.replaceChildren();
|
||||
const points = summary.curve;
|
||||
@@ -699,7 +724,7 @@ function drawCurve(svg: SVGSVGElement, summary: MatchSummary, selected: number |
|
||||
if (reviewed !== null) {
|
||||
mark(indexOf(reviewed.game, reviewed.turn), "match-mark-review", 5);
|
||||
}
|
||||
if (summary.match.over) {
|
||||
if (summary.match.over && !decisiveAtEnd(summary)) {
|
||||
mark(
|
||||
points.length - 1,
|
||||
summary.match.winner === "player" ? "match-mark-end won" : "match-mark-end",
|
||||
@@ -721,6 +746,20 @@ function drawCurve(svg: SVGSVGElement, summary: MatchSummary, selected: number |
|
||||
}
|
||||
}
|
||||
|
||||
/** Le moment décisif est le dernier tour du match fini : sa marque (l'anneau
|
||||
* or) tient lieu de marque de fin. */
|
||||
function decisiveAtEnd(summary: MatchSummary): boolean {
|
||||
const decisive = summary.decisive;
|
||||
const last = summary.curve.at(-1);
|
||||
return (
|
||||
summary.match.over &&
|
||||
decisive !== null &&
|
||||
last !== undefined &&
|
||||
last.game === decisive.game &&
|
||||
last.turn === decisive.turn
|
||||
);
|
||||
}
|
||||
|
||||
/** La bulle du point choisi : partie, coup, score, chances ; un lien SVG
|
||||
* vers la décision dans l'analyse. */
|
||||
function bubble(
|
||||
|
||||
@@ -359,7 +359,7 @@ test("les phrases du bilan du match", () => {
|
||||
decisiveSentence(phrases, { ...moment, side: "computer", roll: [6, 6] }),
|
||||
/^Avec le 6-6 de l'ordinateur/,
|
||||
);
|
||||
assert.match(decisiveSentence(phrases, { ...moment, roll: null }), /^Sur ce double/);
|
||||
assert.match(decisiveSentence(phrases, { ...moment, roll: null }), /^Sur ce double passé, /);
|
||||
for (const text of [
|
||||
decisiveSentence(phrases, { ...moment, side: "computer", roll: [6, 6] }),
|
||||
matchCubeSentence(phrases, 12, 11),
|
||||
|
||||
Reference in New Issue
Block a user