From a8bc8122f34470259e1590b1f0c21c60aeccbcca Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Fri, 13 Nov 2026 18:51:36 +0000 Subject: [PATCH] Refine laser pictogram and render accessible tutorial android tokens --- preview/icons.js | 3 ++- preview/locales/en.json | 2 +- preview/locales/fr.json | 2 +- preview/style.css | 2 ++ preview/tutorial-text.js | 15 +++++++----- test/tactical.test.js | 6 +++++ test/tutorial-text.test.js | 48 ++++++++++++++++++++++++++++++++------ 7 files changed, 62 insertions(+), 16 deletions(-) diff --git a/preview/icons.js b/preview/icons.js index 21ad54d..32dec68 100644 --- a/preview/icons.js +++ b/preview/icons.js @@ -13,7 +13,8 @@ const paths = { bots: "M7 9V7a5 5 0 0 1 10 0v2H7Zm2-3h6M6 10h12v8H6zM10 13h4M3 11v6m18-6v6M8 18v3H5m11-3v3h3", android: "M5 7h14v13H5zM12 3v4M10 3h4M8 11h1m6 0h1M8 16h8M2 10v6m20-6v6", - laser: "M3 14h8v6H3zM6 14V9h4v5M9 9l8-6M14 10l7-5M17 13l5-4", + // Side-view barrel, pedestal, one beam and a small muzzle flash. + laser: "M2 9h8v6H2zM5 15v4m-3 0h7M10 12h12M12 8l2 2m-2 6 2-2", pulse: "M9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0ZM6 6a8.5 8.5 0 0 0 0 12m12-12a8.5 8.5 0 0 1 0 12M3 3a13 13 0 0 0 0 18m18-18a13 13 0 0 1 0 18", shield: "m12 2 8 3v6c0 5-4 8-8 11-4-3-8-6-8-11V5l8-3Z", diff --git a/preview/locales/en.json b/preview/locales/en.json index 23999a0..b35e04d 100644 --- a/preview/locales/en.json +++ b/preview/locales/en.json @@ -9,7 +9,7 @@ "lesson.first-shot.shield": "The center shield absorbs hits automatically while charged.", "lesson.energy.title": "Energy and coordination", "lesson.energy.instruction.0": "The center laser needs one energy per shot. Its reactor starts with three: refill it to fire four times.\n\nIn the lower center room, [[action:energy]] consumes one fuel capsule to fill the central reactor to capacity—not just add one energy. It does not refill other reactors or shields.\n\nAt a shield, [[action:energy]] transfers energy from the same-zone reactor: enough to fill the shield, limited by the reactor’s remaining supply. At a side reactor, it transfers energy from the central reactor, up to capacity and limited by the central supply. These transfers use no fuel capsule.", - "lesson.energy.instruction.1": "Android 1: [[action:weapons]] on turns 1-4. Android 3: use the lift on turn 1, then [[action:energy]] in the lower center room on turn 2 to refill the reactor. Then lock phase 1 to plan turn 4.", + "lesson.energy.instruction.1": "[[crew:android:1]]: [[action:weapons]] on turns 1-4. [[crew:android:3]]: use the lift on turn 1, then [[action:energy]] in the lower center room on turn 2 to refill the reactor. Then lock phase 1 to plan turn 4.", "lesson.repairs.title": "Repairing a malfunction", "lesson.repairs.instruction.0": "Repair the highlighted malfunction.", "lesson.repairs.instruction.1": "Move right on turn 1, then use [[action:energy]] on turns 2, 3 and 4. While this shield malfunction is active, [[action:energy]] repairs it instead of recharging the shield. Three repair actions eliminate it.", diff --git a/preview/locales/fr.json b/preview/locales/fr.json index fea666b..720fb3a 100644 --- a/preview/locales/fr.json +++ b/preview/locales/fr.json @@ -9,7 +9,7 @@ "lesson.first-shot.shield": "Le bouclier central absorbe les tirs automatiquement tant qu’il est chargé.", "lesson.energy.title": "Énergie et coordination", "lesson.energy.instruction.0": "Le laser central consomme une énergie par tir. Son réacteur en contient trois : ravitaillez-le pour tirer quatre fois.\n\nDans la salle centrale du bas, [[action:energy]] consomme une capsule de carburant pour remplir le réacteur central jusqu’à sa capacité, et non ajouter une seule énergie. Cela ne remplit ni les autres réacteurs ni les boucliers.\n\nAu bouclier, [[action:energy]] transfère l’énergie du réacteur de la même zone : de quoi remplir le bouclier, dans la limite de l’énergie restante du réacteur. Dans un réacteur latéral, cette action transfère l’énergie du réacteur central, jusqu’à sa capacité et dans la limite de la réserve centrale. Ces transferts ne consomment aucune capsule.", - "lesson.energy.instruction.1": "Androïde 1 : [[action:weapons]] aux tours 1-4. Androïde 3 : ascenseur au tour 1, puis [[action:energy]] dans la salle centrale du bas au tour 2 pour ravitailler le réacteur. Verrouillez ensuite la phase 1 pour préparer le tour 4.", + "lesson.energy.instruction.1": "[[crew:android:1]] : [[action:weapons]] aux tours 1-4. [[crew:android:3]] : ascenseur au tour 1, puis [[action:energy]] dans la salle centrale du bas au tour 2 pour ravitailler le réacteur. Verrouillez ensuite la phase 1 pour préparer le tour 4.", "lesson.repairs.title": "Réparer une panne", "lesson.repairs.instruction.0": "Réparez la panne surlignée.", "lesson.repairs.instruction.1": "Allez à droite au tour 1, puis utilisez [[action:energy]] aux tours 2, 3 et 4. Tant que cette panne de bouclier est active, [[action:energy]] la répare au lieu de recharger le bouclier. Trois actions de réparation l’éliminent.", diff --git a/preview/style.css b/preview/style.css index 386a1f3..d3f7200 100644 --- a/preview/style.css +++ b/preview/style.css @@ -2454,6 +2454,8 @@ input:not([type="checkbox"]):not([type="range"]) { .native-guide-text { line-height: 1.6; white-space: pre-line; max-width: 65ch; } .tutorial-action { display: inline-block; vertical-align: -0.25em; line-height: 1; } .tutorial-action .pictogram { width: 1.25em; height: 1.25em; } +.tutorial-crew { display: inline-flex; align-items: center; gap: .15em; vertical-align: -.35em; white-space: nowrap; line-height: 1; } +.tutorial-crew .equipment-art { width: 1.5em; height: 1.5em; flex: none; } .native-guide-controls { margin-top: 16px; } .native-guide .basics-stages { grid-template-columns: repeat(3, 1fr); margin: 16px 0; } .native-tutorial .basics-top, diff --git a/preview/tutorial-text.js b/preview/tutorial-text.js index 1923dc8..89e1bc1 100644 --- a/preview/tutorial-text.js +++ b/preview/tutorial-text.js @@ -1,7 +1,7 @@ import { translate } from "./i18n.js"; -import { pictogram } from "./icons.js"; +import { pictogram, equipmentPicture } from "./icons.js"; -// Catalogs contain text and a closed set of action tokens, never executable HTML. +// Catalogs contain text and closed action/crew tokens, never executable HTML. const actions = { weapons: ["A", "app.weapons"], energy: ["B", "app.energy"], @@ -11,10 +11,13 @@ const escape = (text) => String(text).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]); export function tutorialTextParts(text, locale) { - return String(text).split(/(\[\[action:(?:weapons|energy|systems)\]\])/g) + return String(text).split(/(\[\[(?:action:(?:weapons|energy|systems)|crew:android:[1-5])\]\])/g) .filter(Boolean).map((text) => { - const action = actions[text.slice(9, -2)]; - return text.startsWith("[[action:") && action + const crew = /^\[\[crew:android:([1-5])\]\]$/.exec(text); + if (crew) return { type: "crew", number: crew[1], label: `${translate(locale, "app.android")} ${crew[1]}` }; + const match = /^\[\[action:(weapons|energy|systems)\]\]$/.exec(text); + const action = match && actions[match[1]]; + return action ? { type: "action", icon: action[0], label: translate(locale, action[1]) } : { type: "text", text }; }); @@ -27,5 +30,5 @@ export function tutorialTextPlain(text, locale) { export function tutorialTextHtml(text, locale) { return tutorialTextParts(text, locale).map((part) => part.type === "text" ? escape(part.text) - : `${pictogram(part.icon)}`).join(""); + : `${part.type === "crew" ? `${equipmentPicture("android")}` : pictogram(part.icon)}`).join(""); } diff --git a/test/tactical.test.js b/test/tactical.test.js index 321f193..13e9a20 100644 --- a/test/tactical.test.js +++ b/test/tactical.test.js @@ -12,6 +12,12 @@ test("shared action glyphs have distinct accents without changing their silhouet assert.equal(pictogram(action).match(/