Retours des joueurs, 2e lot : Crawford sur la barre, abandon, dé injouable (1k) #76
+12
-4
@@ -779,11 +779,14 @@ export function startApp(options: AppOptions): void {
|
||||
render();
|
||||
}
|
||||
|
||||
function promptText(text: PromptText, g: Geometry): string {
|
||||
/** La consigne pour la mise en page : la forme courte en paysage ; en
|
||||
* portrait, la longue les premières parties, ou toujours (always : le
|
||||
* dé injouable, dont la raison doit se lire en entier). */
|
||||
function promptText(text: PromptText, g: Geometry, always = false): string {
|
||||
if (g.layout === "landscape") {
|
||||
return text.short;
|
||||
}
|
||||
return longPrompts(settings) ? text.long : text.short;
|
||||
return always || longPrompts(settings) ? text.long : text.short;
|
||||
}
|
||||
|
||||
function render(): void {
|
||||
@@ -860,7 +863,7 @@ export function startApp(options: AppOptions): void {
|
||||
? resignationAnswer(phrases, resigned.kind, true, resigned.points)
|
||||
: text === null
|
||||
? resultText(game)
|
||||
: promptText(text, g);
|
||||
: promptText(text, g, unplayable !== null);
|
||||
const thinking = state.turn === "computer" && isPlaying(game);
|
||||
ui.prompt.classList.toggle("thinking", thinking);
|
||||
ui.prompt.classList.toggle(
|
||||
@@ -880,7 +883,12 @@ export function startApp(options: AppOptions): void {
|
||||
renderRefusal(game);
|
||||
show(ui.cancel, moving && !stuck);
|
||||
show(ui.confirm, moving && game.moveComplete);
|
||||
show(ui.moveHint, moving && !stuck && !game.moveComplete);
|
||||
// Un dé injouable dès le lancer : la consigne dit quoi faire, la barre
|
||||
// d'actions n'ajoute rien (Annuler seul).
|
||||
show(
|
||||
ui.moveHint,
|
||||
moving && !stuck && !game.moveComplete && (unplayable === null || unplayable.moveDone),
|
||||
);
|
||||
show(ui.skip, stuck);
|
||||
show(ui.take, doubled);
|
||||
show(ui.drop, doubled);
|
||||
|
||||
@@ -205,7 +205,8 @@ export function createSummaryView(options: SummaryViewOptions): SummaryView {
|
||||
data.match === null
|
||||
? REVIEW_TEXTS.nothingPlayed
|
||||
: `${data.end.detail} ${REVIEW_TEXTS.nothingPlayed}`;
|
||||
actions(data);
|
||||
// Pas d'analyse à voir : une analyse vide n'aurait rien à montrer.
|
||||
actions(data, false);
|
||||
return;
|
||||
}
|
||||
counts(summary);
|
||||
@@ -357,17 +358,19 @@ export function createSummaryView(options: SummaryViewOptions): SummaryView {
|
||||
);
|
||||
}
|
||||
|
||||
function actions(data: SummaryData): void {
|
||||
function actions(data: SummaryData, withAnalysis = true): void {
|
||||
// Les actions et le lien des réglages, ensemble : en paysage, en bas
|
||||
// de la colonne de droite.
|
||||
const end = element(panel, "div", { className: "summary-end" });
|
||||
const bar = element(end, "div", { className: "panel-actions summary-actions" });
|
||||
const analysis = element(bar, "a", {
|
||||
id: "summary-analysis",
|
||||
className: "button secondary",
|
||||
text: REVIEW_TEXTS.seeAnalysis,
|
||||
});
|
||||
analysis.href = routeHash({ screen: "analysis", game: data.id, turn: null });
|
||||
if (withAnalysis) {
|
||||
const analysis = element(bar, "a", {
|
||||
id: "summary-analysis",
|
||||
className: "button secondary",
|
||||
text: REVIEW_TEXTS.seeAnalysis,
|
||||
});
|
||||
analysis.href = routeHash({ screen: "analysis", game: data.id, turn: null });
|
||||
}
|
||||
if (data.afterLabel !== null) {
|
||||
const again = element(bar, "button", {
|
||||
id: "summary-primary",
|
||||
|
||||
+11
-4
@@ -142,32 +142,39 @@ export const TEXTS = {
|
||||
? `Vos ${count} derniers ${value} ne peuvent pas se jouer`
|
||||
: `Le ${value} ne peut pas se jouer`;
|
||||
const done = "Jouez votre coup.";
|
||||
// La bande du paysage : les deux phrases, plus courtes.
|
||||
const short =
|
||||
count > 1
|
||||
? `Vos ${count} derniers ${value} ne se jouent pas`
|
||||
: `Le ${value} ne se joue pas`;
|
||||
switch (reason.kind) {
|
||||
case "closedEntry":
|
||||
return {
|
||||
long: `${subject} : la flèche ${reason.point} est fermée. ${
|
||||
moveDone ? done : `Rentrez un pion avec le ${other}.`
|
||||
}`,
|
||||
short: `${subject} : flèche ${reason.point} fermée.`,
|
||||
short: `${short} : flèche ${reason.point} fermée. ${
|
||||
moveDone ? done : `Rentrez un pion avec le ${other}.`
|
||||
}`,
|
||||
};
|
||||
case "forcedDie":
|
||||
return {
|
||||
long: `Un seul de vos dés peut se jouer : la règle impose de jouer le ${reason.die}.${
|
||||
moveDone ? ` ${done}` : ""
|
||||
}`,
|
||||
short: `Seul le ${reason.die} se joue.`,
|
||||
short: `Seul le ${reason.die} se joue.${moveDone ? ` ${done}` : ""}`,
|
||||
};
|
||||
case "oneDie":
|
||||
return {
|
||||
long: `Un seul de vos dés peut se jouer. ${moveDone ? done : "Choisissez lequel."}`,
|
||||
short: "Un seul dé se joue.",
|
||||
short: `Un seul dé se joue. ${moveDone ? done : "Choisissez lequel."}`,
|
||||
};
|
||||
case "noMove":
|
||||
return {
|
||||
long: `${subject} : aucun pion ne peut avancer de ${value}. ${
|
||||
moveDone ? done : `Jouez le ${other}.`
|
||||
}`,
|
||||
short: `${subject}.`,
|
||||
short: `${short}. ${moveDone ? done : `Jouez le ${other}.`}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
+34
-14
@@ -259,6 +259,14 @@ const bilan = await page.evaluate(() => ({
|
||||
check(bilan.title === "Perdue par abandon, gammon, 4 points" &&
|
||||
bilan.reading === "Aucun coup joué : rien à analyser." && !bilan.counts && !bilan.gauges,
|
||||
`bilan sans coup : ${JSON.stringify(bilan)}`);
|
||||
// Pas d'analyse vide à voir : « Rejouer » et « Changer les réglages » seuls.
|
||||
const bilanActions = await page.evaluate(() => ({
|
||||
analysis: document.getElementById("summary-analysis") !== null,
|
||||
primary: document.getElementById("summary-primary")?.textContent,
|
||||
settings: document.getElementById("summary-settings")?.textContent,
|
||||
}));
|
||||
check(!bilanActions.analysis && bilanActions.primary === "Rejouer" &&
|
||||
bilanActions.settings === "Changer les réglages", `actions du bilan sans coup : ${JSON.stringify(bilanActions)}`);
|
||||
await capture("5-bilan-abandon");
|
||||
// Le bilan fermé laisse la partie finie à l'écran : une seule phrase, celle
|
||||
// du maître, dans le style de l'état de la partie.
|
||||
@@ -331,23 +339,35 @@ const blockedDie = () => page.evaluate(() => ({
|
||||
labels: [...document.querySelectorAll("#board .die-blocked")].map((d) => d.getAttribute("aria-label")),
|
||||
strikes: document.querySelectorAll("#board .die-blocked .die-strike").length,
|
||||
prompt: document.getElementById("prompt").textContent,
|
||||
hint: document.getElementById("move-hint").hidden ? null : document.getElementById("move-hint").textContent,
|
||||
}));
|
||||
/** Paysage : la bande montre les deux phrases, dans sa pastille. */
|
||||
const bandFits = (expected) => async (size) => {
|
||||
if (size.width <= size.height) {
|
||||
return;
|
||||
}
|
||||
const band = await page.evaluate(() => {
|
||||
const text = document.getElementById("band-text");
|
||||
const pill = document.querySelector("#board .band-pill");
|
||||
return {
|
||||
text: text?.textContent ?? "",
|
||||
fits: text !== null && pill !== null && text.getBBox().width <= pill.getBBox().width - 16,
|
||||
};
|
||||
});
|
||||
check(band.text === expected && band.fits, `bande du dé injouable : ${JSON.stringify(band)}`);
|
||||
};
|
||||
// Dès le lancer, le dé qui ne rentre pas est barré (il n'apparaît dans aucun
|
||||
// coup légal du moteur).
|
||||
let blocked = await blockedDie();
|
||||
check(JSON.stringify(blocked.labels) === JSON.stringify([`${other} : ne peut pas être joué`]) &&
|
||||
blocked.strikes === 1, `dé injouable dès le lancer : ${JSON.stringify(blocked)}`);
|
||||
// La forme longue de la consigne (les trois premières parties), ou la courte.
|
||||
const short = `Le ${other} ne peut pas se jouer : flèche ${point} fermée.`;
|
||||
// La consigne entière, en portrait ; rien dans la barre d'actions (Annuler
|
||||
// seul).
|
||||
check(blocked.prompt === `Le ${other} ne peut pas se jouer : la flèche ${point} est fermée. ` +
|
||||
"Rentrez un pion avec le 6." || blocked.prompt === short,
|
||||
`consigne du dé injouable, au lancer : « ${blocked.prompt} »`);
|
||||
await capture("8-de-injouable", async (size) => {
|
||||
if (size.width > size.height) {
|
||||
const band = await page.evaluate(() => document.getElementById("band-text")?.textContent ?? "");
|
||||
check(band === short, `bande du dé injouable : « ${band} »`);
|
||||
}
|
||||
});
|
||||
"Rentrez un pion avec le 6." && blocked.hint === null,
|
||||
`consigne du dé injouable, au lancer : ${JSON.stringify(blocked)}`);
|
||||
await capture("8-de-injouable",
|
||||
bandFits(`Le ${other} ne se joue pas : flèche ${point} fermée. Rentrez un pion avec le 6.`));
|
||||
await page.click('.hit.can-move[data-place="bar-player"]');
|
||||
if ((await page.locator(".hit.can-land").count()) > 0) {
|
||||
await page.click(".hit.can-land");
|
||||
@@ -355,10 +375,10 @@ if ((await page.locator(".hit.can-land").count()) > 0) {
|
||||
await until("pion rentré", () => !document.body.classList.contains("busy") &&
|
||||
!document.getElementById("confirm").hidden);
|
||||
blocked = await blockedDie();
|
||||
check(blocked.labels.length === 1 && (blocked.prompt === `Le ${other} ne peut pas se jouer : la flèche ${point} ` +
|
||||
"est fermée. Jouez votre coup." || blocked.prompt === short),
|
||||
`consigne du dé injouable, après le 6 : « ${blocked.prompt} »`);
|
||||
await capture("8b-de-injouable-apres");
|
||||
check(blocked.labels.length === 1 && blocked.prompt === `Le ${other} ne peut pas se jouer : la flèche ${point} ` +
|
||||
"est fermée. Jouez votre coup.", `consigne du dé injouable, après le 6 : « ${blocked.prompt} »`);
|
||||
await capture("8b-de-injouable-apres",
|
||||
bandFits(`Le ${other} ne se joue pas : flèche ${point} fermée. Jouez votre coup.`));
|
||||
|
||||
// --------------------------------------------- Match en 7 points
|
||||
|
||||
|
||||
Reference in New Issue
Block a user