Improve tutorial guidance and add viewer replay controls
This commit is contained in:
parent
d1be538bd4
commit
3de2e364dc
13 changed files with 377 additions and 23 deletions
|
|
@ -17,6 +17,8 @@ Open <http://127.0.0.1:5250>. Start with **Flight school / École de vol**: nine
|
||||||
|
|
||||||
For a full mission, expand **Local session / Session locale**. Select 1–5 humans, the crew, mission, threat pools and optional modules. In solo, you control four androids and have access to the full action deck. In multiplayer testing, open another tab with `?seat=1`, etc. Readiness lasts two minutes; everyone must be ready together. The local mission starts after a three-second countdown. If someone misses the window, the crew keeps waiting. Click a card half to fill the highlighted turn; the cursor advances afterward. Click any editable turn to select it, including a filled turn to replace its card. W leaves a wait and advances; Backspace clears the selected turn, or steps back if it is empty. The hourglass and erase buttons provide the same controls with a mouse or touch. Left/right arrow keys queue horizontal movement; up/down queue a deck change, using an available card. Typing in fields is unaffected. Shift-click or Combine retains multi-card selection; then choose a turn. Advance individual phases to lock previous turns, or let the shared clock do so. After programming, the captain can resolve one step at a time or finish the mission; everyone can inspect the replay and log.
|
For a full mission, expand **Local session / Session locale**. Select 1–5 humans, the crew, mission, threat pools and optional modules. In solo, you control four androids and have access to the full action deck. In multiplayer testing, open another tab with `?seat=1`, etc. Readiness lasts two minutes; everyone must be ready together. The local mission starts after a three-second countdown. If someone misses the window, the crew keeps waiting. Click a card half to fill the highlighted turn; the cursor advances afterward. Click any editable turn to select it, including a filled turn to replace its card. W leaves a wait and advances; Backspace clears the selected turn, or steps back if it is empty. The hourglass and erase buttons provide the same controls with a mouse or touch. Left/right arrow keys queue horizontal movement; up/down queue a deck change, using an available card. Typing in fields is unaffected. Shift-click or Combine retains multi-card selection; then choose a turn. Advance individual phases to lock previous turns, or let the shared clock do so. After programming, the captain can resolve one step at a time or finish the mission; everyone can inspect the replay and log.
|
||||||
|
|
||||||
|
During resolution or after completion, **Review a step** selects an already-resolved frame. **Play replay** animates consecutive frames from that selection (or restarts at the beginning when viewing the latest frame); **Pause replay** stops playback. **Jump to latest state** skips straight back without replaying animations. These viewer-only controls work in tutorials and full missions, never resolve new steps, and do not alter the mission clock. Playback stops at the last frame available when it began, even if another player resolves further steps meanwhile.
|
||||||
|
|
||||||
Training starts with its clock paused. **Start practice clock** and **Pause clock** control time only in training; normal missions retain their shared, continuous clock. You can also advance lesson phases explicitly.
|
Training starts with its clock paused. **Start practice clock** and **Pause clock** control time only in training; normal missions retain their shared, continuous clock. You can also advance lesson phases explicitly.
|
||||||
|
|
||||||
The local seat selector, “Ready all” and “Next announcement” buttons are development tools. This host has **no authentication** and deliberately listens only on `127.0.0.1`. It is not an online multiplayer deployment. Use external voice for cooperation; mission announcements are visual, with sound effects for game actions. Communications-blackout silence relies on the players.
|
The local seat selector, “Ready all” and “Next announcement” buttons are development tools. This host has **no authentication** and deliberately listens only on `127.0.0.1`. It is not an online multiplayer deployment. Use external voice for cooperation; mission announcements are visual, with sound effects for game actions. Communications-blackout silence relies on the players.
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { LESSONS } from "../src/tutorials.js";
|
||||||
import { snapshot } from "../src/view.js";
|
import { snapshot } from "../src/view.js";
|
||||||
import { mountConsole } from "../preview/app.js";
|
import { mountConsole } from "../preview/app.js";
|
||||||
import { pictogram } from "../preview/icons.js";
|
import { pictogram } from "../preview/icons.js";
|
||||||
|
import { tutorialPhaseButton } from "../preview/tutorial-program.js";
|
||||||
import { duration, practiceClockText } from "../preview/clock.js";
|
import { duration, practiceClockText } from "../preview/clock.js";
|
||||||
import { createSoundDesign } from "../preview/sound.js";
|
import { createSoundDesign } from "../preview/sound.js";
|
||||||
import html from "../preview/index.html";
|
import html from "../preview/index.html";
|
||||||
|
|
@ -195,6 +196,10 @@ export async function mountLesson(
|
||||||
.join("")}</div>${pictogram("step")}</div></div>`;
|
.join("")}</div>${pictogram("step")}</div></div>`;
|
||||||
}
|
}
|
||||||
function renderGuide(s) {
|
function renderGuide(s) {
|
||||||
|
// Put planning decisions beside the program tools, without moving playback.
|
||||||
|
if (s.state.stage === 'programming')
|
||||||
|
target.querySelector('#selection-tools').before(programControls);
|
||||||
|
else target.querySelector('#hand').after(programControls);
|
||||||
const planned = s.state.game.programs[0].some(
|
const planned = s.state.game.programs[0].some(
|
||||||
(slot) => slot?.cards?.length,
|
(slot) => slot?.cards?.length,
|
||||||
);
|
);
|
||||||
|
|
@ -210,7 +215,7 @@ export async function mountLesson(
|
||||||
s.step === 2 &&
|
s.step === 2 &&
|
||||||
completedTurns(s.state) >= 3 &&
|
completedTurns(s.state) >= 3 &&
|
||||||
!s.completed;
|
!s.completed;
|
||||||
programControls.innerHTML = `${chapter === "basics" && s.step === 3 ? `<button data-guide="timeout" class="primary icon-label" aria-keyshortcuts="Enter" title="${t("timing.next_scenario")} · ↵" ${s.busy ? "disabled" : ""}>${pictogram("clock")}<span>${t("timing.next_scenario")}</span><kbd aria-hidden="true">↵</kbd></button>` : ""}${canPlay(s) ? transport("playback", playing ? "pause" : "right", playing ? t("basics.pause") : t("tutorial.play_program")) : ""}${!LESSONS[index].basics && chapter !== "first-shot" && s.step === 1 && s.state.phase === 1 ? transport("phase", "lock", t("tutorial.lock_phase", { phase: 1 }), s.busy) : ""}${!LESSONS[index].basics && s.step === 1 && (chapter !== "energy" || s.state.phase === 2) ? `<button data-guide="run" class="primary icon-button" aria-keyshortcuts="Enter" title="${t("basics.run_program")} · ↵" aria-label="${t("basics.run_program")}" ${(chapter === "first-shot" ? !readyToFire : !planned) || s.busy ? "disabled" : ""}>${pictogram("check")}<kbd>↵</kbd></button>` : ""}`;
|
programControls.innerHTML = `${chapter === "basics" && s.step === 3 ? `<button data-guide="timeout" class="primary icon-label" aria-keyshortcuts="Enter" title="${t("timing.next_scenario")} · ↵" ${s.busy ? "disabled" : ""}>${pictogram("clock")}<span>${t("timing.next_scenario")}</span><kbd aria-hidden="true">↵</kbd></button>` : ""}${canPlay(s) ? transport("playback", playing ? "pause" : "right", playing ? t("basics.pause") : t("tutorial.play_program")) : ""}${!LESSONS[index].basics && chapter !== "first-shot" && s.step === 1 && s.state.phase === 1 ? tutorialPhaseButton(s.state, locale, s.busy) : ""}${!LESSONS[index].basics && s.step === 1 && (chapter !== "energy" || s.state.phase === 2) ? `<button data-guide="run" class="primary icon-label lesson-run" aria-keyshortcuts="Enter" title="${t("basics.run_program")} · ↵" ${(chapter === "first-shot" ? !readyToFire : !planned) || s.busy ? "disabled" : ""}>${pictogram("check")}<span>${t("basics.run_program")}</span><kbd aria-hidden="true">↵</kbd></button>` : ""}`;
|
||||||
if (phaseLesson && s.state.stage === "programming" && s.step > 0) {
|
if (phaseLesson && s.state.stage === "programming" && s.step > 0) {
|
||||||
const ready =
|
const ready =
|
||||||
s.state.game.programs[0][(s.state.phase === 1 ? 1 : 4) - 1]?.cards
|
s.state.game.programs[0][(s.state.phase === 1 ? 1 : 4) - 1]?.cards
|
||||||
|
|
@ -220,7 +225,7 @@ export async function mountLesson(
|
||||||
s.state.mission.phaseEndsMs[s.state.phase - 1] -
|
s.state.mission.phaseEndsMs[s.state.phase - 1] -
|
||||||
s.state.observedAt,
|
s.state.observedAt,
|
||||||
);
|
);
|
||||||
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-button" aria-keyshortcuts="Enter" title="${t("phases.execute")} · ↵" aria-label="${t("phases.execute")}" ${!ready || s.busy ? "disabled" : ""}>${pictogram("check")}<kbd>↵</kbd></button>`}<div class="practice-clock"><div><strong data-practice-phase>${t("phases.deadline", { phase: s.state.phase, time: phaseTime })}</strong><small>${t("phases.total")} · <span data-practice-time>${practiceClockText(s.state, locale)}</span></small></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><small>${t("phases.total")} · <span data-practice-time>${practiceClockText(s.state, locale)}</span></small></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>${s.step === 0 && (chapter === "basics" || phaseLesson) ? missionOverview() : ""}${["basics", "first-shot", "energy"].includes(chapter) ? `<small class="lesson-scope">${t("timing.exercise", { turns: chapter === "energy" ? 4 : 3 })}${chapter === "basics" ? ` · ${deadline ? 2 : 1}/2` : ""}</small>` : ""}<p class="native-guide-text">${escape(missed ? t("tutorial.destination_missed_go_back_and_plan_another_route") : s.text)}</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>${s.step === 0 && (chapter === "basics" || phaseLesson) ? missionOverview() : ""}${["basics", "first-shot", "energy"].includes(chapter) ? `<small class="lesson-scope">${t("timing.exercise", { turns: chapter === "energy" ? 4 : 3 })}${chapter === "basics" ? ` · ${deadline ? 2 : 1}/2` : ""}</small>` : ""}<p class="native-guide-text">${escape(missed ? t("tutorial.destination_missed_go_back_and_plan_another_route") : s.text)}</p>${chapter === "first-shot" && s.step < 2 ? `<p class="lesson-shield-note">${pictogram("shield")}<span>${t("lesson.first-shot.shield")}</span></p>` : ""}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { createReplay } from "./replay.js";
|
||||||
import { createResolutionEffects } from "./resolution-effects.js";
|
import { createResolutionEffects } from "./resolution-effects.js";
|
||||||
import { createSoundDesign } from "./sound.js";
|
import { createSoundDesign } from "./sound.js";
|
||||||
import { plannedRoute } from "./program-route.js";
|
import { plannedRoute } from "./program-route.js";
|
||||||
|
|
@ -70,6 +71,17 @@ export function mountConsole(root, host = null) {
|
||||||
root.ownerDocument.addEventListener("keydown", unlockSound, true);
|
root.ownerDocument.addEventListener("keydown", unlockSound, true);
|
||||||
const effects = createResolutionEffects(root, cue);
|
const effects = createResolutionEffects(root, cue);
|
||||||
let autoResolve = false;
|
let autoResolve = false;
|
||||||
|
const replay = createReplay({
|
||||||
|
index: () => replayFrame,
|
||||||
|
count: () => view?.game?.resolution?.frames.length ?? 0,
|
||||||
|
show: (index) => { replayFrame = index; rerender(); },
|
||||||
|
busy: () => effects.busy() || root.ownerDocument.hidden,
|
||||||
|
});
|
||||||
|
intervals.push(setInterval(() => {
|
||||||
|
const wasPlaying = replay.playing;
|
||||||
|
replay.tick();
|
||||||
|
if (wasPlaying && !replay.playing) rerender();
|
||||||
|
}, 100));
|
||||||
const t = (key, params) => translate(locale, key, params);
|
const t = (key, params) => translate(locale, key, params);
|
||||||
const actionWords = (text) =>
|
const actionWords = (text) =>
|
||||||
text.replace(
|
text.replace(
|
||||||
|
|
@ -313,8 +325,14 @@ export function mountConsole(root, host = null) {
|
||||||
showPlannedPosition(next ? Number(next.dataset.turn) : null);
|
showPlannedPosition(next ? Number(next.dataset.turn) : null);
|
||||||
});
|
});
|
||||||
function render(next, force = false) {
|
function render(next, force = false) {
|
||||||
|
if (!next.game?.resolution || (replayFrame !== null &&
|
||||||
|
replayFrame >= next.game.resolution.frames.length)) {
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
|
replayFrame = null;
|
||||||
|
}
|
||||||
view = next;
|
view = next;
|
||||||
received = performance.now();
|
if (!force) received = performance.now();
|
||||||
const newKey = `${view.revision}/${seat}/${locale}`;
|
const newKey = `${view.revision}/${seat}/${locale}`;
|
||||||
renderCareers(next);
|
renderCareers(next);
|
||||||
if (!force && key === newKey) return;
|
if (!force && key === newKey) return;
|
||||||
|
|
@ -583,7 +601,7 @@ export function mountConsole(root, host = null) {
|
||||||
$("#player-help").textContent = planning
|
$("#player-help").textContent = planning
|
||||||
? selected.length
|
? selected.length
|
||||||
? t("app.choose_a_turn_for_this_card")
|
? t("app.choose_a_turn_for_this_card")
|
||||||
: t("app.click_a_card_to_fill_the_next_turn")
|
: ""
|
||||||
: view.stage === "presence"
|
: view.stage === "presence"
|
||||||
? t("app.ready_lasts_two_minutes_we_wait_until_everyone")
|
? t("app.ready_lasts_two_minutes_we_wait_until_everyone")
|
||||||
: view.stage === "resolution"
|
: view.stage === "resolution"
|
||||||
|
|
@ -603,7 +621,7 @@ export function mountConsole(root, host = null) {
|
||||||
: planning
|
: planning
|
||||||
? `${g?.solo ? "" : button("advance-phase", t("app.next_phase"), own.finishedPlanning || own.planningPhase >= view.mission.phaseEndsMs.length)}${button("finish-planning", t("app.lock_my_program"), own.finishedPlanning || view.phase < view.mission.phaseEndsMs.length)}${g.dataCredits ? button("draw", `${t("app.draw")} +${g.dataCredits}`) : ""}${g.androidDataCredits ? button("draw-android", t("app.android_card") + ` +${g.androidDataCredits}`, !g.canDrawAndroid) : ""}`
|
? `${g?.solo ? "" : button("advance-phase", t("app.next_phase"), own.finishedPlanning || own.planningPhase >= view.mission.phaseEndsMs.length)}${button("finish-planning", t("app.lock_my_program"), own.finishedPlanning || view.phase < view.mission.phaseEndsMs.length)}${g.dataCredits ? button("draw", `${t("app.draw")} +${g.dataCredits}`) : ""}${g.androidDataCredits ? button("draw-android", t("app.android_card") + ` +${g.androidDataCredits}`, !g.canDrawAndroid) : ""}`
|
||||||
: view.stage === "resolution"
|
: view.stage === "resolution"
|
||||||
? `<button data-command="resolve" class="primary icon-button" title="${t("app.next_resolution_step")}" aria-label="${t("app.next_resolution_step")}" ${seat !== 0 || !!resolution?.outcome ? "disabled" : ""}>${pictogram("step")}</button><button data-command="resolve-all" class="quiet icon-button" title="${t(autoResolve ? "basics.pause" : "app.resolve_mission")}" aria-label="${t(autoResolve ? "basics.pause" : "app.resolve_mission")}" ${seat !== 0 || !!resolution?.outcome ? "disabled" : ""}>${pictogram(autoResolve ? "pause" : "right")}</button>`
|
? `<button data-command="resolve" class="primary icon-button" title="${t("app.next_resolution_step")}" aria-label="${t("app.next_resolution_step")}" ${seat !== 0 || replayFrame !== null || !!resolution?.outcome ? "disabled" : ""}>${pictogram("step")}</button><button data-command="resolve-all" class="quiet icon-button" title="${t(autoResolve ? "basics.pause" : "app.resolve_mission")}" aria-label="${t(autoResolve ? "basics.pause" : "app.resolve_mission")}" ${seat !== 0 || replayFrame !== null || !!resolution?.outcome ? "disabled" : ""}>${pictogram(autoResolve ? "pause" : "right")}</button>`
|
||||||
: view.stage === "cancelled"
|
: view.stage === "cancelled"
|
||||||
? '<button id="open-setup">' + t("app.new_session") + "</button>"
|
? '<button id="open-setup">' + t("app.new_session") + "</button>"
|
||||||
: "";
|
: "";
|
||||||
|
|
@ -728,7 +746,7 @@ export function mountConsole(root, host = null) {
|
||||||
.join("")
|
.join("")
|
||||||
: "";
|
: "";
|
||||||
$("#replay").innerHTML = resolution
|
$("#replay").innerHTML = resolution
|
||||||
? `<p>${resolution.outcome ? `${resolution.outcome.survived ? "✓" : "✕"} ${t("app.score")} : <b>${resolution.outcome.score}</b> · ${resolution.outcome.threatPoints} ${t("app.threats_87b951")} + ${resolution.outcome.visual} ${t("app.visual")} − ${resolution.outcome.penalties} ${t("app.penalties")}` : resolution.turn > resolution.lastTurn ? t("app.final_threat_movement") : `${t("app.turn")} ${resolution.turn} · ${esc({ appear: t("app.appearances"), crew: t("app.crew_actions"), damage: t("app.damage"), threats: t("app.threat_actions"), computer: t("app.computer") }[resolution.step])}`}</p><label>${t("app.review_a_step")} <input id="replay-slider" type="range" min="0" max="${resolution.frames.length - 1}" value="${replayFrame ?? resolution.frames.length - 1}"></label>${replayFrame !== null ? '<button id="live" class="quiet">' + t("app.back_to_live") + "</button>" : ""}`
|
? `<p>${resolution.outcome ? `${resolution.outcome.survived ? "✓" : "✕"} ${t("app.score")} : <b>${resolution.outcome.score}</b> · ${resolution.outcome.threatPoints} ${t("app.threats_87b951")} + ${resolution.outcome.visual} ${t("app.visual")} − ${resolution.outcome.penalties} ${t("app.penalties")}` : resolution.turn > resolution.lastTurn ? t("app.final_threat_movement") : `${t("app.turn")} ${resolution.turn} · ${esc({ appear: t("app.appearances"), crew: t("app.crew_actions"), damage: t("app.damage"), threats: t("app.threat_actions"), computer: t("app.computer") }[resolution.step])}`}</p><label>${t("app.review_a_step")} <input id="replay-slider" type="range" min="0" max="${resolution.frames.length - 1}" value="${replayFrame ?? resolution.frames.length - 1}"></label><button id="replay-play" class="quiet" ${resolution.frames.length < 2 ? "disabled" : ""}>${t(replay.playing ? "app.pause_replay" : "app.play_replay")}</button>${replayFrame !== null ? '<button id="live" class="quiet">' + t("app.back_to_live") + "</button>" : ""}`
|
||||||
: "";
|
: "";
|
||||||
renderCampaign(g?.campaign);
|
renderCampaign(g?.campaign);
|
||||||
$("#announcements").innerHTML = resolution
|
$("#announcements").innerHTML = resolution
|
||||||
|
|
@ -1028,6 +1046,7 @@ export function mountConsole(root, host = null) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
async function command(type, extra = {}, target = seat) {
|
async function command(type, extra = {}, target = seat) {
|
||||||
|
if (replayFrame !== null) return; // Reviewing never sends engine commands.
|
||||||
if (host) {
|
if (host) {
|
||||||
if (target !== seat || seat < 0)
|
if (target !== seat || seat < 0)
|
||||||
throw Error("Only your own seat can send commands");
|
throw Error("Only your own seat can send commands");
|
||||||
|
|
@ -1300,6 +1319,8 @@ export function mountConsole(root, host = null) {
|
||||||
seat = 0;
|
seat = 0;
|
||||||
crew = 0;
|
crew = 0;
|
||||||
selected = [];
|
selected = [];
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
replayFrame = null;
|
replayFrame = null;
|
||||||
basicsStarted = false;
|
basicsStarted = false;
|
||||||
basicsPicked = false;
|
basicsPicked = false;
|
||||||
|
|
@ -1353,6 +1374,8 @@ export function mountConsole(root, host = null) {
|
||||||
}
|
}
|
||||||
if (el.id === "campaign-next") {
|
if (el.id === "campaign-next") {
|
||||||
perform(async () => {
|
perform(async () => {
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
replayFrame = null;
|
replayFrame = null;
|
||||||
selected = [];
|
selected = [];
|
||||||
await localPost("/api/campaign-next", {
|
await localPost("/api/campaign-next", {
|
||||||
|
|
@ -1460,6 +1483,7 @@ export function mountConsole(root, host = null) {
|
||||||
else { cue('select'); rerender(); }
|
else { cue('select'); rerender(); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (el.dataset.command && replayFrame !== null) return;
|
||||||
if (el.dataset.command === "resolve-all") {
|
if (el.dataset.command === "resolve-all") {
|
||||||
autoResolve = !autoResolve;
|
autoResolve = !autoResolve;
|
||||||
rerender();
|
rerender();
|
||||||
|
|
@ -1521,7 +1545,18 @@ export function mountConsole(root, host = null) {
|
||||||
}).then((r) => r.json());
|
}).then((r) => r.json());
|
||||||
render(result);
|
render(result);
|
||||||
});
|
});
|
||||||
|
if (el.id === "replay-play") {
|
||||||
|
autoResolve = false;
|
||||||
|
if (replay.playing) replay.pause();
|
||||||
|
else {
|
||||||
|
effects.reset(); // Establish a silent starting frame, then animate adjacent frames.
|
||||||
|
replay.play();
|
||||||
|
}
|
||||||
|
rerender();
|
||||||
|
}
|
||||||
if (el.id === "live") {
|
if (el.id === "live") {
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
replayFrame = null;
|
replayFrame = null;
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
|
@ -1539,8 +1574,20 @@ export function mountConsole(root, host = null) {
|
||||||
selected = [];
|
selected = [];
|
||||||
rerender();
|
rerender();
|
||||||
});
|
});
|
||||||
|
// Stop immediately while dragging; commit the selected frame on change so
|
||||||
|
// rendering does not replace the range input underneath the pointer.
|
||||||
|
listenRoot("input", (e) => {
|
||||||
|
if (e.target.id === "replay-slider") {
|
||||||
|
replay.pause();
|
||||||
|
autoResolve = false;
|
||||||
|
effects.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
listenRoot("change", (e) => {
|
listenRoot("change", (e) => {
|
||||||
if (e.target.id === "replay-slider") {
|
if (e.target.id === "replay-slider") {
|
||||||
|
replay.pause();
|
||||||
|
autoResolve = false;
|
||||||
|
effects.reset();
|
||||||
replayFrame = Number(e.target.value);
|
replayFrame = Number(e.target.value);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
|
@ -1590,6 +1637,8 @@ export function mountConsole(root, host = null) {
|
||||||
});
|
});
|
||||||
const next = await res.json();
|
const next = await res.json();
|
||||||
if (!res.ok) throw Error(next.error);
|
if (!res.ok) throw Error(next.error);
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
replayFrame = null;
|
replayFrame = null;
|
||||||
selected = [];
|
selected = [];
|
||||||
crew = seat;
|
crew = seat;
|
||||||
|
|
@ -1665,7 +1714,7 @@ export function mountConsole(root, host = null) {
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isAnimating: () => effects.busy(),
|
isAnimating: () => effects.busy() || replayFrame !== null,
|
||||||
resetTutorial() {
|
resetTutorial() {
|
||||||
previewTurn = null;
|
previewTurn = null;
|
||||||
cursor.reset();
|
cursor.reset();
|
||||||
|
|
@ -1673,6 +1722,8 @@ export function mountConsole(root, host = null) {
|
||||||
basicsPicked = false;
|
basicsPicked = false;
|
||||||
basicsStarted = false;
|
basicsStarted = false;
|
||||||
selected = [];
|
selected = [];
|
||||||
|
replay.pause();
|
||||||
|
effects.reset();
|
||||||
replayFrame = null;
|
replayFrame = null;
|
||||||
key = "";
|
key = "";
|
||||||
},
|
},
|
||||||
|
|
@ -1708,6 +1759,7 @@ export function mountConsole(root, host = null) {
|
||||||
rerender();
|
rerender();
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
|
replay.pause();
|
||||||
effects.destroy();
|
effects.destroy();
|
||||||
audio?.destroy();
|
audio?.destroy();
|
||||||
root.ownerDocument.removeEventListener("pointerdown", unlockSound, true);
|
root.ownerDocument.removeEventListener("pointerdown", unlockSound, true);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export function basicsView(view, locale, { started, picked, shipMarkup }) {
|
||||||
const playing = view.stage === "resolution";
|
const playing = view.stage === "resolution";
|
||||||
if (view.tutorial.nativeStep !== undefined) {
|
if (view.tutorial.nativeStep !== undefined) {
|
||||||
const control = (id, glyph, description, disabled = false) =>
|
const control = (id, glyph, description, disabled = false) =>
|
||||||
`<button id="${id}" class="primary icon-button" ${id === "basics-run" ? 'aria-keyshortcuts="Enter"' : ""} title="${description}${id === "basics-run" ? " · ↵" : ""}" aria-label="${description}" ${disabled ? "disabled" : ""}>${pictogram(glyph)}${id === "lesson-deadline" ? "<small>5 s</small>" : ""}</button>`;
|
`<button id="${id}" class="primary ${id === 'basics-run' ? 'icon-label lesson-run' : 'icon-button'}" ${id === "basics-run" ? 'aria-keyshortcuts="Enter"' : ""} title="${description}${id === "basics-run" ? " · ↵" : ""}" aria-label="${description}" ${disabled ? "disabled" : ""}>${pictogram(glyph)}${id === 'basics-run' ? `<span>${description}</span>` : ''}${id === "lesson-deadline" ? "<small>5 s</small>" : ""}</button>`;
|
||||||
if (view.tutorial.nativeStep === 0) return "";
|
if (view.tutorial.nativeStep === 0) return "";
|
||||||
if (playing)
|
if (playing)
|
||||||
return view.tutorial.timing
|
return view.tutorial.timing
|
||||||
|
|
@ -70,7 +70,7 @@ export function basicsView(view, locale, { started, picked, shipMarkup }) {
|
||||||
? btn("basics-start", t("basics.try_with_two_cards"))
|
? btn("basics-start", t("basics.try_with_two_cards"))
|
||||||
: `<div class="basics-program-heading">${pictogram("cards")}<span>${t("basics.program")}</span>${pictogram("right")}</div><div class="basics-program program">${[1, 2, 3].map((n) => `<button title="${t("app.turn")} ${n} · ${actionLabel(direction(n))}" aria-label="${t("app.turn")} ${n} · ${actionLabel(direction(n))}" data-basics-turn="${n}" ${playing || (!picked && !slots[n - 1].cards.length) || n === 3 ? "disabled" : ""} class="slot ${playing && n === turn ? "current" : ""}"><span class="turn">${n}</span><strong class="action">${pictogram(direction(n) === "blue" ? "right" : direction(n) === "red" ? "left" : "wait")}</strong></button>`).join("")}</div>
|
: `<div class="basics-program-heading">${pictogram("cards")}<span>${t("basics.program")}</span>${pictogram("right")}</div><div class="basics-program program">${[1, 2, 3].map((n) => `<button title="${t("app.turn")} ${n} · ${actionLabel(direction(n))}" aria-label="${t("app.turn")} ${n} · ${actionLabel(direction(n))}" data-basics-turn="${n}" ${playing || (!picked && !slots[n - 1].cards.length) || n === 3 ? "disabled" : ""} class="slot ${playing && n === turn ? "current" : ""}"><span class="turn">${n}</span><strong class="action">${pictogram(direction(n) === "blue" ? "right" : direction(n) === "red" ? "left" : "wait")}</strong></button>`).join("")}</div>
|
||||||
${!playing ? `<div class="practice-readiness" role="status"><progress value="${placed}" max="2"></progress><span title="${t("basics.practice_actions_placed")}" aria-label="${placed}/2 ${t("basics.practice_actions_placed_2d48e9")}">${pictogram("cards")} ${placed}/2</span></div><div class="basics-card-area"><div class="basics-card-choices">${["red", "blue"].map((action) => `<button title="${actionLabel(action)}" aria-label="${actionLabel(action)}" data-basics-pick="${action}" aria-pressed="${picked === action}" class="basics-card ${picked === action ? "selected" : ""}"><strong>${pictogram(action === "blue" ? "right" : "left")}</strong></button>`).join("")}</div></div>` : ""}
|
${!playing ? `<div class="practice-readiness" role="status"><progress value="${placed}" max="2"></progress><span title="${t("basics.practice_actions_placed")}" aria-label="${placed}/2 ${t("basics.practice_actions_placed_2d48e9")}">${pictogram("cards")} ${placed}/2</span></div><div class="basics-card-area"><div class="basics-card-choices">${["red", "blue"].map((action) => `<button title="${actionLabel(action)}" aria-label="${actionLabel(action)}" data-basics-pick="${action}" aria-pressed="${picked === action}" class="basics-card ${picked === action ? "selected" : ""}"><strong>${pictogram(action === "blue" ? "right" : "left")}</strong></button>`).join("")}</div></div>` : ""}
|
||||||
${!playing && ready ? `<div class="practice-clock"><div><strong data-practice-time>${practiceClockText(view, locale)}</strong><small>${t("basics.to_plan_safe_practice")}</small></div><button id="lesson-clock" class="icon-button" title="${view.tutorial.clockRunning ? t("basics.pause_clock") : t("basics.start_clock")}" aria-label="${view.tutorial.clockRunning ? t("basics.pause_clock") : t("basics.start_clock")}">${pictogram(view.tutorial.clockRunning ? "pause" : "clock")}</button></div><button id="basics-run" class="primary icon-button" title="${t("basics.run_program")}" aria-label="${t("basics.run_program")}">${pictogram("check")}</button>` : ""}
|
${!playing && ready ? `<div class="practice-clock"><div><strong data-practice-time>${practiceClockText(view, locale)}</strong><small>${t("basics.to_plan_safe_practice")}</small></div><button id="lesson-clock" class="icon-button" title="${view.tutorial.clockRunning ? t("basics.pause_clock") : t("basics.start_clock")}" aria-label="${view.tutorial.clockRunning ? t("basics.pause_clock") : t("basics.start_clock")}">${pictogram(view.tutorial.clockRunning ? "pause" : "clock")}</button></div><button id="basics-run" class="primary icon-label lesson-run" title="${t("basics.run_program")}">${pictogram("check")}<span>${t("basics.run_program")}</span></button>` : ""}
|
||||||
${playing ? (turn < 3 ? `<button data-command="resolve" class="primary icon-button" title="${t("app.next_resolution_step")}" aria-label="${t("app.next_resolution_step")}">${pictogram("step")}</button>` : `<div class="basics-complete"><p>${t("basics.planning_against_a_clock_and_carrying_out_turns")}</p><button data-lesson="first-shot" class="primary">${t("basics.next_your_first_shot")}</button></div>`) : ""}`
|
${playing ? (turn < 3 ? `<button data-command="resolve" class="primary icon-button" title="${t("app.next_resolution_step")}" aria-label="${t("app.next_resolution_step")}">${pictogram("step")}</button>` : `<div class="basics-complete"><p>${t("basics.planning_against_a_clock_and_carrying_out_turns")}</p><button data-lesson="first-shot" class="primary">${t("basics.next_your_first_shot")}</button></div>`) : ""}`
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
"lesson.first-shot.lane": "Center lane",
|
"lesson.first-shot.lane": "Center lane",
|
||||||
"lesson.first-shot.shield": "The center shield absorbs hits automatically while charged.",
|
"lesson.first-shot.shield": "The center shield absorbs hits automatically while charged.",
|
||||||
"lesson.energy.title": "Energy and coordination",
|
"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.",
|
"lesson.energy.instruction.0": "The center laser needs one energy per shot. Its reactor starts with three: refill it to fire four times. One refill uses a fuel capsule to fill the central reactor to capacity—not just add one energy. It does not refill the other reactors or shields.",
|
||||||
"lesson.energy.instruction.1": "Android 1: fire on turns 1-4. Android 3: use the lift on turn 1, refill on turn 2. Then lock phase 1 to plan turn 4.",
|
"lesson.energy.instruction.1": "Android 1: fire on turns 1-4. Android 3: use the lift on turn 1, refill on turn 2. Then lock phase 1 to plan turn 4.",
|
||||||
"lesson.repairs.title": "Repairing a malfunction",
|
"lesson.repairs.title": "Repairing a malfunction",
|
||||||
"lesson.repairs.instruction.0": "Repair the highlighted malfunction.",
|
"lesson.repairs.instruction.0": "Repair the highlighted malfunction.",
|
||||||
"lesson.repairs.instruction.1": "→ on turn 1, then energy on turns 2-4.",
|
"lesson.repairs.instruction.1": "Move right on turn 1, then use B on turns 2, 3 and 4. While the malfunction is active, B repairs it instead of recharging the shield; it needs three repair actions.",
|
||||||
"lesson.battlebots.title": "Battlebots and interceptors",
|
"lesson.battlebots.title": "Battlebots and interceptors",
|
||||||
"lesson.battlebots.instruction.0": "Collect the battlebots, then reach the interceptors.",
|
"lesson.battlebots.instruction.0": "Collect the battlebots, then reach the interceptors.",
|
||||||
"lesson.battlebots.instruction.1": "→ · systems · ← · ← · systems. In flight, play battlebots to fire; leave a slot empty to return.",
|
"lesson.battlebots.instruction.1": "→ · systems · ← · ← · systems. In flight, play battlebots to fire; leave a slot empty to return.",
|
||||||
|
|
@ -177,7 +177,9 @@
|
||||||
"app.damage": "Damage",
|
"app.damage": "Damage",
|
||||||
"app.threat_actions": "Threat actions",
|
"app.threat_actions": "Threat actions",
|
||||||
"app.review_a_step": "Review a step",
|
"app.review_a_step": "Review a step",
|
||||||
"app.back_to_live": "Back to live",
|
"app.back_to_live": "Jump to latest state",
|
||||||
|
"app.play_replay": "Play replay",
|
||||||
|
"app.pause_replay": "Pause replay",
|
||||||
"app.laser": "Laser",
|
"app.laser": "Laser",
|
||||||
"app.pulse": "Pulse",
|
"app.pulse": "Pulse",
|
||||||
"app.shield": "Shield",
|
"app.shield": "Shield",
|
||||||
|
|
@ -606,5 +608,6 @@
|
||||||
"program.selected_turn": "Turn {turn}",
|
"program.selected_turn": "Turn {turn}",
|
||||||
"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."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
"lesson.first-shot.lane": "Zone centrale",
|
"lesson.first-shot.lane": "Zone centrale",
|
||||||
"lesson.first-shot.shield": "Le bouclier central absorbe les tirs automatiquement tant qu’il est chargé.",
|
"lesson.first-shot.shield": "Le bouclier central absorbe les tirs automatiquement tant qu’il est chargé.",
|
||||||
"lesson.energy.title": "Énergie et coordination",
|
"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.",
|
"lesson.energy.instruction.0": "Le laser central consomme une énergie par tir. Son réacteur en contient trois : ravitaillez-le pour tirer quatre fois. Un ravitaillement consomme une capsule et remplit le réacteur central jusqu’à sa capacité, au lieu d’ajouter une seule énergie. Il ne remplit pas les autres réacteurs ni les boucliers.",
|
||||||
"lesson.energy.instruction.1": "Androïde 1 : tirer aux tours 1-4. Androïde 3 : ascenseur au tour 1, énergie au tour 2. Verrouillez ensuite la phase 1 pour préparer le tour 4.",
|
"lesson.energy.instruction.1": "Androïde 1 : tirer aux tours 1-4. Androïde 3 : ascenseur au tour 1, énergie au tour 2. Verrouillez ensuite la phase 1 pour préparer le tour 4.",
|
||||||
"lesson.repairs.title": "Réparer une panne",
|
"lesson.repairs.title": "Réparer une panne",
|
||||||
"lesson.repairs.instruction.0": "Réparez la panne surlignée.",
|
"lesson.repairs.instruction.0": "Réparez la panne surlignée.",
|
||||||
"lesson.repairs.instruction.1": "→ au tour 1, puis énergie aux tours 2-4.",
|
"lesson.repairs.instruction.1": "Allez à droite au tour 1, puis utilisez B aux tours 2, 3 et 4. Tant que la panne est active, B la répare au lieu de recharger le bouclier ; trois actions de réparation sont nécessaires.",
|
||||||
"lesson.battlebots.title": "Robots et intercepteurs",
|
"lesson.battlebots.title": "Robots et intercepteurs",
|
||||||
"lesson.battlebots.instruction.0": "Prenez les robots, puis rejoignez les intercepteurs.",
|
"lesson.battlebots.instruction.0": "Prenez les robots, puis rejoignez les intercepteurs.",
|
||||||
"lesson.battlebots.instruction.1": "→ · systèmes · ← · ← · systèmes. En vol, jouez robots pour tirer ; laissez vide pour rentrer.",
|
"lesson.battlebots.instruction.1": "→ · systèmes · ← · ← · systèmes. En vol, jouez robots pour tirer ; laissez vide pour rentrer.",
|
||||||
|
|
@ -177,7 +177,9 @@
|
||||||
"app.damage": "Dégâts",
|
"app.damage": "Dégâts",
|
||||||
"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": "Revenir au direct",
|
"app.back_to_live": "Aller au dernier état",
|
||||||
|
"app.play_replay": "Lire la reprise",
|
||||||
|
"app.pause_replay": "Mettre la reprise en pause",
|
||||||
"app.laser": "Laser",
|
"app.laser": "Laser",
|
||||||
"app.pulse": "Impulsion",
|
"app.pulse": "Impulsion",
|
||||||
"app.shield": "Bouclier",
|
"app.shield": "Bouclier",
|
||||||
|
|
@ -606,5 +608,6 @@
|
||||||
"program.selected_turn": "Tour {turn}",
|
"program.selected_turn": "Tour {turn}",
|
||||||
"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."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
preview/replay.js
Normal file
27
preview/replay.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Viewer transport only. The caller supplies already-visible frame counts;
|
||||||
|
// this controller has no engine, clock or network access.
|
||||||
|
export function createReplay({ index, count, show, busy, now = () => performance.now() }) {
|
||||||
|
let playing = false, end = -1, due = 0;
|
||||||
|
return {
|
||||||
|
get playing() { return playing; },
|
||||||
|
pause() { playing = false; },
|
||||||
|
play() {
|
||||||
|
end = count() - 1; // Freeze the horizon: incoming live frames are not replayed.
|
||||||
|
if (end < 1) return;
|
||||||
|
playing = true;
|
||||||
|
const start = index();
|
||||||
|
show(start === null || start >= end ? 0 : start);
|
||||||
|
due = now() + 450;
|
||||||
|
},
|
||||||
|
tick() {
|
||||||
|
if (!playing || busy() || now() < due) return;
|
||||||
|
const current = index();
|
||||||
|
if (current === null || count() <= end || current >= end) {
|
||||||
|
playing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
show(current + 1);
|
||||||
|
due = now() + 450;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -142,6 +142,9 @@ export function createResolutionEffects(root, cue) {
|
||||||
function delta(p, value, color, icon = "") {
|
function delta(p, value, color, icon = "") {
|
||||||
if (!p || !value) return;
|
if (!p || !value) return;
|
||||||
const n = node("fx-delta", p, color);
|
const n = node("fx-delta", p, color);
|
||||||
|
// Cancelling the finished animation restores the underlying style before
|
||||||
|
// the removal timer runs. Keep that style hidden to avoid a one-frame flash.
|
||||||
|
n.style.opacity = "0";
|
||||||
n.textContent = `${icon}−${value}`;
|
n.textContent = `${icon}−${value}`;
|
||||||
animate(n, [{ transform: "translate(-50%,-20%)", opacity: 1 },
|
animate(n, [{ transform: "translate(-50%,-20%)", opacity: 1 },
|
||||||
{ transform: `translate(-50%,${reduced.matches ? "-20%" : "-140%"})`, opacity: 0 }], 750);
|
{ transform: `translate(-50%,${reduced.matches ? "-20%" : "-140%"})`, opacity: 0 }], 750);
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,7 @@ export function createPreviewServer({ clock = Date.now, storagePath } = {}) {
|
||||||
"/program-route.js": "program-route.js",
|
"/program-route.js": "program-route.js",
|
||||||
"/program-cursor.js": "program-cursor.js",
|
"/program-cursor.js": "program-cursor.js",
|
||||||
"/resolution-effects.js": "resolution-effects.js",
|
"/resolution-effects.js": "resolution-effects.js",
|
||||||
|
"/replay.js": "replay.js",
|
||||||
"/sound.js": "sound.js",
|
"/sound.js": "sound.js",
|
||||||
"/i18n.js": "i18n.js",
|
"/i18n.js": "i18n.js",
|
||||||
"/locales/en.json": "locales/en.json",
|
"/locales/en.json": "locales/en.json",
|
||||||
|
|
|
||||||
|
|
@ -2448,10 +2448,9 @@ input:not([type="checkbox"]):not([type="range"]) {
|
||||||
.native-tutorial.learning-basics #ship .station-title { visibility: hidden; }
|
.native-tutorial.learning-basics #ship .station-title { visibility: hidden; }
|
||||||
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #controls { display: flex !important; gap: 10px; }
|
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #controls { display: flex !important; gap: 10px; }
|
||||||
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #replay { display: block !important; }
|
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #replay { display: block !important; }
|
||||||
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #replay label,
|
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #replay label { display: block; }
|
||||||
.native-tutorial.learning-basics[data-tutorial-stage="resolution"] #replay #live { display: none; }
|
|
||||||
.native-tutorial.learning-basics[data-tutorial-step="3"] #controls { display: none !important; }
|
.native-tutorial.learning-basics[data-tutorial-step="3"] #controls { display: none !important; }
|
||||||
.native-tutorial.learning-basics[data-tutorial-step="3"] #replay { display: none !important; }
|
.native-tutorial.learning-basics[data-tutorial-step="3"] #replay:not(:empty) { display: block !important; }
|
||||||
|
|
||||||
.training-ship .deck-upper .station,
|
.training-ship .deck-upper .station,
|
||||||
.training-ship .deck-lower .station { min-height: 104px; }
|
.training-ship .deck-lower .station { min-height: 104px; }
|
||||||
|
|
@ -2480,7 +2479,7 @@ input:not([type="checkbox"]):not([type="range"]) {
|
||||||
margin: 12px 0 0;
|
margin: 12px 0 0;
|
||||||
}
|
}
|
||||||
.native-tutorial.learning-basics #program { width: fit-content; max-width: 100%; }
|
.native-tutorial.learning-basics #program { width: fit-content; max-width: 100%; }
|
||||||
.native-tutorial .practice-readiness #basics-run { margin-left: 12px; }
|
.native-tutorial .practice-readiness #basics-run { margin-left: 0; }
|
||||||
.native-tutorial .practice-clock { margin: 12px 0; padding: 12px; gap: 12px; }
|
.native-tutorial .practice-clock { margin: 12px 0; padding: 12px; gap: 12px; }
|
||||||
.native-tutorial .practice-clock strong { font-size: 1rem; }
|
.native-tutorial .practice-clock strong { font-size: 1rem; }
|
||||||
|
|
||||||
|
|
@ -2537,6 +2536,20 @@ input:not([type="checkbox"]):not([type="range"]) {
|
||||||
|
|
||||||
.native-tutorial #lesson-guide { display: none !important; }
|
.native-tutorial #lesson-guide { display: none !important; }
|
||||||
.native-tutorial .lesson-focus { outline: 2px dashed #e8c984; outline-offset: 3px; }
|
.native-tutorial .lesson-focus { outline: 2px dashed #e8c984; outline-offset: 3px; }
|
||||||
|
/* Keep the repair target readable throughout; only its small outer halo breathes.
|
||||||
|
Static emphasis is the default, including when reduced motion is requested. */
|
||||||
|
.native-tutorial[data-chapter="repairs"] .lesson-focus {
|
||||||
|
box-shadow: 0 0 0 4px #e8c98420, 0 0 10px 2px #e8c98428;
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.native-tutorial[data-chapter="repairs"] .lesson-focus {
|
||||||
|
animation: tutorial-repair-attention 2.8s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes tutorial-repair-attention {
|
||||||
|
0%, 100% { box-shadow: 0 0 0 4px #e8c98420, 0 0 10px 2px #e8c98428; }
|
||||||
|
50% { box-shadow: 0 0 0 5px #e8c98438, 0 0 16px 3px #e8c98448; }
|
||||||
|
}
|
||||||
.native-tutorial .flight-layout { grid-template-columns: minmax(0, 600px) minmax(280px, 480px); gap: 28px; justify-content: start; }
|
.native-tutorial .flight-layout { grid-template-columns: minmax(0, 600px) minmax(280px, 480px); gap: 28px; justify-content: start; }
|
||||||
@media (max-width: 800px) { .native-tutorial .flight-layout { grid-template-columns: 1fr; } }
|
@media (max-width: 800px) { .native-tutorial .flight-layout { grid-template-columns: 1fr; } }
|
||||||
/* BGS already supplies the game name and chapter header. */
|
/* BGS already supplies the game name and chapter header. */
|
||||||
|
|
@ -2585,11 +2598,23 @@ input:not([type="checkbox"]):not([type="range"]) {
|
||||||
}
|
}
|
||||||
.native-tutorial[data-chapter="first-shot"] #latest { display: none; }
|
.native-tutorial[data-chapter="first-shot"] #latest { display: none; }
|
||||||
|
|
||||||
.lesson-program-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
|
.lesson-program-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
|
||||||
|
.lesson-program-controls .lesson-phase-lock { min-height: 48px; font-weight: 700; }
|
||||||
|
.lesson-program-controls .lesson-phase-lock.ready {
|
||||||
|
background: var(--gold);
|
||||||
|
border-color: var(--gold);
|
||||||
|
color: #15242c;
|
||||||
|
box-shadow: 0 0 0 2px #e8c98433;
|
||||||
|
}
|
||||||
|
.lesson-phase-ready { color: var(--gold); font-size: 13px; }
|
||||||
|
.lesson-phase-lock, .lesson-run { max-width: 100%; min-width: 0; white-space: normal; }
|
||||||
|
.lesson-phase-lock span, .lesson-run span { min-width: 0; overflow-wrap: anywhere; }
|
||||||
|
.lesson-run kbd { flex-shrink: 0; }
|
||||||
|
.native-tutorial .practice-readiness, .phase-lesson-controls { flex-wrap: wrap; }
|
||||||
.lesson-program-controls:empty { display: none; }
|
.lesson-program-controls:empty { display: none; }
|
||||||
.lesson-program-controls [data-guide="run"] { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; }
|
.lesson-program-controls [data-guide="run"] { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; }
|
||||||
.lesson-program-controls kbd { font: inherit; font-size: 12px; color: var(--muted); }
|
.lesson-program-controls kbd { font: inherit; font-size: 12px; color: var(--muted); }
|
||||||
.native-tutorial[data-chapter="first-shot"] #replay { display: none !important; }
|
.native-tutorial[data-chapter="first-shot"] #replay:not(:empty) { display: block !important; }
|
||||||
|
|
||||||
.compact-console-header { flex-wrap: wrap; }
|
.compact-console-header { flex-wrap: wrap; }
|
||||||
.compact-console-header .console-nav { margin: 0 0 0 auto; padding: 0; border: 0; flex-wrap: nowrap; }
|
.compact-console-header .console-nav { margin: 0 0 0 auto; padding: 0; border: 0; flex-wrap: nowrap; }
|
||||||
|
|
|
||||||
37
preview/tutorial-program.js
Normal file
37
preview/tutorial-program.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { translate } from './i18n.js';
|
||||||
|
import { pictogram } from './icons.js';
|
||||||
|
|
||||||
|
// A teaching cue, not a rule or a prediction of successful resolution. Check
|
||||||
|
// only the actions requested in this phase, never every slot: empty turns wait.
|
||||||
|
export function tutorialPhaseReady(state) {
|
||||||
|
if (state.stage !== 'programming' || state.phase !== 1) return false;
|
||||||
|
const actions = (crew, turn) => (state.game.programs[crew]?.[turn - 1]?.cards ?? [])
|
||||||
|
.flatMap(card => state.game.cards[card.id]?.sides[card.side] ?? []);
|
||||||
|
const has = (crew, turn, action) => actions(crew, turn).includes(action);
|
||||||
|
switch (state.tutorial?.id) {
|
||||||
|
case 'energy':
|
||||||
|
return [1, 2, 3].every(turn => has(0, turn, 'A')) &&
|
||||||
|
has(2, 1, 'lift') && has(2, 2, 'B');
|
||||||
|
case 'repairs':
|
||||||
|
return has(0, 1, 'blue') && [2, 3].every(turn => has(0, turn, 'B'));
|
||||||
|
case 'battlebots':
|
||||||
|
return has(0, 1, 'blue') && has(0, 2, 'C') && has(0, 3, 'red');
|
||||||
|
case 'double-actions':
|
||||||
|
return [1, 2, 3].some(turn => {
|
||||||
|
const programmed = actions(0, turn);
|
||||||
|
return programmed.length === 2 && programmed.includes('blue') && programmed.includes('A');
|
||||||
|
});
|
||||||
|
case 'phasing':
|
||||||
|
return [1, 2, 3].every(turn => has(0, turn, 'A'));
|
||||||
|
case 'specializations':
|
||||||
|
return has(0, 1, 'special:rocketeer:basic');
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tutorialPhaseButton(state, locale, busy = false) {
|
||||||
|
const ready = tutorialPhaseReady(state);
|
||||||
|
const label = translate(locale, 'tutorial.lock_phase', { phase: state.phase });
|
||||||
|
return `<button data-guide="phase" class="icon-label lesson-phase-lock${ready ? ' ready' : ''}" ${busy ? 'disabled' : ''}>${pictogram('lock')}<span>${label}</span></button>${ready ? `<span class="lesson-phase-ready" role="status">${translate(locale, 'tutorial.phase_ready')}</span>` : ''}`;
|
||||||
|
}
|
||||||
112
test/replay.test.js
Normal file
112
test/replay.test.js
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
import test from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { createReplay } from "../preview/replay.js";
|
||||||
|
|
||||||
|
function transport(start = 0, length = 4) {
|
||||||
|
let index = start, count = length, time = 0, busy = false;
|
||||||
|
const shown = [];
|
||||||
|
const replay = createReplay({
|
||||||
|
index: () => index, count: () => count, now: () => time,
|
||||||
|
busy: () => busy, show: value => { index = value; shown.push(value); },
|
||||||
|
});
|
||||||
|
return { replay, shown,
|
||||||
|
step(ms = 450) { time += ms; replay.tick(); },
|
||||||
|
set busy(value) { busy = value; },
|
||||||
|
set count(value) { count = value; },
|
||||||
|
set index(value) { index = value; },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test("replay from the scrubbed position visits consecutive resolved frames and stays in review", () => {
|
||||||
|
const t = transport(1);
|
||||||
|
t.replay.play();
|
||||||
|
t.step(); t.step(); t.step();
|
||||||
|
assert.deepEqual(t.shown, [1, 2, 3]);
|
||||||
|
assert.equal(t.replay.playing, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("play from live or the final frame replays from the beginning, including completed missions", () => {
|
||||||
|
for (const start of [null, 3]) {
|
||||||
|
const t = transport(start);
|
||||||
|
t.replay.play();
|
||||||
|
t.step(); t.step(); t.step(); t.step();
|
||||||
|
assert.deepEqual(t.shown, [0, 1, 2, 3]);
|
||||||
|
assert.equal(t.replay.playing, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("effect busy timing and minimum dwell prevent skipped or interrupted animations", () => {
|
||||||
|
const t = transport();
|
||||||
|
t.replay.play();
|
||||||
|
t.step(449);
|
||||||
|
assert.deepEqual(t.shown, [0]);
|
||||||
|
t.busy = true;
|
||||||
|
t.step(3000);
|
||||||
|
assert.deepEqual(t.shown, [0]);
|
||||||
|
t.busy = false;
|
||||||
|
t.step(1);
|
||||||
|
assert.deepEqual(t.shown, [0, 1]);
|
||||||
|
t.step(449);
|
||||||
|
assert.deepEqual(t.shown, [0, 1]);
|
||||||
|
t.step(1);
|
||||||
|
assert.deepEqual(t.shown, [0, 1, 2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("pause (also used for scrub, reset and destroy) prevents any further frame updates", () => {
|
||||||
|
const t = transport();
|
||||||
|
t.replay.play(); t.step();
|
||||||
|
t.replay.pause(); t.step(10000);
|
||||||
|
assert.deepEqual(t.shown, [0, 1]);
|
||||||
|
t.index = 2;
|
||||||
|
t.replay.play(); t.step();
|
||||||
|
assert.deepEqual(t.shown, [0, 1, 2, 3]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("incoming live frames cannot extend the captured replay horizon", () => {
|
||||||
|
const t = transport(0, 3);
|
||||||
|
t.replay.play();
|
||||||
|
t.count = 20;
|
||||||
|
for (let i = 0; i < 25; i++) t.step();
|
||||||
|
assert.deepEqual(t.shown, [0, 1, 2]);
|
||||||
|
assert.equal(t.replay.playing, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("missing/reset frames and single-frame resolutions stop safely", () => {
|
||||||
|
const t = transport();
|
||||||
|
t.replay.play();
|
||||||
|
t.count = 1;
|
||||||
|
t.step();
|
||||||
|
assert.equal(t.replay.playing, false);
|
||||||
|
assert.deepEqual(t.shown, [0]);
|
||||||
|
const empty = transport(null, 0), initial = transport(null, 1);
|
||||||
|
for (const fixture of [empty, initial]) {
|
||||||
|
fixture.replay.play(); fixture.step();
|
||||||
|
assert.equal(fixture.replay.playing, false);
|
||||||
|
assert.deepEqual(fixture.shown, []);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("replaying resolved snapshots reproduces movement effects without mutating resolution", async () => {
|
||||||
|
const { beginResolution, stepResolution } = await import("../src/game/resolution.js");
|
||||||
|
const { resolutionEffects } = await import("../preview/resolution-effects.js");
|
||||||
|
const { TRACKS } = await import("../src/game/catalog.js");
|
||||||
|
let resolution = beginResolution({ crewSize: 1, seed: "replay", turns: 3,
|
||||||
|
programs: [[{ actions: ["blue"] }, null, null]], threats: [],
|
||||||
|
tracks: Object.fromEntries(["red", "white", "blue", "internal"].map(z => [z, TRACKS[6]])) });
|
||||||
|
while (!resolution.outcome) resolution = stepResolution(resolution);
|
||||||
|
const original = JSON.stringify(resolution);
|
||||||
|
let index = 0, time = 0;
|
||||||
|
const events = [];
|
||||||
|
const replay = createReplay({ index: () => index,
|
||||||
|
count: () => resolution.frames.length, busy: () => false, now: () => time,
|
||||||
|
show(next) {
|
||||||
|
events.push(...resolutionEffects(resolution, resolution.frames[index], resolution.frames[next]));
|
||||||
|
index = next;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
replay.play();
|
||||||
|
while (replay.playing) { time += 450; replay.tick(); }
|
||||||
|
assert.ok(events.some(e => e.kind === "move" && e.from === "white-upper" && e.to === "blue-upper"));
|
||||||
|
assert.equal(index, resolution.frames.length - 1);
|
||||||
|
assert.equal(JSON.stringify(resolution), original);
|
||||||
|
});
|
||||||
84
test/tutorial-program.test.js
Normal file
84
test/tutorial-program.test.js
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { tutorialPhaseReady, tutorialPhaseButton } from '../preview/tutorial-program.js';
|
||||||
|
import { loadLocale } from '../preview/i18n.js';
|
||||||
|
import { basicsView } from '../preview/basics.js';
|
||||||
|
|
||||||
|
function fixture(id) {
|
||||||
|
return { stage: 'programming', phase: 1, tutorial: { id }, game: {
|
||||||
|
programs: Array.from({ length: 4 }, () => Array.from({ length: 7 }, () => ({ cards: [] }))), cards: {},
|
||||||
|
} };
|
||||||
|
}
|
||||||
|
function place(state, crew, turn, ...actions) {
|
||||||
|
const id = `${crew}/${turn}`;
|
||||||
|
state.game.cards[id] = { sides: [actions] };
|
||||||
|
state.game.programs[crew][turn - 1].cards = [{ id, side: 0 }];
|
||||||
|
}
|
||||||
|
|
||||||
|
test('energy readiness includes both crew objectives but not empty wait turns or next phase', () => {
|
||||||
|
const s = fixture('energy');
|
||||||
|
for (const turn of [1, 2, 3]) place(s, 0, turn, 'A');
|
||||||
|
assert.equal(tutorialPhaseReady(s), false);
|
||||||
|
place(s, 2, 1, 'lift');
|
||||||
|
place(s, 2, 2, 'A');
|
||||||
|
assert.equal(tutorialPhaseReady(s), false, 'wrong refill action');
|
||||||
|
place(s, 2, 2, 'B');
|
||||||
|
assert.equal(tutorialPhaseReady(s), true, 'crew 3 turn 3 and turn 4 intentionally empty');
|
||||||
|
s.game.programs[2][0].cards = [];
|
||||||
|
assert.equal(tutorialPhaseReady(s), false, 'clearing a required action removes cue');
|
||||||
|
place(s, 2, 1, 'lift');
|
||||||
|
s.phase = 2;
|
||||||
|
assert.equal(tutorialPhaseReady(s), false);
|
||||||
|
s.phase = 1;
|
||||||
|
s.stage = 'resolution';
|
||||||
|
assert.equal(tutorialPhaseReady(s), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('phase cues follow the requested actions for each exercise', () => {
|
||||||
|
for (const [id, turns] of [
|
||||||
|
['repairs', [['blue'], ['B'], ['B']]],
|
||||||
|
['battlebots', [['blue'], ['C'], ['red']]],
|
||||||
|
['double-actions', [['blue', 'A']]],
|
||||||
|
['phasing', [['A'], ['A'], ['A']]],
|
||||||
|
['specializations', [['special:rocketeer:basic']]],
|
||||||
|
]) {
|
||||||
|
const s = fixture(id);
|
||||||
|
assert.equal(tutorialPhaseReady(s), false, id);
|
||||||
|
turns.forEach((actions, i) => place(s, 0, i + 1, ...actions));
|
||||||
|
assert.equal(tutorialPhaseReady(s), true, id);
|
||||||
|
}
|
||||||
|
assert.equal(tutorialPhaseReady(fixture('unknown')), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('lock labels are visible in EN/FR; readiness is advisory and busy still disables', async () => {
|
||||||
|
for (const [locale, label] of [['en', 'Lock phase 1'], ['fr', 'Verrouiller la phase 1']]) {
|
||||||
|
await loadLocale(locale);
|
||||||
|
const s = fixture('specializations');
|
||||||
|
const initial = tutorialPhaseButton(s, locale);
|
||||||
|
assert.ok(initial.includes(`<span>${label}</span>`));
|
||||||
|
assert.ok(!initial.includes('disabled'));
|
||||||
|
assert.ok(!initial.includes('role="status"'));
|
||||||
|
place(s, 0, 1, 'special:rocketeer:basic');
|
||||||
|
const ready = tutorialPhaseButton(s, locale, true);
|
||||||
|
assert.match(ready, /lesson-phase-lock ready/);
|
||||||
|
assert.match(ready, /role="status"/);
|
||||||
|
assert.match(ready, /disabled/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('native first lesson retains a visible localized execution label and enablement', async () => {
|
||||||
|
for (const [locale, label] of [['en', 'Run program'], ['fr', 'Exécuter le programme']]) {
|
||||||
|
await loadLocale(locale);
|
||||||
|
const s = fixture('basics');
|
||||||
|
s.mission = { phaseEndsMs: [600000] };
|
||||||
|
s.missionStartAt = 0;
|
||||||
|
s.observedAt = 0;
|
||||||
|
s.tutorial.nativeStep = 1;
|
||||||
|
const html = basicsView(s, locale, {});
|
||||||
|
assert.ok(html.includes(`<span>${label}</span>`));
|
||||||
|
assert.match(html, /id="basics-run"[^>]*disabled/);
|
||||||
|
place(s, 0, 1, 'blue');
|
||||||
|
place(s, 0, 2, 'lift');
|
||||||
|
assert.doesNotMatch(basicsView(s, locale, {}), /id="basics-run"[^>]*disabled/);
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue