Add energy discovery examples and shared ship resource cells

This commit is contained in:
coyotte508 2026-11-13 17:08:55 +00:00
commit fb7e4f6369
12 changed files with 353 additions and 27 deletions

View file

@ -9,6 +9,7 @@ import { mountConsole } from "../preview/app.js";
import { pictogram } from "../preview/icons.js"; import { pictogram } from "../preview/icons.js";
import { tutorialTextHtml } from "../preview/tutorial-text.js"; import { tutorialTextHtml } from "../preview/tutorial-text.js";
import { tutorialMissionHeader, updateTutorialMissionProgress } from "../preview/tutorial-header.js"; import { tutorialMissionHeader, updateTutorialMissionProgress } from "../preview/tutorial-header.js";
import { energyDiscovery, ENERGY_DEMOS } from "../preview/tutorial-energy.js";
import { tutorialPhaseButton } from "../preview/tutorial-program.js"; import { tutorialPhaseButton } from "../preview/tutorial-program.js";
import { duration } from "../preview/clock.js"; import { duration } from "../preview/clock.js";
import { createSoundDesign } from "../preview/sound.js"; import { createSoundDesign } from "../preview/sound.js";
@ -35,6 +36,7 @@ export async function mountLesson(
lastStep = -1, lastStep = -1,
lastTurn = 0, lastTurn = 0,
lastTick = performance.now(); lastTick = performance.now();
let energyDemo = 0; // Local presentation only; never a controller checkpoint.
let playing = false, let playing = false,
previousStage, previousStage,
previousPhase, previousPhase,
@ -215,8 +217,8 @@ export async function mountLesson(
programControls.innerHTML = `<div class="phase-lesson-controls">${s.state.phase === 1 ? transport("phase-deadline", "forward", t("phases.skip"), !ready || !s.state.game.threats.length || s.busy) : `<button data-guide="run" class="primary icon-label lesson-run" aria-keyshortcuts="Enter" title="${t("phases.execute")} · ↵" ${!ready || s.busy ? "disabled" : ""}>${pictogram("check")}<span>${t("phases.execute")}</span><kbd aria-hidden="true">↵</kbd></button>`}<div class="practice-clock"><div><strong data-practice-phase>${t("phases.deadline", { phase: s.state.phase, time: phaseTime })}</strong></div>${transport("phase-clock", s.state.tutorial.clockRunning ? "pause" : "clock", t(s.state.tutorial.clockRunning ? "basics.pause" : "basics.start_clock"))}</div></div>`; programControls.innerHTML = `<div class="phase-lesson-controls">${s.state.phase === 1 ? transport("phase-deadline", "forward", t("phases.skip"), !ready || !s.state.game.threats.length || s.busy) : `<button data-guide="run" class="primary icon-label lesson-run" aria-keyshortcuts="Enter" title="${t("phases.execute")} · ↵" ${!ready || s.busy ? "disabled" : ""}>${pictogram("check")}<span>${t("phases.execute")}</span><kbd aria-hidden="true">↵</kbd></button>`}<div class="practice-clock"><div><strong data-practice-phase>${t("phases.deadline", { phase: s.state.phase, time: phaseTime })}</strong></div>${transport("phase-clock", s.state.tutorial.clockRunning ? "pause" : "clock", t(s.state.tutorial.clockRunning ? "basics.pause" : "basics.start_clock"))}</div></div>`;
} }
guide.innerHTML = `<div class="native-guide-row"><nav class="basics-stages" aria-label="${t("tutorial.steps")}">${label.map((name, i) => `<button data-guide-step="${deadline ? i + 3 : i}" class="quiet ${stage === i ? "active" : ""}" ${i > stage || s.busy ? "disabled" : ""} ${stage === i ? 'aria-current="step"' : ""}><span class="step-number">${i + 1}</span><span>${name}</span></button>`).join("")}</nav><div class="native-guide-tools">${standalone ? `<a href="/">${t("tutorial.local_game")}</a>` : ""}${transport("sound", soundOn ? "speaker" : "muted", soundOn ? t("tutorial.mute_sounds") : t("tutorial.enable_sounds"))}</div></div> guide.innerHTML = `<div class="native-guide-row"><nav class="basics-stages" aria-label="${t("tutorial.steps")}">${label.map((name, i) => `<button data-guide-step="${deadline ? i + 3 : i}" class="quiet ${stage === i ? "active" : ""}" ${i > stage || s.busy ? "disabled" : ""} ${stage === i ? 'aria-current="step"' : ""}><span class="step-number">${i + 1}</span><span>${name}</span></button>`).join("")}</nav><div class="native-guide-tools">${standalone ? `<a href="/">${t("tutorial.local_game")}</a>` : ""}${transport("sound", soundOn ? "speaker" : "muted", soundOn ? t("tutorial.mute_sounds") : t("tutorial.enable_sounds"))}</div></div>
<h1>${escape(s.title)}</h1>${tutorialMissionHeader(chapter, s.step, locale)}<p class="native-guide-text">${tutorialTextHtml(missed ? t("tutorial.destination_missed_go_back_and_plan_another_route") : s.text, locale)}</p>${chapter === "first-shot" && s.step < 2 ? `<p class="lesson-shield-note">${pictogram("shield")}<span>${t("lesson.first-shot.shield")}</span></p>` : ""} <h1>${escape(s.title)}</h1>${tutorialMissionHeader(chapter, s.step, locale)}${chapter === "energy" && s.step === 0 ? energyDiscovery(energyDemo, locale) : `<p class="native-guide-text">${tutorialTextHtml(missed ? t("tutorial.destination_missed_go_back_and_plan_another_route") : s.text, locale)}</p>`}${chapter === "first-shot" && s.step < 2 ? `<p class="lesson-shield-note">${pictogram("shield")}<span>${t("lesson.first-shot.shield")}</span></p>` : ""}
<div class="native-guide-controls">${transport("restart", "rewind", t("tutorial.restart_exercise"), s.busy)}${transport("previous", "left", t("tutorial.previous_step"), s.step === 0 || s.busy)}${transport("replay", "restart", t("tutorial.replay_step"), s.busy || s.step === 0)}${s.canContinue ? `<button data-guide="continue" class="primary icon-button" title="${t("tutorial.start")}" aria-label="${t("tutorial.start")}">${pictogram("right")}</button>` : ""}${s.completed && (nextChapter || (standalone && LESSONS[index + 1])) ? `<button data-guide="next" class="primary icon-label"><span>${t("tutorial.next_exercise")}</span>${pictogram("right")}</button>` : ""}</div> <div class="native-guide-controls">${transport("restart", "rewind", t("tutorial.restart_exercise"), s.busy)}${transport("previous", "left", t("tutorial.previous_step"), s.step === 0 || s.busy)}${transport("replay", "restart", t("tutorial.replay_step"), s.busy || s.step === 0)}${s.canContinue && (chapter !== "energy" || s.step !== 0 || energyDemo === ENERGY_DEMOS.length - 1) ? `<button data-guide="continue" class="primary icon-button" title="${t("tutorial.start")}" aria-label="${t("tutorial.start")}">${pictogram("right")}</button>` : ""}${s.completed && (nextChapter || (standalone && LESSONS[index + 1])) ? `<button data-guide="next" class="primary icon-label"><span>${t("tutorial.next_exercise")}</span>${pictogram("right")}</button>` : ""}</div>
${s.error ? `<p role="alert">${escape(s.error)}</p>` : ""}`; ${s.error ? `<p role="alert">${escape(s.error)}</p>` : ""}`;
updateTutorialMissionProgress(guide, displayedFrames, locale, displayedLastTurn); updateTutorialMissionProgress(guide, displayedFrames, locale, displayedLastTurn);
} }
@ -278,7 +280,17 @@ export async function mountLesson(
const onClick = async (event) => { const onClick = async (event) => {
const button = event.target.closest("button"); const button = event.target.closest("button");
if (!button || tutorial.snapshot.busy) return; if (!button || tutorial.snapshot.busy) return;
if (button.dataset.energyDemo !== undefined) {
if (chapter !== "energy" || tutorial.snapshot.step !== 0) return;
const next = Number(button.dataset.energyDemo);
if (!Number.isInteger(next) || next < 0 || next >= ENERGY_DEMOS.length) return;
energyDemo = next;
renderGuide(tutorial.snapshot);
guide.querySelector(".energy-discovery h2")?.focus();
return;
}
const action = button.dataset.guide; const action = button.dataset.guide;
if (action === "restart") energyDemo = 0;
if (action === "sound") { if (action === "sound") {
soundOn = !soundOn; soundOn = !soundOn;
try { try {

View file

@ -458,7 +458,7 @@ export function mountConsole(root, host = null) {
} }
} }
$("#resources").innerHTML = $("#resources").innerHTML =
`${symbol("fuel", `${t("app.fuel")} : ${ship.fuel}`, `<b>${ship.fuel}</b>`)}${symbol("rocket", `${t("app.rockets")} : ${ship.rockets}`, `<b>${ship.rockets}</b>`)}${symbol("computer", t("app.computer") + " · " + ship.computer.map((x, i) => `${t("app.phase")} ${i + 1} : ${x ? t("app.maintained") : t("app.not_maintained")}`).join(" · "), ship.computer.map((x, i) => `<span class="computer-phase ${x ? "maintained" : ""}">${i + 1}</span>`).join(""))}${symbol("bots", `${t("app.battlebots_available_squads")} : ${ship.bots.filter((b) => b.owner === null && b.station && !b.disabled).length}`, `<b>${ship.bots.filter((b) => b.owner === null && b.station && !b.disabled).length}</b><small>${t("app.squads")}</small>`)}${ship.crew `${symbol("rocket", `${t("app.rockets")} : ${ship.rockets}`, `<b>${ship.rockets}</b>`)}${symbol("computer", t("app.computer") + " · " + ship.computer.map((x, i) => `${t("app.phase")} ${i + 1} : ${x ? t("app.maintained") : t("app.not_maintained")}`).join(" · "), ship.computer.map((x, i) => `<span class="computer-phase ${x ? "maintained" : ""}">${i + 1}</span>`).join(""))}${symbol("bots", `${t("app.battlebots_available_squads")} : ${ship.bots.filter((b) => b.owner === null && b.station && !b.disabled).length}`, `<b>${ship.bots.filter((b) => b.owner === null && b.station && !b.disabled).length}</b><small>${t("app.squads")}</small>`)}${ship.crew
.filter((p) => p.space) .filter((p) => p.space)
.map((p) => .map((p) =>
symbol( symbol(

View file

@ -1,4 +1,7 @@
{ {
"energy.demo.before": "Before",
"energy.demo.after": "After",
"tactical.energy_cells": "Energy: {value} / {capacity} capacity",
"lesson.basics.title": "Start here: planning turns", "lesson.basics.title": "Start here: planning turns",
"lesson.first-shot.title": "Your first shot", "lesson.first-shot.title": "Your first shot",
"lesson.first-shot.instruction.0": "The fighter approaches the center lane. Fire the highlighted laser from the upper center room.", "lesson.first-shot.instruction.0": "The fighter approaches the center lane. Fire the highlighted laser from the upper center room.",
@ -511,6 +514,7 @@
"tactical.show_my_cards": "Show my {value1} cards", "tactical.show_my_cards": "Show my {value1} cards",
"tactical.power": "Power", "tactical.power": "Power",
"tactical.fire": "Fire", "tactical.fire": "Fire",
"tactical.fuel_capsules": "Fuel capsules remaining: {count}",
"tactical.weapon_power": "Weapon power: {power}", "tactical.weapon_power": "Weapon power: {power}",
"tactical.firepower": "Firepower", "tactical.firepower": "Firepower",
"tactical.own_battery": "Own battery", "tactical.own_battery": "Own battery",
@ -612,5 +616,23 @@
"program.choose_turn": "Click a turn to edit", "program.choose_turn": "Click a turn to edit",
"lesson.energy.retry": "{count}/4 shots fired. Go back and plan four center-laser shots with a reactor refill.", "lesson.energy.retry": "{count}/4 shots fired. Go back and plan four center-laser shots with a reactor refill.",
"tutorial.lock_phase": "Lock phase {phase}", "tutorial.lock_phase": "Lock phase {phase}",
"tutorial.phase_ready": "Required actions programmed — ready to lock." "tutorial.phase_ready": "Required actions programmed — ready to lock.",
"energy.demo.label": "Energy examples",
"energy.demo.back": "Previous example",
"energy.demo.next": "Next example",
"energy.demo.example": "Illustration only · before → after",
"energy.demo.central": "Central reactor",
"energy.demo.zone": "Same-zone reactor",
"energy.demo.side": "Side reactor",
"energy.demo.shield": "Shield",
"energy.demo.fuel": "Fuel capsules",
"energy.demo.shots": "Shots",
"energy.demo.shot.title": "Fire: spend 1 energy",
"energy.demo.shot.text": "At the center laser, [[action:weapons]] spends 1 reactor energy per shot. Three energy means three shots.",
"energy.demo.refill.title": "Refill: spend 1 capsule",
"energy.demo.refill.text": "In the lower center room, [[action:energy]] spends 1 fuel capsule to fill the central reactor to capacity. Other reactors and shields stay unchanged.",
"energy.demo.shield.title": "Shield: transfer energy",
"energy.demo.shield.text": "At a shield, [[action:energy]] draws from the same-zone reactor, up to shield capacity. Limited supply means a partial refill. No fuel used.",
"energy.demo.side.title": "Side reactor: transfer energy",
"energy.demo.side.text": "At a side reactor, [[action:energy]] draws from the central reactor, up to side capacity. Limited supply means a partial refill. No fuel used."
} }

View file

@ -1,4 +1,7 @@
{ {
"energy.demo.before": "Avant",
"energy.demo.after": "Après",
"tactical.energy_cells": "Énergie : {value} / {capacity} de capacité",
"lesson.basics.title": "Commencer ici : programmer les tours", "lesson.basics.title": "Commencer ici : programmer les tours",
"lesson.first-shot.title": "Votre premier tir", "lesson.first-shot.title": "Votre premier tir",
"lesson.first-shot.instruction.0": "Le chasseur approche au centre. Tirez avec le laser surligné depuis la salle centrale du haut.", "lesson.first-shot.instruction.0": "Le chasseur approche au centre. Tirez avec le laser surligné depuis la salle centrale du haut.",
@ -178,8 +181,8 @@
"app.threat_actions": "Actions des menaces", "app.threat_actions": "Actions des menaces",
"app.review_a_step": "Revoir une étape", "app.review_a_step": "Revoir une étape",
"app.back_to_live": "Aller au dernier état", "app.back_to_live": "Aller au dernier état",
"app.play_replay": "Lire la reprise", "app.play_replay": "Revoir les actions",
"app.pause_replay": "Mettre la reprise en pause", "app.pause_replay": "Pause",
"app.laser": "Laser", "app.laser": "Laser",
"app.pulse": "Impulsion", "app.pulse": "Impulsion",
"app.shield": "Bouclier", "app.shield": "Bouclier",
@ -511,6 +514,7 @@
"tactical.show_my_cards": "Voir mes cartes {value1}", "tactical.show_my_cards": "Voir mes cartes {value1}",
"tactical.power": "Puissance", "tactical.power": "Puissance",
"tactical.fire": "Tirer", "tactical.fire": "Tirer",
"tactical.fuel_capsules": "Capsules de carburant restantes : {count}",
"tactical.weapon_power": "Puissance de l’arme : {power}", "tactical.weapon_power": "Puissance de l’arme : {power}",
"tactical.firepower": "Puissance de tir", "tactical.firepower": "Puissance de tir",
"tactical.own_battery": "Batterie autonome", "tactical.own_battery": "Batterie autonome",
@ -612,5 +616,23 @@
"program.choose_turn": "Cliquez un tour à modifier", "program.choose_turn": "Cliquez un tour à modifier",
"lesson.energy.retry": "{count}/4 tirs effectués. Revenez à la préparation : quatre tirs du laser central et un ravitaillement du réacteur.", "lesson.energy.retry": "{count}/4 tirs effectués. Revenez à la préparation : quatre tirs du laser central et un ravitaillement du réacteur.",
"tutorial.lock_phase": "Verrouiller la phase {phase}", "tutorial.lock_phase": "Verrouiller la phase {phase}",
"tutorial.phase_ready": "Actions requises programmées — vous pouvez verrouiller." "tutorial.phase_ready": "Actions requises programmées — vous pouvez verrouiller.",
"energy.demo.label": "Exemples d’énergie",
"energy.demo.back": "Exemple précédent",
"energy.demo.next": "Exemple suivant",
"energy.demo.example": "Illustration uniquement · avant → après",
"energy.demo.central": "Réacteur central",
"energy.demo.zone": "Réacteur de la zone",
"energy.demo.side": "Réacteur latéral",
"energy.demo.shield": "Bouclier",
"energy.demo.fuel": "Capsules de carburant",
"energy.demo.shots": "Tirs",
"energy.demo.shot.title": "Tirer : dépenser 1 énergie",
"energy.demo.shot.text": "Au laser central, [[action:weapons]] dépense 1 énergie du réacteur par tir. Trois énergies permettent trois tirs.",
"energy.demo.refill.title": "Ravitailler : dépenser 1 capsule",
"energy.demo.refill.text": "Dans la salle centrale du bas, [[action:energy]] dépense 1 capsule pour remplir le réacteur central à sa capacité. Les autres réacteurs et boucliers restent inchangés.",
"energy.demo.shield.title": "Bouclier : transférer l’énergie",
"energy.demo.shield.text": "Au bouclier, [[action:energy]] puise dans le réacteur de la même zone, jusqu’à sa capacité. Réserve limitée : recharge partielle. Aucun carburant utilisé.",
"energy.demo.side.title": "Réacteur latéral : transférer l’énergie",
"energy.demo.side.text": "Au réacteur latéral, [[action:energy]] puise dans le réacteur central, jusqu’à sa capacité. Réserve limitée : recharge partielle. Aucun carburant utilisé."
} }

15
preview/resource-cells.js Normal file
View file

@ -0,0 +1,15 @@
import { pictogram } from './icons.js';
const esc = value => String(value).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
// One cell per capacity; heroic excess stays visible as additional outlined cells.
// Keep the wrapper inside .system-caption so deferred resolution meters swap atomically.
export function energyCells(value, capacity, t) {
const label = t('tactical.energy_cells', { value, capacity });
return `<span class="energy-value energy-cells" role="img" aria-label="${esc(label)}" title="${esc(label)}" data-energy="${value}" data-capacity="${capacity}">${Array.from({ length: Math.max(capacity, value) }, (_, i) => `<i aria-hidden="true" class="energy-cell ${i < value ? 'filled' : 'empty'}${i >= capacity ? ' excess' : ''}"></i>`).join('')}</span>`;
}
export function fuelRack(fuel, t) {
const label = t('tactical.fuel_capsules', { count: fuel });
return `<div class="fuel-rack" role="img" aria-label="${esc(label)}" title="${esc(label)}" data-fuel="${fuel}"><div class="fuel-slots" aria-hidden="true">${Array.from({ length: Math.max(3, fuel) }, (_, i) => `<span class="fuel-slot ${i < fuel ? 'filled' : 'empty'}">${i < fuel ? pictogram('fuel') : ''}</span>`).join('')}</div></div>`;
}

View file

@ -477,6 +477,7 @@ export function createPreviewServer({ clock = Date.now, storagePath } = {}) {
"/icons.js": "icons.js", "/icons.js": "icons.js",
"/art.js": "art.js", "/art.js": "art.js",
"/tactical.js": "tactical.js", "/tactical.js": "tactical.js",
"/resource-cells.js": "resource-cells.js",
"/threat-track.js": "threat-track.js", "/threat-track.js": "threat-track.js",
"/program-route.js": "program-route.js", "/program-route.js": "program-route.js",
"/program-cursor.js": "program-cursor.js", "/program-cursor.js": "program-cursor.js",

View file

@ -1398,30 +1398,30 @@ input:not([type="checkbox"]):not([type="range"]) {
top: 2px; top: 2px;
left: 1px; left: 1px;
} }
.energy-value { /* Shared by the live ship, inspection flows and Discover examples. */
color: #b8f6f6; .energy-cells {
font-size: 18px; display: inline-flex;
font-weight: 750; flex-wrap: wrap;
font-variant-numeric: tabular-nums; justify-content: center;
}
.charge-pips {
display: flex;
width: 100%;
max-width: 90px;
gap: 3px; gap: 3px;
max-width: 100%;
vertical-align: middle;
} }
.charge-pips i { .energy-cell {
height: 5px; box-sizing: border-box;
flex: 1; padding: 0;
min-width: 0; width: 10px;
height: 17px;
flex: 0 0 10px;
background: #112330; background: #112330;
border: 1px solid #7696a4; border: 1px solid #7696a4;
border-radius: 2px; border-radius: 2px;
} }
.charge-pips i.filled { .energy-cell.filled {
background: #96ebed; background: #96ebed;
border-color: #d6ffff; border-color: #d6ffff;
} }
.energy-cell.excess { border: 2px dashed #ffd48a; }
.energy-system.depleted button { .energy-system.depleted button {
border-color: #c99871; border-color: #c99871;
} }
@ -1578,6 +1578,44 @@ input:not([type="checkbox"]):not([type="range"]) {
gap: 12px; gap: 12px;
padding: 0 14px 18px; padding: 0 14px 18px;
} }
.fuel-rack {
justify-self: center;
display: flex;
align-items: center;
gap: 4px;
max-width: 100%;
padding: 5px;
border: 2px solid #81939a;
border-top: 0;
border-radius: 0 0 9px 9px;
background: #142c38;
color: #f5d48a;
}
.fuel-slots {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 3px;
}
.fuel-slot {
padding: 0;
display: grid;
place-items: center;
width: clamp(14px, 2.5vw, 23px);
height: clamp(20px, 3.5vw, 30px);
border: 1px solid #afbdc3;
border-radius: 5px;
}
.fuel-slot.filled {
background: #695333;
border-color: #f5d48a;
}
.fuel-slot.empty {
border-style: dashed;
background: #0c1c25;
}
.fuel-slot .pictogram { width: 100%; height: 100%; }
.ship-stern > span { .ship-stern > span {
display: flex; display: flex;
gap: 5px; gap: 5px;
@ -2782,3 +2820,31 @@ input:not([type="checkbox"]):not([type="range"]) {
@media (max-width: 760px) { @media (max-width: 760px) {
.ship-zones { inset: 30px 9px 12px; } .ship-zones { inset: 30px 9px 12px; }
} }
/* Discover examples are illustrations, not live ship resources. */
.energy-discovery { max-width: 38rem; margin-top: 1rem; }
.energy-demo-content h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.energy-demo-content p { line-height: 1.5; margin: .5rem 0; }
.energy-demo-diagram { display: grid; gap: .45rem; margin: .8rem 0; }
.energy-demo-diagram > div { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .5rem .65rem; background: #ffffff08; border: 1px solid #ffffff20; border-radius: .4rem; }
.energy-demo-diagram svg { width: 1.5rem; height: 1.5rem; }
.energy-demo-diagram strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.energy-demo-content small { opacity: .75; }
.energy-demo-navigation { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; margin-top: .85rem; }
.energy-demo-navigation button { min-height: 44px; min-width: 44px; }
.energy-demo-dots { display: flex; gap: .3rem; }
.energy-demo-dots > span { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; opacity: .25; }
.energy-demo-dots > .active { opacity: 1; }
/* Give cells the whole button width even on narrow three-zone ships. */
.energy-system button { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 2px; padding-bottom: 5px; }
.energy-system .system-caption { width: 100%; min-width: 0; }
.resource-transition { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.resource-transition > [role="group"] { display: flex; min-width: 0; }
.resource-transition .fuel-rack { border-radius: 5px; border-top: 2px solid #81939a; padding: 3px; }
.resource-transition .fuel-slot { width: 14px; height: 20px; }
.energy-demo-diagram .fuel-slot svg { width: 100%; height: 100%; }
@media (max-width: 480px) {
.energy-demo-diagram > div { grid-template-columns: 1.5rem minmax(0, 1fr); }
.energy-demo-diagram .resource-transition { grid-column: 2; justify-content: flex-start; }
}

View file

@ -1,3 +1,4 @@
import { energyCells, fuelRack } from "./resource-cells.js";
import { illustration, threatIllustration } from "./art.js"; import { illustration, threatIllustration } from "./art.js";
import { pictogram, shipLocator, equipmentPicture } from "./icons.js"; import { pictogram, shipLocator, equipmentPicture } from "./icons.js";
@ -15,8 +16,6 @@ export function createTacticalView({
C: t("app.systems"), C: t("app.systems"),
})[key]; })[key];
const actionWords = (text) => text.replace(/\b[ABC]\b/g, actionName); const actionWords = (text) => text.replace(/\b[ABC]\b/g, actionName);
const meter = (value, capacity) =>
`<span class="charge-pips" aria-hidden="true">${Array.from({ length: capacity }, (_, i) => `<i class="${i < value ? "filled" : ""}"></i>`).join("")}</span>`;
function stationControls({ function stationControls({
station, station,
@ -73,12 +72,14 @@ export function createTacticalView({
), ),
"blue-lower": t("tactical.c_launches_a_rocket_it_attacks_on_the"), "blue-lower": t("tactical.c_launches_a_rocket_it_attacks_on_the"),
}[station]; }[station];
const flow = `<div class="energy-flow"><span>${illustration(sourceIcon)}<b>${sourceValue}</b><small>${esc(sourceName)}</small></span>${pictogram("right")}<span>${illustration(system)}<b>${s[system]}/${capacity}</b><small>${esc(energyName)}</small></span></div>`; const sourceZone = system === "shield" ? zone : "white";
const sourceCapacity = (sourceZone === "white" ? 5 : 3) - Number(ship.zones[sourceZone].damage.includes("reactor"));
const flow = `<div class="energy-flow"><span>${illustration(sourceIcon)}${centralRefuel ? fuelRack(sourceValue, t) : energyCells(sourceValue, sourceCapacity, t)}<small>${esc(sourceName)}</small></span>${pictogram("right")}<span>${illustration(system)}${energyCells(s[system], capacity, t)}<small>${esc(energyName)}</small></span></div>`;
const details = (key, art, text, extra = "") => const details = (key, art, text, extra = "") =>
`<template>${key === "B" ? "" : `<div class="system-detail-art">${illustration(art)}</div>`}<p class="room-location">${esc(zoneName(zone))} · ${deck === "upper" ? t("tactical.upper_deck") : t("tactical.lower_deck")}</p>${extra}<p>${esc(actionWords(text))}</p><p class="planning-note">${t("tactical.program_on_a_turn_when_your_crew_member", { value1: actionName(key) })}</p>${canPlan ? `<button class="primary icon-label" data-pick-action="${key}"><span class="action-key">${pictogram(key)}</span>${t("tactical.show_my_cards", { value1: actionName(key) })}</button>` : ""}</template>`; `<template>${key === "B" ? "" : `<div class="system-detail-art">${illustration(art)}</div>`}<p class="room-location">${esc(zoneName(zone))} · ${deck === "upper" ? t("tactical.upper_deck") : t("tactical.lower_deck")}</p>${extra}<p>${esc(actionWords(text))}</p><p class="planning-note">${t("tactical.program_on_a_turn_when_your_crew_member", { value1: actionName(key) })}</p>${canPlan ? `<button class="primary icon-label" data-pick-action="${key}"><span class="action-key">${pictogram(key)}</span>${t("tactical.show_my_cards", { value1: actionName(key) })}</button>` : ""}</template>`;
return `<div class="systems illustrated-systems"> return `<div class="systems illustrated-systems">
<div class="system-card weapon-system"><button title="${esc(weapon)}" data-inspect="system-${station}-A" data-inspect-title="${esc(weapon)}" aria-haspopup="dialog" aria-label="${esc(`${weapon} · ${powerLabel}`)}"><span class="action-key">${pictogram("A")}</span>${illustration(weaponArt)}<span class="system-caption"><strong>${t("tactical.fire")}</strong><span class="power-value">${symbol("impact", powerLabel, power)}</span></span></button>${details("A", weaponArt, fireText, `<div class="weapon-facts">${symbol("impact", powerLabel, power)}${symbol(light ? "check" : "reactor", light ? t("tactical.own_battery") : t("tactical.cost_1_energy"), light ? t("tactical.own_battery_defc21") : "−1")}</div>`)}</div> <div class="system-card weapon-system"><button title="${esc(weapon)}" data-inspect="system-${station}-A" data-inspect-title="${esc(weapon)}" aria-haspopup="dialog" aria-label="${esc(`${weapon} · ${powerLabel}`)}"><span class="action-key">${pictogram("A")}</span>${illustration(weaponArt)}<span class="system-caption"><strong>${t("tactical.fire")}</strong><span class="power-value">${symbol("impact", powerLabel, power)}</span></span></button>${details("A", weaponArt, fireText, `<div class="weapon-facts">${symbol("impact", powerLabel, power)}${symbol(light ? "check" : "reactor", light ? t("tactical.own_battery") : t("tactical.cost_1_energy"), light ? t("tactical.own_battery_defc21") : "−1")}</div>`)}</div>
<div class="system-card energy-system ${s[system] === 0 ? "depleted" : ""}"><button data-inspect="system-${station}-B" data-inspect-title="${esc(charge)}" aria-haspopup="dialog" aria-label="${esc(`${charge} · ${s[system]}/${capacity}`)}"><span class="action-key">${pictogram("B")}</span>${illustration(system)}<span class="system-caption"><strong>${t("tactical.charge")}</strong><b class="energy-value">${s[system]}/${capacity}</b>${meter(s[system], capacity)}</span></button>${details("B", system, chargeText, flow)}</div> <div class="system-card energy-system ${s[system] === 0 ? "depleted" : ""}"><button title="${esc(t("tactical.energy_cells", { value: s[system], capacity }))}" data-inspect="system-${station}-B" data-inspect-title="${esc(charge)}" aria-haspopup="dialog" aria-label="${esc(`${charge} · ${s[system]}/${capacity}`)}"><span class="action-key">${pictogram("B")}</span>${illustration(system)}<span class="system-caption"><strong>${t("tactical.charge")}</strong>${energyCells(s[system], capacity, t)}</span></button>${details("B", system, chargeText, flow)}</div>
<div class="system-card special-system"><button title="${esc(c)}" data-inspect="system-${station}-C" data-inspect-title="${esc(c)}" aria-haspopup="dialog" aria-label="${esc(c)}"><span class="action-key">${pictogram("C")}</span>${illustration(cIcon)}<span class="system-caption"><strong>${esc(c)}</strong></span></button>${details("C", cIcon, cText)}</div> <div class="system-card special-system"><button title="${esc(c)}" data-inspect="system-${station}-C" data-inspect-title="${esc(c)}" aria-haspopup="dialog" aria-label="${esc(c)}"><span class="action-key">${pictogram("C")}</span>${illustration(cIcon)}<span class="system-caption"><strong>${esc(c)}</strong></span></button>${details("C", cIcon, cText)}</div>
</div>`; </div>`;
} }
@ -131,7 +132,7 @@ export function createTacticalView({
.join( .join(
"", "",
)}${[1, 2].map((i) => `<div class="ship-passage passage-${i}"><button data-inspect="door-${level}-${i}" data-inspect-title="${t("tactical.doors_same_deck")}" aria-label="${t("tactical.passage")} ${esc(zoneName(zones[i - 1]))} ↔ ${esc(zoneName(zones[i]))} · ${level === "upper" ? t("tactical.upper_deck") : t("tactical.lower_deck")}" aria-haspopup="dialog">${pictogram("move")}</button>${movementHelp(false)}</div>`).join("")}</div>`; )}${[1, 2].map((i) => `<div class="ship-passage passage-${i}"><button data-inspect="door-${level}-${i}" data-inspect-title="${t("tactical.doors_same_deck")}" aria-label="${t("tactical.passage")} ${esc(zoneName(zones[i - 1]))} ↔ ${esc(zoneName(zones[i]))} · ${level === "upper" ? t("tactical.upper_deck") : t("tactical.lower_deck")}" aria-haspopup="dialog">${pictogram("move")}</button>${movementHelp(false)}</div>`).join("")}</div>`;
return `<div class="ship-vessel"><div class="ship-hull"><div class="ship-zones" aria-hidden="true">${zones.map(z => `<span style="--zone:var(--${z})"></span>`).join("")}</div><div class="ship-bow" aria-hidden="true"><svg viewBox="0 0 600 46" preserveAspectRatio="none"><path class="hull-shell" d="M2 46V32L40 20 200 10 240 3h120l40 7 160 10 38 12v14"/><path class="bridge-window" d="m237 16 11-6h104l11 6-13 12H250Z"/><path d="M275 11v16m50-16v16M32 39h135m266 0h135"/></svg></div>${deck("upper")}<div class="between-decks"><svg class="energy-conduits" viewBox="0 0 600 44" preserveAspectRatio="none" aria-hidden="true"><path class="conduit-back" d="M300 44V28H120V44m180-16h180v16M100 44V0M300 28V0M500 44V0"/><path d="M300 44V28H120V44m180-16h180v16M100 44V0M300 28V0M500 44V0"/><path d="m96 6 4-4 4 4m192 0 4-4 4 4m192 0 4-4 4 4M116 38l4 4 4-4m352 0 4 4 4-4M193 24l-5 4 5 4m214-8 5 4-5 4"/></svg>${zones.map((z) => `<div class="lift-bay"><button class="lift-control ${ship.zones[z].damage.includes("lift") ? "damaged-lift" : ""}" data-inspect="lift-${z}" data-inspect-title="${t("tactical.gravolift")} · ${esc(zoneName(z))}" aria-label="${t("tactical.gravolift")} · ${esc(zoneName(z))}${ship.zones[z].damage.includes("lift") ? " · " + t("tactical.damaged") : ""}" aria-haspopup="dialog">${pictogram("lift")}</button>${movementHelp(true)}</div>`).join("")}</div>${deck("lower")}</div><div class="ship-stern" aria-hidden="true">${zones.map(() => `<span><i></i><i></i><i></i></span>`).join("")}</div></div><div class="ship-key"><span>${pictogram("A")}${t("tactical.fire")}</span><span>${pictogram("B")}${t("app.energy")}</span><span>${pictogram("C")}${t("app.systems")}</span></div>`; return `<div class="ship-vessel"><div class="ship-hull"><div class="ship-zones" aria-hidden="true">${zones.map(z => `<span style="--zone:var(--${z})"></span>`).join("")}</div><div class="ship-bow" aria-hidden="true"><svg viewBox="0 0 600 46" preserveAspectRatio="none"><path class="hull-shell" d="M2 46V32L40 20 200 10 240 3h120l40 7 160 10 38 12v14"/><path class="bridge-window" d="m237 16 11-6h104l11 6-13 12H250Z"/><path d="M275 11v16m50-16v16M32 39h135m266 0h135"/></svg></div>${deck("upper")}<div class="between-decks"><svg class="energy-conduits" viewBox="0 0 600 44" preserveAspectRatio="none" aria-hidden="true"><path class="conduit-back" d="M300 44V28H120V44m180-16h180v16M100 44V0M300 28V0M500 44V0"/><path d="M300 44V28H120V44m180-16h180v16M100 44V0M300 28V0M500 44V0"/><path d="m96 6 4-4 4 4m192 0 4-4 4 4m192 0 4-4 4 4M116 38l4 4 4-4m352 0 4 4 4-4M193 24l-5 4 5 4m214-8 5 4-5 4"/></svg>${zones.map((z) => `<div class="lift-bay"><button class="lift-control ${ship.zones[z].damage.includes("lift") ? "damaged-lift" : ""}" data-inspect="lift-${z}" data-inspect-title="${t("tactical.gravolift")} · ${esc(zoneName(z))}" aria-label="${t("tactical.gravolift")} · ${esc(zoneName(z))}${ship.zones[z].damage.includes("lift") ? " · " + t("tactical.damaged") : ""}" aria-haspopup="dialog">${pictogram("lift")}</button>${movementHelp(true)}</div>`).join("")}</div>${deck("lower")}</div><div class="ship-stern">${zones.map(z => z === "white" ? fuelRack(ship.fuel, t) : `<span aria-hidden="true"><i></i><i></i><i></i></span>`).join("")}</div></div><div class="ship-key"><span>${pictogram("A")}${t("tactical.fire")}</span><span>${pictogram("B")}${t("app.energy")}</span><span>${pictogram("C")}${t("app.systems")}</span></div>`;
} }
function threatPortrait(th) { function threatPortrait(th) {

View file

@ -0,0 +1,36 @@
import { energyCells, fuelRack } from './resource-cells.js';
import { translate } from './i18n.js';
import { pictogram } from './icons.js';
import { tutorialTextHtml } from './tutorial-text.js';
// Presentation only: these examples never read or mutate the engine or its history.
// Undamaged ship capacities: central reactor 5, side reactor 3, central shield 3.
// The shield example uses the central zone's reactor and shield.
export const ENERGY_DEMOS = [
{ id: 'shot', rows: [['reactor', 'central', 3, 2, 5], ['laser', 'shots', '+1']] },
{ id: 'refill', rows: [['reactor', 'central', 1, 5, 5], ['fuel', 'fuel', 3, 2]] },
{ id: 'shield', rows: [['reactor', 'zone', 1, 0, 5], ['shield', 'shield', 0, 1, 3], ['fuel', 'fuel', 3, 3]] },
{ id: 'side', rows: [['reactor', 'central', 2, 0, 5], ['reactor', 'side', 0, 2, 3], ['fuel', 'fuel', 3, 3]] },
];
export function energyDiscovery(index, locale) {
const demo = ENERGY_DEMOS[index];
const t = (key, params) => tutorialTextHtml(translate(locale, `energy.demo.${key}`, params), locale);
const resource = (icon, value, capacity) => icon === 'fuel'
? fuelRack(value, (key, params) => translate(locale, key, params))
: energyCells(value, capacity, (key, params) => translate(locale, key, params));
return `<section class="energy-discovery" aria-label="${t('label')}">
<div class="energy-demo-content" aria-live="polite" aria-atomic="true">
<h2 tabindex="-1">${t(`${demo.id}.title`)}</h2>
<p>${t(`${demo.id}.text`)}</p>
<div class="energy-demo-diagram">${demo.rows.map(([icon, label, before, after, capacity]) => `<div>${pictogram(icon)}<span>${t(label)}</span>${after === undefined ? `<strong>${before}</strong>` : `<span class="resource-transition"><span role="group" aria-label="${t('before')}">${resource(icon, before, capacity)}</span><span aria-hidden="true">→</span><span role="group" aria-label="${t('after')}">${resource(icon, after, capacity)}</span></span>`}</div>`).join('')}</div>
</div>
<nav class="energy-demo-navigation" aria-label="${t('label')}">
<button class="quiet icon-button" data-energy-demo="${index - 1}" aria-label="${t('back')}" ${index === 0 ? 'disabled' : ''}>${pictogram('left')}</button>
<span class="energy-demo-dots">${ENERGY_DEMOS.map((_, i) => `<span class="${i === index ? 'active' : ''}" aria-hidden="true"></span>`).join('')}</span>
<span>${index + 1} / ${ENERGY_DEMOS.length}</span>
${index < ENERGY_DEMOS.length - 1 ? `<button class="primary icon-label" data-energy-demo="${index + 1}"><span>${t('next')}</span>${pictogram('right')}</button>` : ''}
</nav>
</section>`;
}

View file

@ -39,3 +39,59 @@ for (const locale of ["en", "fr"]) {
assert.ok(tutorialTextHtml("[[action:weapons]] [[action:energy]] [[action:systems]]", locale).includes(pictogram("A"))); assert.ok(tutorialTextHtml("[[action:weapons]] [[action:energy]] [[action:systems]]", locale).includes(pictogram("A")));
}); });
} }
// Use genuine engine frames, including reverse playback, rather than a UI counter.
test("fuel rack follows actual resolution/replay fuel and retains empty slots", async () => {
const { beginResolution, stepResolution } = await import("../src/game/resolution.js");
const { TRACKS } = await import("../src/game/catalog.js");
await loadLocale("en");
await loadLocale("fr");
let r = beginResolution({
crewSize: 4, seed: "fuel-rack", threats: [],
tracks: Object.fromEntries(["red", "white", "blue", "internal"].map(z => [z, TRACKS[0]])),
programs: Array.from({ length: 4 }, (_, p) => Array.from({ length: 12 }, (_, turn) =>
p === 0 && turn < 4 ? { actions: [turn === 0 ? "lift" : "B"] } : null)),
});
while (!r.outcome && r.turn < 6) r = stepResolution(r);
assert.deepEqual([...new Set(r.frames.map(f => f.ship.fuel))], [3, 2, 1, 0]);
for (const locale of ["en", "fr"]) {
const t = (key, vars) => translate(locale, key, vars);
const view = createTacticalView({ t, esc: String, zoneName: String, symbol: () => "" });
const render = ship => view.shipCutaway({ ship, crewLabel: String }).replace(/<template>[\s\S]*?<\/template>/g, "");
for (const frame of [...r.frames, ...r.frames.toReversed()]) {
const html = render(frame.ship);
assert.equal((html.match(/class="fuel-slot filled"/g) ?? []).length, frame.ship.fuel);
assert.equal((html.match(/class="fuel-slot empty"/g) ?? []).length, 3 - frame.ship.fuel);
assert.ok(html.includes(`aria-label="${t("tactical.fuel_capsules", { count: frame.ship.fuel })}"`));
const stern = html.split('<div class="ship-stern">')[1].split('<div class="ship-key">')[0];
assert.equal((stern.match(/<i>/g) ?? []).length, 6, "side jump thrusters remain");
if (frame.ship.fuel) assert.ok(stern.includes(pictogram("fuel")));
}
assert.equal((render({ ...r.ship, fuel: 4 }).match(/class="fuel-slot filled"/g) ?? []).length, 4);
}
});
test("energy cells preserve exact capacity, empty and heroic excess in live/replay markup", async () => {
const { energyCells } = await import('../preview/resource-cells.js');
for (const locale of ['en', 'fr']) {
await loadLocale(locale);
const t = (k, p) => translate(locale, k, p);
for (const [value, capacity] of [[0, 5], [3, 5], [2, 2], [6, 5], [4, 2]]) {
const html = energyCells(value, capacity, t);
assert.equal((html.match(/class="energy-cell /g) || []).length, Math.max(value, capacity));
assert.equal((html.match(/energy-cell filled/g) || []).length, value);
assert.equal((html.match(/ excess"/g) || []).length, Math.max(0, value - capacity));
assert.ok(html.includes(t('tactical.energy_cells', { value, capacity })));
assert.doesNotMatch(html, />\d/);
}
const ship = structuredClone(createLesson('energy', 0).game.initialShip);
ship.zones.white.reactor = 6;
ship.zones.red.damage.push('shield');
const view = createTacticalView({ t, esc: String, zoneName: String, symbol: () => '' });
const html = view.shipCutaway({ ship, crewLabel: String });
assert.ok(html.includes(energyCells(6, 5, t)));
assert.ok(html.includes(energyCells(ship.zones.red.shield, 1, t)));
assert.match(html, /class="system-caption"><strong>[^<]*<\/strong><span class="energy-value energy-cells"/);
assert.doesNotMatch(html, /charge-pips/);
}
});

View file

@ -0,0 +1,64 @@
// Optional: PLAYWRIGHT_MODULE=/path/to/playwright/index.mjs node test/tutorial-energy.browser.mjs
import assert from "node:assert/strict";
import { createPreviewServer } from "../preview/server.js";
const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || "playwright");
const server = createPreviewServer();
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
let browser;
try {
browser = await chromium.launch({ headless: true });
for (const [locale, width] of [["en", 1280], ["fr", 380], ["fr", 320]]) {
const page = await browser.newPage({ viewport: { width, height: 900 } });
const errors = [];
page.on("pageerror", error => errors.push(error.message));
await page.goto(`http://127.0.0.1:${server.address().port}/learn?chapter=energy&locale=${locale}`);
await page.waitForSelector(".energy-discovery");
const before = await page.evaluate(() => JSON.stringify(localStorage));
for (let i = 0; i < 4; i++) {
assert.equal(await page.locator('.energy-demo-diagram .energy-cells').count(), i < 2 ? 2 : 4);
assert.doesNotMatch(await page.locator('.energy-demo-diagram').innerText(), /\d+\/\d+/);
if (i === 0) await page.screenshot({ path: `/tmp/space-alert-cells-demo-${locale}-${width}.png` });
assert.equal(await page.locator('[data-tutorial-step="0"]').count(), 1);
assert.equal(await page.locator('[data-guide="continue"]').count(), i === 3 ? 1 : 0);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false);
if (i < 3) {
await page.click(`[data-energy-demo="${i + 1}"]`);
assert.equal(await page.locator(".energy-discovery h2").evaluate(el => el === document.activeElement), true);
}
}
assert.equal(await page.evaluate(() => JSON.stringify(localStorage)), before, "demos must not save controller progress");
await page.click('[data-energy-demo="2"]');
await page.locator('[data-energy-demo="3"]').focus();
await page.keyboard.press("Enter");
await page.click('[data-guide="continue"]');
await page.waitForSelector('[data-tutorial-step="1"]');
assert.equal(await page.locator(".energy-discovery").count(), 0);
// The energy lesson hides the resource strip, not the authoritative fuel rack.
assert.equal(await page.locator('#resources').isVisible(), false);
assert.equal(await page.locator('.fuel-rack').isVisible(), true);
assert.equal(await page.locator('.fuel-slot.filled').count(), 3);
assert.equal(await page.locator('.ship-stern i').count(), 6);
assert.equal(await page.locator('.fuel-rack').getAttribute('aria-label'), locale === 'fr'
? 'Capsules de carburant restantes : 3' : 'Fuel capsules remaining: 3');
const cellSizes = await page.locator('.energy-system .energy-cell').evaluateAll(cells => cells.map(cell => ({ width: cell.getBoundingClientRect().width, height: cell.getBoundingClientRect().height })));
assert.ok(cellSizes.length > 0);
assert.ok(cellSizes.every(cell => cell.width === 10 && cell.height === 17), 'empty and filled cells have identical usable dimensions');
const rack = await page.locator('.fuel-rack').boundingBox();
const reactor = await page.locator('[data-station="white-lower"] .energy-system').boundingBox();
assert.ok(rack.y >= reactor.y + reactor.height, 'rack is below central reactor');
assert.ok(Math.abs(rack.x + rack.width / 2 - reactor.x - reactor.width / 2) < 5, 'rack aligns with central reactor');
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false);
await page.locator('.fuel-rack').scrollIntoViewIfNeeded();
await page.screenshot({ path: `/tmp/space-alert-cells-ship-${locale}-${width}.png` });
await page.click('[data-guide="previous"]');
await page.waitForSelector(".energy-discovery");
await page.click('[data-guide="restart"]');
await page.waitForSelector('[data-energy-demo="-1"]:disabled');
assert.deepEqual(errors, []);
await page.close();
}
console.log("Energy Discover: EN/FR desktop/mobile, keyboard, back/restart and progress isolation passed");
} finally {
await browser?.close();
await new Promise(resolve => server.close(resolve));
}

View file

@ -0,0 +1,31 @@
import { energyCells, fuelRack } from "../preview/resource-cells.js";
import test from "node:test";
import assert from "node:assert/strict";
import { loadLocale, translate } from "../preview/i18n.js";
import { energyDiscovery, ENERGY_DEMOS } from "../preview/tutorial-energy.js";
for (const locale of ["en", "fr"]) {
test(`energy Discover has four short illustrated examples (${locale})`, async () => {
await loadLocale(locale);
assert.deepEqual(ENERGY_DEMOS.map(demo => demo.id), ["shot", "refill", "shield", "side"]);
for (const [index, demo] of ENERGY_DEMOS.entries()) {
const html = energyDiscovery(index, locale);
for (const [icon, , before, after, capacity] of demo.rows) {
if (after === undefined) assert.ok(html.includes(`<strong>${before}</strong>`));
else for (const value of [before, after]) assert.ok(html.includes(icon === 'fuel' ? fuelRack(value, (k, p) => translate(locale, k, p)) : energyCells(value, capacity, (k, p) => translate(locale, k, p))));
}
assert.doesNotMatch(html, />\d+\/\d+ →/);
assert.ok(html.includes(translate(locale, `energy.demo.${demo.id}.title`)));
assert.ok(translate(locale, `energy.demo.${demo.id}.text`).length < 210);
assert.doesNotMatch(html, /Illustration/);
assert.match(html, /tabindex="-1"/);
assert.match(html, /aria-live="polite"/);
assert.doesNotMatch(html, /\[\[action:/);
assert.equal(html.includes(`data-energy-demo="${index + 1}"`), index < 3);
}
assert.match(energyDiscovery(0, locale), /data-energy-demo="-1"[^>]*disabled/);
});
}