Guide tutorial progression and let players choose program turns
This commit is contained in:
parent
4aafa6c205
commit
e64585243d
16 changed files with 319 additions and 101 deletions
|
|
@ -15,7 +15,7 @@ npm run dev
|
|||
|
||||
Open <http://127.0.0.1:5250>. Start with **Flight school / École de vol**: nine exercises use the real engine. Start with **Planning turns**: one crew member, a highlighted destination, two movement actions, and an empty turn. Choose left, right or a deck change to reach the destination; start the planning clock, finish early, and watch all three turns execute. A second attempt runs out of time with empty turns. The next chapter reveals a threat, locks the first group at its deadline, then executes the complete seven-turn training mission. A missed destination can be retried. The later exercises have editable programs and a teammate already maintaining the computer; they cover firing, energy, malfunctions, battlebots/interceptors, double actions, phasing and specializations.
|
||||
|
||||
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 next empty editable turn. Click a filled turn to clear it; Backspace undoes your last placement for the selected crew member. 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.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@
|
|||
},
|
||||
{
|
||||
"id": "energy",
|
||||
"version": 2,
|
||||
"version": 3,
|
||||
"title": "Energy and coordination",
|
||||
"description": ""
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export async function mountLesson(
|
|||
["threats", "computer", "appear"].includes(s.state.game.resolution.step);
|
||||
const canPlay = (s) =>
|
||||
!shotExerciseEnded(s) &&
|
||||
!(chapter === 'energy' && completedTurns(s.state) >= 4) &&
|
||||
s.state.stage === "resolution" &&
|
||||
!s.completed &&
|
||||
!s.state.game.resolution?.outcome &&
|
||||
|
|
@ -209,7 +210,7 @@ export async function mountLesson(
|
|||
s.step === 2 &&
|
||||
completedTurns(s.state) >= 3 &&
|
||||
!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", "step", t("app.phase_2"), s.busy) : ""}${!LESSONS[index].basics && s.step === 1 ? `<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 ? 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>` : ""}`;
|
||||
if (phaseLesson && s.state.stage === "programming" && s.step > 0) {
|
||||
const ready =
|
||||
s.state.game.programs[0][(s.state.phase === 1 ? 1 : 4) - 1]?.cards
|
||||
|
|
@ -222,7 +223,7 @@ 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-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>`;
|
||||
}
|
||||
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() : ""}${chapter === "basics" || chapter === "first-shot" ? `<small class="lesson-scope">${t("timing.exercise", { turns: 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>
|
||||
<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>` : ""}
|
||||
<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>
|
||||
${s.error ? `<p role="alert">${escape(s.error)}</p>` : ""}`;
|
||||
}
|
||||
|
|
@ -275,20 +276,6 @@ export async function mountLesson(
|
|||
);
|
||||
target.dataset.tutorialStage = s.state.stage;
|
||||
ui.render(view);
|
||||
const focus =
|
||||
{
|
||||
"first-shot": ["white-upper-A"],
|
||||
energy: ["white-lower-B", "white-upper-A"],
|
||||
repairs: ["blue-upper-B"],
|
||||
battlebots: ["blue-upper-C", "red-upper-C"],
|
||||
"double-actions": ["white-upper-A", "blue-upper-A"],
|
||||
phasing: ["white-upper-A"],
|
||||
specializations: ["blue-lower-C"],
|
||||
}[chapter] ?? [];
|
||||
for (const system of focus)
|
||||
target
|
||||
.querySelector(`[data-inspect="system-${system}"]`)
|
||||
?.classList.add("lesson-focus");
|
||||
renderGuide(s);
|
||||
});
|
||||
const onClick = async (event) => {
|
||||
|
|
|
|||
145
preview/app.js
145
preview/app.js
|
|
@ -1,6 +1,7 @@
|
|||
import { createResolutionEffects } from "./resolution-effects.js";
|
||||
import { createSoundDesign } from "./sound.js";
|
||||
import { plannedRoute } from "./program-route.js";
|
||||
import { createProgramCursor } from "./program-cursor.js";
|
||||
import { translate, createLocaleSelection, lessonCopy } from "./i18n.js";
|
||||
import { basicsView } from "./basics.js";
|
||||
import { duration, practiceClockText } from "./clock.js";
|
||||
|
|
@ -49,7 +50,6 @@ export function mountConsole(root, host = null) {
|
|||
received = 0,
|
||||
key = "",
|
||||
selected = [],
|
||||
placements = [],
|
||||
handFilter = "all",
|
||||
lessons = [],
|
||||
careerKey = "",
|
||||
|
|
@ -62,6 +62,7 @@ export function mountConsole(root, host = null) {
|
|||
basicsMarkup;
|
||||
let route = [],
|
||||
previewTurn = null;
|
||||
const cursor = createProgramCursor();
|
||||
const audio = host?.cue ? null : createSoundDesign();
|
||||
const cue = (kind, pan) => host?.cue ? host.cue(kind, pan) : audio.cue(kind, pan);
|
||||
const unlockSound = () => audio?.enable(sound);
|
||||
|
|
@ -327,6 +328,7 @@ export function mountConsole(root, host = null) {
|
|||
const phaseLesson = !!view.tutorial?.phaseLesson;
|
||||
const simpleShip = basic || phaseLesson;
|
||||
const firstShot = host?.tutorial && view.tutorial?.id === "first-shot";
|
||||
const energyLesson = host?.tutorial && view.tutorial?.id === "energy";
|
||||
const teachingActions = simpleShip
|
||||
? ["red", "blue", "lift"]
|
||||
: firstShot
|
||||
|
|
@ -483,6 +485,27 @@ export function mountConsole(root, host = null) {
|
|||
)
|
||||
.join("") ||
|
||||
`<p class="empty">${t("app.awaiting_the_first_detections")}</p>`;
|
||||
if (host?.tutorial) {
|
||||
const focus = {
|
||||
"first-shot": ["white-upper-A"],
|
||||
energy: ["white-lower-B", "white-upper-A"],
|
||||
repairs: ["blue-upper-B"],
|
||||
battlebots: ["blue-upper-C", "red-upper-C"],
|
||||
"double-actions": ["white-upper-A", "blue-upper-A"],
|
||||
phasing: ["white-upper-A"],
|
||||
specializations: ["blue-lower-C"],
|
||||
}[view.tutorial?.id] ?? [];
|
||||
for (const system of focus)
|
||||
$(`[data-inspect="system-${system}"]`)?.classList.add("lesson-focus");
|
||||
}
|
||||
if (firstShot) {
|
||||
for (const station of ["white-upper", "white-lower"])
|
||||
$(`[data-station="${station}"]`)?.classList.add("lesson-lane");
|
||||
$('[data-inspect="system-white-upper-B"]')?.classList.add("lesson-shield-focus");
|
||||
$("#threats .threat-target")?.insertAdjacentHTML(
|
||||
"beforeend", `<span class="lesson-lane-label">${t("lesson.first-shot.lane")}</span>`,
|
||||
);
|
||||
}
|
||||
const announcements = view.log.filter((x) => x.type === "announcement");
|
||||
$("#latest").textContent =
|
||||
view.stage === "resolution"
|
||||
|
|
@ -495,6 +518,7 @@ export function mountConsole(root, host = null) {
|
|||
$("#program-crew").innerHTML = Array.from(
|
||||
{ length: view.crewSize },
|
||||
(_, i) =>
|
||||
host?.tutorial && view.tutorial?.id === 'energy' && ![0, 2].includes(i) ? '' :
|
||||
`<option value="${i}" data-kind="${g?.solo || i >= view.players.length ? "android" : "crew"}" data-short-label="${g?.solo || i >= view.players.length ? i + 1 : playerName(i)}" data-specialization="${g?.specializations[i]?.name ?? ""}" ${crew === i ? "selected" : ""}>${g?.solo || i >= view.players.length ? `${t("app.android")} ${i + 1}` : playerName(i)}${g?.specializations[i] ? " · " + esc(specialName(g.specializations[i].name)) : ""}</option>`,
|
||||
).join("");
|
||||
const planning = view.stage === "programming",
|
||||
|
|
@ -508,7 +532,7 @@ export function mountConsole(root, host = null) {
|
|||
$("#program").innerHTML = (g?.programs[crew] ?? [])
|
||||
.slice(
|
||||
0,
|
||||
basic || firstShot ? 3 : view.mission.phaseEndsMs.length === 2 ? 7 : 12,
|
||||
basic || firstShot ? 3 : energyLesson ? 4 : view.mission.phaseEndsMs.length === 2 ? 7 : 12,
|
||||
)
|
||||
.map((slot) => {
|
||||
const editable =
|
||||
|
|
@ -522,6 +546,7 @@ export function mountConsole(root, host = null) {
|
|||
(!host?.tutorial || view.tutorial.nativeStep === 1) &&
|
||||
planning &&
|
||||
canOwn &&
|
||||
(g.solo || crew < view.players.length || !slot.cards.length) &&
|
||||
!own.finishedPlanning &&
|
||||
phaseFor(slot.turn) === ownPhase;
|
||||
const destination = route[slot.turn - 1];
|
||||
|
|
@ -532,7 +557,19 @@ export function mountConsole(root, host = null) {
|
|||
return `<button class="slot ${slot.cards.length ? "filled" : "empty"} ${slot.turn === activeTurn ? "current" : ""} ${phaseFor(slot.turn) < ownPhase ? "locked" : ""} ${phaseFor(slot.turn) > ownPhase ? "future" : ""}" data-turn="${slot.turn}" ${slot.turn === activeTurn ? 'aria-current="step"' : ""} ${editable ? "" : "disabled"} title="${esc(description + (routeDescription ? " · " + routeDescription : ""))}" aria-label="${esc(description + (routeDescription ? " · " + routeDescription : ""))}">${firstShot && slot.turn === 2 ? `<span class="slot-arrival" title="${t("app.target_arrives_before_this_shot")}">${pictogram("down")}${t("app.arrival")}</span>` : ""}<span class="turn">${slot.turn} ${phaseFor(slot.turn) < ownPhase ? pictogram("lock") : ""}</span><span class="action">${slot.cards.map((c) => (c.sides ? c.sides[c.side].map(icon).join(" ") : pictogram(c.category === "movement" ? "move" : "cards"))).join(" + ") || pictogram("wait")}</span>${slot.cards.length && destination ? `<span class="planned-location" aria-hidden="true">${shipLocator([destination])}</span>` : ""}</button>`;
|
||||
})
|
||||
.join("");
|
||||
if (!basic && !firstShot) {
|
||||
const editable = [...root.querySelectorAll('#program [data-turn]:not(:disabled)')]
|
||||
.map(button => Number(button.dataset.turn));
|
||||
// Do not erase a saved phase cursor just because its controls are hidden
|
||||
// during an introduction or while reviewing resolution.
|
||||
const insertionTurn = editable.length
|
||||
? cursor.sync(`${crew}/${ownPhase}`, editable)
|
||||
: null;
|
||||
for (const button of root.querySelectorAll('#program [data-turn]:not(:disabled)')) {
|
||||
const active = Number(button.dataset.turn) === insertionTurn;
|
||||
button.classList.toggle('insertion', active);
|
||||
button.setAttribute('aria-pressed', String(active));
|
||||
}
|
||||
if (!basic && !firstShot && !energyLesson) {
|
||||
const lastTurn = resolution?.lastTurn ?? (view.mission.phaseEndsMs.length === 2 ? 7 : 12);
|
||||
const jumping = activeTurn > lastTurn;
|
||||
$("#program").insertAdjacentHTML("beforeend",
|
||||
|
|
@ -541,7 +578,7 @@ export function mountConsole(root, host = null) {
|
|||
showPlannedPosition(previewTurn);
|
||||
$("#program").setAttribute(
|
||||
"aria-keyshortcuts",
|
||||
"ArrowLeft ArrowRight ArrowUp ArrowDown Backspace",
|
||||
"ArrowLeft ArrowRight ArrowUp ArrowDown Backspace W",
|
||||
);
|
||||
$("#player-help").textContent = planning
|
||||
? selected.length
|
||||
|
|
@ -589,6 +626,8 @@ export function mountConsole(root, host = null) {
|
|||
];
|
||||
const grouped = [];
|
||||
for (const card of hand) {
|
||||
if (energyLesson && !card.sides.every(side =>
|
||||
side.length === 1 && ["A", "B", "lift"].includes(side[0]))) continue;
|
||||
if (
|
||||
teachingActions &&
|
||||
!card.sides.some(
|
||||
|
|
@ -620,14 +659,16 @@ export function mountConsole(root, host = null) {
|
|||
if (same) same.count++;
|
||||
else grouped.push({ ...card, count: 1 });
|
||||
}
|
||||
$("#selection-tools").innerHTML =
|
||||
planning &&
|
||||
if (energyLesson) grouped.sort((a, b) => JSON.stringify(a.sides).localeCompare(JSON.stringify(b.sides)));
|
||||
$("#selection-tools").innerHTML = (editable.length
|
||||
? `<div class="program-edit-tools"><button id="program-wait" class="quiet icon-label" aria-keyshortcuts="W" title="${t('program.wait')}" aria-label="${t('program.wait')}" ${insertionTurn === null ? 'disabled' : ''}>${pictogram('wait')}<kbd>W</kbd></button><button id="program-clear" class="quiet icon-label" aria-keyshortcuts="Backspace" title="${t('program.clear')}" aria-label="${t('program.clear')}" ${cursor.eraseTurn(g.programs[crew]) === null ? 'disabled' : ''}>${pictogram('erase')}<kbd>⌫</kbd></button><small>${insertionTurn === null ? t('program.choose_turn') : t('program.selected_turn', {turn: insertionTurn})}</small></div>`
|
||||
: '') + (planning &&
|
||||
canOwn &&
|
||||
g.specializations.some(
|
||||
(s) => s && ["medic", "special-ops"].includes(s.name),
|
||||
)
|
||||
? `<button id="combine" class="quiet icon-button" title="${t("app.combine_two_cards")}" aria-label="${t("app.combine_two_cards")}" aria-pressed="${combine}">${pictogram("combine")}</button>`
|
||||
: "";
|
||||
: "");
|
||||
$("#card-help").textContent = selected
|
||||
.map((choice) => {
|
||||
const card = hand.find((c) => c.id === choice.id);
|
||||
|
|
@ -1062,15 +1103,30 @@ export function mountConsole(root, host = null) {
|
|||
slotVersion: view.game.programs[owner][turn - 1].revision,
|
||||
cards,
|
||||
});
|
||||
placements.push({
|
||||
crew: owner,
|
||||
turn,
|
||||
ids: cards.map((c) => c.id).join(","),
|
||||
});
|
||||
cursor.advance(turn);
|
||||
selected = [];
|
||||
previewTurn = turn;
|
||||
rerender();
|
||||
}
|
||||
async function clearTurn(turn) {
|
||||
if (turn === null) return;
|
||||
const slot = view.game.programs[crew][turn - 1];
|
||||
if (slot.cards.length)
|
||||
await command('remove', { crew, turn, slotVersion: slot.revision });
|
||||
cursor.select(turn);
|
||||
selected = [];
|
||||
}
|
||||
async function waitTurn() {
|
||||
const turn = cursor.turn;
|
||||
if (turn === null) return;
|
||||
await clearTurn(turn);
|
||||
cursor.advance(turn);
|
||||
rerender();
|
||||
}
|
||||
async function eraseTurn() {
|
||||
await clearTurn(cursor.eraseTurn(view.game.programs[crew]));
|
||||
rerender();
|
||||
}
|
||||
const handlePlanningKey = (event) => {
|
||||
if (
|
||||
![
|
||||
|
|
@ -1080,11 +1136,13 @@ export function mountConsole(root, host = null) {
|
|||
"ArrowRight",
|
||||
"ArrowUp",
|
||||
"ArrowDown",
|
||||
"w",
|
||||
"W",
|
||||
].includes(event.key) ||
|
||||
event.ctrlKey ||
|
||||
event.metaKey ||
|
||||
event.altKey ||
|
||||
event.shiftKey
|
||||
(event.shiftKey && event.key !== "W")
|
||||
)
|
||||
return;
|
||||
if (
|
||||
|
|
@ -1108,6 +1166,10 @@ export function mountConsole(root, host = null) {
|
|||
if (!editable.length) return;
|
||||
event.preventDefault();
|
||||
if (pending || event.repeat) return;
|
||||
if (event.key.toLowerCase() === "w") {
|
||||
perform(waitTurn);
|
||||
return;
|
||||
}
|
||||
if (event.key !== "Backspace") {
|
||||
const action = {
|
||||
ArrowLeft: "red",
|
||||
|
|
@ -1115,9 +1177,7 @@ export function mountConsole(root, host = null) {
|
|||
ArrowUp: "lift",
|
||||
ArrowDown: "lift",
|
||||
}[event.key];
|
||||
const turn = editable.find(
|
||||
(n) => !view.game.programs[crew][n - 1].cards.length,
|
||||
);
|
||||
const turn = cursor.turn;
|
||||
const hand = [
|
||||
...(view.game.hand ?? []),
|
||||
...(view.game.androidCards ?? []).filter((c) => c.owner === crew),
|
||||
|
|
@ -1125,7 +1185,7 @@ export function mountConsole(root, host = null) {
|
|||
const card = hand.find((c) =>
|
||||
c.sides.some((side) => side.length === 1 && side[0] === action),
|
||||
);
|
||||
if (turn !== undefined && card) {
|
||||
if (turn !== null && card) {
|
||||
const side = card.sides.findIndex(
|
||||
(side) => side.length === 1 && side[0] === action,
|
||||
);
|
||||
|
|
@ -1133,30 +1193,7 @@ export function mountConsole(root, host = null) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
const matches = placements.filter(
|
||||
(p) =>
|
||||
p.crew === crew &&
|
||||
editable.includes(p.turn) &&
|
||||
view.game.programs[crew][p.turn - 1].cards
|
||||
.map((c) => c.id)
|
||||
.join(",") === p.ids,
|
||||
);
|
||||
const turn =
|
||||
matches.at(-1)?.turn ??
|
||||
editable
|
||||
.filter((n) => view.game.programs[crew][n - 1].cards.length)
|
||||
.at(-1);
|
||||
if (!turn) return;
|
||||
event.preventDefault();
|
||||
perform(async () => {
|
||||
await command("remove", {
|
||||
crew,
|
||||
turn,
|
||||
slotVersion: view.game.programs[crew][turn - 1].revision,
|
||||
});
|
||||
selected = [];
|
||||
rerender();
|
||||
});
|
||||
perform(eraseTurn);
|
||||
};
|
||||
root.ownerDocument.addEventListener("keydown", handlePlanningKey);
|
||||
listenRoot("click", (e) => {
|
||||
|
|
@ -1164,6 +1201,10 @@ export function mountConsole(root, host = null) {
|
|||
if (host && ["ready-all", "next-event", "open-setup"].includes(el?.id))
|
||||
return;
|
||||
if (!el || pending) return;
|
||||
if (el.id === 'program-wait' || el.id === 'program-clear') {
|
||||
perform(el.id === 'program-wait' ? waitTurn : eraseTurn);
|
||||
return;
|
||||
}
|
||||
if (el.id === "open-setup") {
|
||||
navigation.openPanel("setup");
|
||||
return;
|
||||
|
|
@ -1398,10 +1439,8 @@ export function mountConsole(root, host = null) {
|
|||
choice,
|
||||
].slice(-2);
|
||||
else {
|
||||
const turn = editableTurns().find(
|
||||
(n) => !view.game.programs[crew][n - 1].cards.length,
|
||||
);
|
||||
if (turn !== undefined) {
|
||||
const turn = cursor.turn;
|
||||
if (turn !== null && editableTurns().includes(turn)) {
|
||||
perform(() => placeCard(turn, [choice]));
|
||||
return;
|
||||
}
|
||||
|
|
@ -1415,15 +1454,10 @@ export function mountConsole(root, host = null) {
|
|||
return;
|
||||
}
|
||||
if (el.dataset.turn) {
|
||||
const turn = Number(el.dataset.turn),
|
||||
slot = view.game.programs[crew][turn - 1];
|
||||
perform(async () => {
|
||||
if (selected.length) await placeCard(turn, selected);
|
||||
else if (slot.cards.length)
|
||||
await command("remove", { crew, turn, slotVersion: slot.revision });
|
||||
selected = [];
|
||||
rerender();
|
||||
});
|
||||
const turn = Number(el.dataset.turn);
|
||||
cursor.select(turn);
|
||||
if (selected.length) perform(() => placeCard(turn, selected));
|
||||
else { cue('select'); rerender(); }
|
||||
return;
|
||||
}
|
||||
if (el.dataset.command === "resolve-all") {
|
||||
|
|
@ -1634,7 +1668,7 @@ export function mountConsole(root, host = null) {
|
|||
isAnimating: () => effects.busy(),
|
||||
resetTutorial() {
|
||||
previewTurn = null;
|
||||
placements.length = 0;
|
||||
cursor.reset();
|
||||
$("#error").textContent = "";
|
||||
basicsPicked = false;
|
||||
basicsStarted = false;
|
||||
|
|
@ -1661,6 +1695,7 @@ export function mountConsole(root, host = null) {
|
|||
if (seat === nextSeat) return;
|
||||
seat = nextSeat;
|
||||
crew = Math.max(0, seat);
|
||||
cursor.reset();
|
||||
previewTurn = null;
|
||||
selected = [];
|
||||
rerender();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function basicsView(view, locale, { started, picked, shipMarkup }) {
|
|||
? `<div class="practice-clock stopped"><div><strong data-practice-time>${practiceClockText(view, locale)}</strong><small>${t(view.tutorial.remainingMs > 0 ? "timing.stopped" : "timing.expired")}</small></div>${pictogram(view.tutorial.remainingMs > 0 ? "clock" : "lock")}</div>`
|
||||
: "";
|
||||
const deadline = view.tutorial.scenario === "deadline";
|
||||
return `<div class="planning-shortcuts" title="${t(deadline ? "timing.deadline_shortcuts" : "basics.arrows_move_change_deck_backspace_undo_enter_run")}" aria-label="${t(deadline ? "timing.deadline_shortcuts" : "basics.shortcuts_arrow_keys_to_move_backspace_to_undo")}"><kbd>←</kbd><kbd>→</kbd><kbd>↑</kbd><kbd>↓</kbd><kbd>⌫</kbd>${deadline ? "" : "<kbd>↵</kbd>"}</div>${deadline ? "" : `<div class="practice-readiness" role="status" aria-label="${placed}/2 ${t("basics.actions_placed")}"><span>${pictogram("cards")} ${placed}/2</span><span class="ready-dots" aria-hidden="true">${[0, 1].map((i) => `<i class="${i < placed ? "filled" : ""}"></i>`).join("")}</span>${control("basics-run", "check", t("basics.run_program"), placed !== 2)}</div>`}<div class="practice-clock"><div><strong data-practice-time>${practiceClockText(view, locale)}</strong><small>${t(deadline ? "timing.last_seconds" : "basics.time_to_plan")}</small></div>${control("lesson-clock", view.tutorial.clockRunning ? "pause" : "clock", view.tutorial.clockRunning ? t("basics.pause") : t("basics.start_clock"), deadline && placed !== 1)}</div>`;
|
||||
return `<div class="planning-shortcuts" title="${t(deadline ? "timing.deadline_shortcuts" : "basics.arrows_move_change_deck_backspace_undo_enter_run")}" aria-label="${t(deadline ? "timing.deadline_shortcuts" : "basics.shortcuts_arrow_keys_to_move_backspace_to_undo")}"><kbd>←</kbd><kbd>→</kbd><kbd>↑</kbd><kbd>↓</kbd><kbd>W</kbd><kbd>⌫</kbd>${deadline ? "" : "<kbd>↵</kbd>"}</div>${deadline ? "" : `<div class="practice-readiness" role="status" aria-label="${placed}/2 ${t("basics.actions_placed")}"><span>${pictogram("cards")} ${placed}/2</span><span class="ready-dots" aria-hidden="true">${[0, 1].map((i) => `<i class="${i < placed ? "filled" : ""}"></i>`).join("")}</span>${control("basics-run", "check", t("basics.run_program"), placed !== 2)}</div>`}<div class="practice-clock"><div><strong data-practice-time>${practiceClockText(view, locale)}</strong><small>${t(deadline ? "timing.last_seconds" : "basics.time_to_plan")}</small></div>${control("lesson-clock", view.tutorial.clockRunning ? "pause" : "clock", view.tutorial.clockRunning ? t("basics.pause") : t("basics.start_clock"), deadline && placed !== 1)}</div>`;
|
||||
}
|
||||
const intro = !started && !placed && !playing;
|
||||
const ready = placed === 2;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ const paths = {
|
|||
destination: "M5 21V3m0 0h14l-3 4 3 4H5",
|
||||
check: "m4 12 5 5L20 6",
|
||||
close: "m5 5 14 14M5 19 19 5",
|
||||
erase: "M8 5h13v14H8l-6-7 6-7Zm3 4 6 6m0-6-6 6",
|
||||
cards: "M7 7h13v15H7zM4 18H2V2h13v2",
|
||||
combine: "M2 6h7v12H2zM15 6h7v12h-7zM9 12h6m-3-3v6",
|
||||
speaker: "M3 9h4l5-5v16l-5-5H3V9Zm13-2a7 7 0 0 1 0 10m3-13a11 11 0 0 1 0 16",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"lesson.basics.title": "Start here: planning turns",
|
||||
"lesson.first-shot.title": "Your first shot",
|
||||
"lesson.first-shot.instruction.0": "Destroy the target with the highlighted laser.",
|
||||
"lesson.first-shot.instruction.0": "The fighter approaches the center lane. Fire the highlighted laser from the upper center room.",
|
||||
"lesson.first-shot.lane": "Center lane",
|
||||
"lesson.first-shot.shield": "The center shield absorbs hits automatically while charged.",
|
||||
"lesson.energy.title": "Energy and coordination",
|
||||
"lesson.energy.instruction.0": "Power the central laser for four shots.",
|
||||
"lesson.energy.instruction.1": "Android 1: weapons on turns 1-4. Android 3: lift, then energy to refill the reactor.",
|
||||
"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.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.instruction.0": "Repair the highlighted malfunction.",
|
||||
"lesson.repairs.instruction.1": "→ on turn 1, then energy on turns 2-4.",
|
||||
|
|
@ -145,7 +147,7 @@
|
|||
"app.empty": "Empty",
|
||||
"app.target_arrives_before_this_shot": "Target arrives before this shot",
|
||||
"app.choose_a_turn_for_this_card": "Choose a turn for this card.",
|
||||
"app.click_a_card_to_fill_the_next_turn": "Click a card to fill the next turn. Click a filled turn to clear it; Backspace undoes the last placement.",
|
||||
"app.click_a_card_to_fill_the_next_turn": "Click a turn to select it, then a card. W: wait · Backspace: clear.",
|
||||
"app.ready_lasts_two_minutes_we_wait_until_everyone": "Ready lasts two minutes. We wait until everyone is ready together.",
|
||||
"app.programs_are_locked_advance_resolution_or_review_its": "Programs are locked. Advance resolution or review its steps.",
|
||||
"app.not_ready_yet": "Not ready yet",
|
||||
|
|
@ -186,7 +188,7 @@
|
|||
"app.rocket": "Rocket",
|
||||
"app.hit_points": "Hit points",
|
||||
"app.left_center_and_right_correspond_to_red_white": "Left, center and right correspond to red, white and blue in the original announcements. Each threat’s miniature map shows its trajectory or affected rooms.",
|
||||
"app.plan_choose_a_card_then_a_turn_click": "<p><b>Plan.</b> Choose a card then a turn; click a filled turn to retrieve its card. A operates a weapon, B transfers energy, C uses the station system. Arrows move your crew member. Planning does not move the real ship pieces; programs execute during resolution.</p><p><b>Coordinate.</b> Each weapon fires once per turn. Heavy lasers and pulse draw from the zone reactor; light lasers have their own battery. A second crew member using the same lift is delayed.</p><p><b>Computer.</b> Someone must perform C on the bridge within the first two turns of each phase (1-2, 4-5, 8-9), or the next actions are delayed.</p><p><b>Threats.</b> Combine fire before subtracting enemy shields. Rockets hit on the following turn. Threats move after crew actions and execute X, Y and Z as they cross them.</p><p><b>Remote cooperation.</b> Use external voice chat. Stay silent during communications blackouts; this page cannot mute your call.</p>",
|
||||
"app.plan_choose_a_card_then_a_turn_click": "<p><b>Plan.</b> Click a turn to select it, then choose a card. W leaves a wait; Backspace retrieves a card. A operates a weapon, B transfers energy, C uses the station system. Arrows move your crew member. Planning does not move the real ship pieces; programs execute during resolution.</p><p><b>Coordinate.</b> Each weapon fires once per turn. Heavy lasers and pulse draw from the zone reactor; light lasers have their own battery. A second crew member using the same lift is delayed.</p><p><b>Computer.</b> Someone must perform C on the bridge within the first two turns of each phase (1-2, 4-5, 8-9), or the next actions are delayed.</p><p><b>Threats.</b> Combine fire before subtracting enemy shields. Rockets hit on the following turn. Threats move after crew actions and execute X, Y and Z as they cross them.</p><p><b>Remote cooperation.</b> Use external voice chat. Stay silent during communications blackouts; this page cannot mute your call.</p>",
|
||||
"app.reinforcement": "Reinforcement",
|
||||
"app.speed": "Speed",
|
||||
"app.forecast_without_crew_intervention_includes_the_threat_s": "Forecast without crew intervention; includes the threat’s own speed changes.",
|
||||
|
|
@ -442,8 +444,8 @@
|
|||
"text.damage": "Damage {value1} · {value2}",
|
||||
"text.ship_destroyed": "Ship destroyed",
|
||||
"text.attack_absorbed_remaining": "Attack {value1}: {absorbed} absorbed, {damage} remaining",
|
||||
"basics.arrows_move_change_deck_backspace_undo_enter_run": "Arrows: move · ↑/↓: change deck · Backspace: undo · Enter: run",
|
||||
"basics.shortcuts_arrow_keys_to_move_backspace_to_undo": "Shortcuts: arrow keys to move; Backspace to undo; Enter to run",
|
||||
"basics.arrows_move_change_deck_backspace_undo_enter_run": "Arrows: move · W: wait · Backspace: clear · Enter: run",
|
||||
"basics.shortcuts_arrow_keys_to_move_backspace_to_undo": "Arrows: move · W: wait · Backspace: clear · Enter: run",
|
||||
"basics.actions_placed": "actions placed",
|
||||
"basics.run_program": "Run program",
|
||||
"basics.time_to_plan": "Time to plan",
|
||||
|
|
@ -588,7 +590,7 @@
|
|||
"overview.turns": "Full mission · 12 turns",
|
||||
"route.planned": "Planned position after turn {turn}: {room}",
|
||||
"route.assumption": "Intended route without disruptions: delays, threats or a busy lift may change it.",
|
||||
"timing.deadline_shortcuts": "Arrows: move · Backspace: undo",
|
||||
"timing.deadline_shortcuts": "Arrows: move · W: wait · Backspace: clear",
|
||||
"phases.deadline": "Phase {phase} · {time}",
|
||||
"phases.total": "Total",
|
||||
"timing.destination_reached": "Destination reached",
|
||||
|
|
@ -598,5 +600,11 @@
|
|||
"app.jump_after_turn": "After turn {turn}: threats move once more, then the ship jumps.",
|
||||
"app.final_threat_movement": "Final threat movement before the jump",
|
||||
"tactical.impact": "Impact",
|
||||
"phases.complete": "The meteoroid hit during the final threat movement. Then the ship jumped."
|
||||
"phases.complete": "The meteoroid hit during the final threat movement. Then the ship jumped.",
|
||||
"program.wait": "Wait, then select the next turn",
|
||||
"program.clear": "Clear the selected turn, or step back",
|
||||
"program.selected_turn": "Turn {turn}",
|
||||
"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.",
|
||||
"tutorial.lock_phase": "Lock phase {phase}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"lesson.basics.title": "Commencer ici : programmer les tours",
|
||||
"lesson.first-shot.title": "Votre premier tir",
|
||||
"lesson.first-shot.instruction.0": "Détruisez la cible avec le laser surligné.",
|
||||
"lesson.first-shot.instruction.0": "Le chasseur approche au centre. Tirez avec le laser surligné depuis la salle centrale du haut.",
|
||||
"lesson.first-shot.lane": "Zone centrale",
|
||||
"lesson.first-shot.shield": "Le bouclier central absorbe les tirs automatiquement tant qu’il est chargé.",
|
||||
"lesson.energy.title": "Énergie et coordination",
|
||||
"lesson.energy.instruction.0": "Alimentez le laser central pour tirer quatre fois.",
|
||||
"lesson.energy.instruction.1": "Androïde 1 : armes aux tours 1-4. Androïde 3 : ascenseur, puis énergie pour ravitailler le réacteur.",
|
||||
"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.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.instruction.0": "Réparez la panne surlignée.",
|
||||
"lesson.repairs.instruction.1": "→ au tour 1, puis énergie aux tours 2-4.",
|
||||
|
|
@ -145,7 +147,7 @@
|
|||
"app.empty": "Vide",
|
||||
"app.target_arrives_before_this_shot": "La cible arrive avant ce tir",
|
||||
"app.choose_a_turn_for_this_card": "Choisissez un tour pour cette carte.",
|
||||
"app.click_a_card_to_fill_the_next_turn": "Cliquez une carte pour remplir le prochain tour. Cliquez un tour rempli pour l’effacer ; Retour arrière annule le dernier ajout.",
|
||||
"app.click_a_card_to_fill_the_next_turn": "Cliquez un tour pour le sélectionner, puis une carte. W : attendre · Retour arrière : effacer.",
|
||||
"app.ready_lasts_two_minutes_we_wait_until_everyone": "Prêt pendant deux minutes. Nous attendons que tout le monde soit prêt.",
|
||||
"app.programs_are_locked_advance_resolution_or_review_its": "Les programmes sont verrouillés. Avancez la résolution ou revoyez les étapes.",
|
||||
"app.not_ready_yet": "Pas encore prêt",
|
||||
|
|
@ -186,7 +188,7 @@
|
|||
"app.rocket": "Roquette",
|
||||
"app.hit_points": "Points de vie",
|
||||
"app.left_center_and_right_correspond_to_red_white": "Les zones gauche, centre et droite correspondent aux zones rouge, blanche et bleue des annonces originales. Le petit plan sur chaque menace indique sa trajectoire ou les salles touchées.",
|
||||
"app.plan_choose_a_card_then_a_turn_click": "<p><b>Planifier.</b> Choisissez une carte puis un tour ; cliquez sur un tour rempli pour reprendre la carte. A utilise l’arme, B l’énergie, C le système indiqué dans la station. Les flèches déplacent votre équipier. Les déplacements planifiés ne déplacent pas encore les pions : tout sera exécuté pendant la résolution.</p><p><b>Coordonner.</b> Chaque arme ne tire qu’une fois par tour. Le réacteur de la zone alimente le laser lourd et l’impulsion ; les petits lasers ont leur propre batterie. Deux équipiers prenant le même ascenseur retardent le second.</p><p><b>Ordinateur.</b> Quelqu’un doit faire C sur la passerelle pendant les deux premiers tours de chaque phase (1-2, 4-5, 8-9), sinon les actions suivantes sont retardées.</p><p><b>Menaces.</b> Les tirs se combinent avant de retirer le bouclier adverse. Une roquette touche au tour suivant. Les ennemis avancent après les actions et exécutent X, Y, Z en les franchissant.</p><p><b>Coopérer à distance.</b> Utilisez une conversation vocale externe. Pendant une panne de communication, gardez le silence : cette page ne peut pas couper votre appel.</p>",
|
||||
"app.plan_choose_a_card_then_a_turn_click": "<p><b>Planifier.</b> Cliquez un tour pour le sélectionner, puis une carte. W laisse une attente ; Retour arrière reprend une carte. A utilise l’arme, B l’énergie, C le système indiqué dans la station. Les flèches déplacent votre équipier. Les déplacements planifiés ne déplacent pas encore les pions : tout sera exécuté pendant la résolution.</p><p><b>Coordonner.</b> Chaque arme ne tire qu’une fois par tour. Le réacteur de la zone alimente le laser lourd et l’impulsion ; les petits lasers ont leur propre batterie. Deux équipiers prenant le même ascenseur retardent le second.</p><p><b>Ordinateur.</b> Quelqu’un doit faire C sur la passerelle pendant les deux premiers tours de chaque phase (1-2, 4-5, 8-9), sinon les actions suivantes sont retardées.</p><p><b>Menaces.</b> Les tirs se combinent avant de retirer le bouclier adverse. Une roquette touche au tour suivant. Les ennemis avancent après les actions et exécutent X, Y, Z en les franchissant.</p><p><b>Coopérer à distance.</b> Utilisez une conversation vocale externe. Pendant une panne de communication, gardez le silence : cette page ne peut pas couper votre appel.</p>",
|
||||
"app.reinforcement": "Renfort",
|
||||
"app.speed": "Vitesse",
|
||||
"app.forecast_without_crew_intervention_includes_the_threat_s": "Prévision sans intervention de l’équipage ; changements de vitesse propres à la menace inclus.",
|
||||
|
|
@ -442,8 +444,8 @@
|
|||
"text.damage": "Dégât {value1} · {value2}",
|
||||
"text.ship_destroyed": "Vaisseau détruit",
|
||||
"text.attack_absorbed_remaining": "Attaque {value1} : {absorbed} absorbé(s), {damage} restant(s)",
|
||||
"basics.arrows_move_change_deck_backspace_undo_enter_run": "Flèches : déplacement · ↑/↓ : changer de pont · Retour arrière : annuler · Entrée : exécuter",
|
||||
"basics.shortcuts_arrow_keys_to_move_backspace_to_undo": "Raccourcis : flèches pour se déplacer ; retour arrière pour annuler ; entrée pour exécuter",
|
||||
"basics.arrows_move_change_deck_backspace_undo_enter_run": "Flèches : se déplacer · W : attendre · Retour arrière : effacer · Entrée : exécuter",
|
||||
"basics.shortcuts_arrow_keys_to_move_backspace_to_undo": "Flèches : se déplacer · W : attendre · Retour arrière : effacer · Entrée : exécuter",
|
||||
"basics.actions_placed": "actions placées",
|
||||
"basics.run_program": "Exécuter le programme",
|
||||
"basics.time_to_plan": "Temps pour programmer",
|
||||
|
|
@ -588,7 +590,7 @@
|
|||
"overview.turns": "Mission complète · 12 tours",
|
||||
"route.planned": "Position prévue après le tour {turn} : {room}",
|
||||
"route.assumption": "Trajet prévu, sans perturbations : retards, menaces ou ascenseur occupé peuvent le modifier.",
|
||||
"timing.deadline_shortcuts": "Flèches : se déplacer · Retour arrière : annuler",
|
||||
"timing.deadline_shortcuts": "Flèches : se déplacer · W : attendre · Retour arrière : effacer",
|
||||
"phases.deadline": "Phase {phase} · {time}",
|
||||
"phases.total": "Total",
|
||||
"timing.destination_reached": "Destination atteinte",
|
||||
|
|
@ -598,5 +600,11 @@
|
|||
"app.jump_after_turn": "Après le tour {turn} : les menaces avancent une dernière fois, puis le vaisseau saute.",
|
||||
"app.final_threat_movement": "Dernier mouvement des menaces avant le saut",
|
||||
"tactical.impact": "Impact",
|
||||
"phases.complete": "La météorite a frappé lors du dernier mouvement des menaces. Puis le vaisseau a sauté."
|
||||
"phases.complete": "La météorite a frappé lors du dernier mouvement des menaces. Puis le vaisseau a sauté.",
|
||||
"program.wait": "Attendre, puis sélectionner le tour suivant",
|
||||
"program.clear": "Effacer le tour sélectionné, ou revenir au précédent",
|
||||
"program.selected_turn": "Tour {turn}",
|
||||
"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.",
|
||||
"tutorial.lock_phase": "Verrouiller la phase {phase}"
|
||||
}
|
||||
|
|
|
|||
28
preview/program-cursor.js
Normal file
28
preview/program-cursor.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Local insertion positions are independent for each crew member and phase.
|
||||
// null means the cursor has reached the end; undefined means a new phase.
|
||||
export function createProgramCursor() {
|
||||
const positions = new Map();
|
||||
let scope, turns = [];
|
||||
return {
|
||||
sync(nextScope, editable) {
|
||||
scope = nextScope;
|
||||
turns = editable;
|
||||
const current = positions.get(scope);
|
||||
if (current === undefined || (current !== null && !turns.includes(current)))
|
||||
positions.set(scope, turns[0] ?? null);
|
||||
return this.turn;
|
||||
},
|
||||
get turn() { return positions.get(scope) ?? null; },
|
||||
select(turn) {
|
||||
if (turns.includes(turn)) positions.set(scope, turn);
|
||||
},
|
||||
advance(turn = this.turn) {
|
||||
positions.set(scope, turns.find(n => n > turn) ?? null);
|
||||
},
|
||||
eraseTurn(program) {
|
||||
if (this.turn !== null && program[this.turn - 1]?.cards.length) return this.turn;
|
||||
return turns.filter(n => this.turn === null || n < this.turn).at(-1) ?? null;
|
||||
},
|
||||
reset() { positions.clear(); },
|
||||
};
|
||||
}
|
||||
|
|
@ -66,8 +66,9 @@ export function createResolutionEffects(root, cue) {
|
|||
layer.className = "resolution-effects";
|
||||
layer.setAttribute("aria-hidden", "true");
|
||||
root.append(layer);
|
||||
let previous = null, previousIndex = -1, busyUntil = 0, jumping = false;
|
||||
let previous = null, previousIndex = -1, busyUntil = 0, jumping = false, pendingFrame = null;
|
||||
let oldPawns = new Map();
|
||||
let oldShip = null;
|
||||
const animations = new Set(), timers = new Set(), restores = [];
|
||||
const q = selector => root.querySelector(selector);
|
||||
const threat = id => q(`[data-threat="${id}"] .threat-portrait`);
|
||||
|
|
@ -91,6 +92,8 @@ export function createResolutionEffects(root, cue) {
|
|||
busyUntil = Math.max(busyUntil, performance.now() + duration + delay);
|
||||
}
|
||||
function clear() {
|
||||
if (pendingFrame !== null) win.cancelAnimationFrame(pendingFrame);
|
||||
pendingFrame = null;
|
||||
for (const id of timers) win.clearTimeout(id);
|
||||
timers.clear();
|
||||
for (const animation of animations) animation.cancel();
|
||||
|
|
@ -309,6 +312,7 @@ export function createResolutionEffects(root, cue) {
|
|||
let oldMeters = new Map();
|
||||
function beforeRender() {
|
||||
clear();
|
||||
oldShip = point(q(".ship-vessel"));
|
||||
oldPawns = new Map([...root.querySelectorAll("[data-crew]")].map(p => [p.dataset.crew, point(p)]));
|
||||
oldMeters = new Map([...root.querySelectorAll("[data-threat]")].map(p => [`threat-${p.dataset.threat}`, p.querySelector(".threat-hud")?.innerHTML]));
|
||||
for (const zone of ["red", "white", "blue"]) {
|
||||
|
|
@ -318,14 +322,32 @@ export function createResolutionEffects(root, cue) {
|
|||
}
|
||||
function afterRender(resolution, index) {
|
||||
const current = resolution?.frames[index];
|
||||
if (current && previous && index === previousIndex + 1 && !doc.hidden)
|
||||
play(resolutionEffects(resolution, previous, current), previous, current, oldMeters);
|
||||
if (current && previous && index === previousIndex + 1 && !doc.hidden) {
|
||||
const events = resolutionEffects(resolution, previous, current), before = previous;
|
||||
if (events.length) {
|
||||
// Tutorial completion also updates the guide and removes controls. Let
|
||||
// layout and scroll anchoring settle before locating beams and targets.
|
||||
busyUntil = performance.now() + 1000;
|
||||
pendingFrame = win.requestAnimationFrame(() => {
|
||||
pendingFrame = win.requestAnimationFrame(() => {
|
||||
pendingFrame = null;
|
||||
const ship = point(q(".ship-vessel"));
|
||||
if (oldShip && ship)
|
||||
oldPawns = new Map([...oldPawns].map(([id, p]) => [id, p && {
|
||||
...p, x: p.x + ship.x - oldShip.x, y: p.y + ship.y - oldShip.y,
|
||||
}]));
|
||||
busyUntil = 0;
|
||||
play(events, before, current, oldMeters);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
previous = current;
|
||||
previousIndex = index;
|
||||
}
|
||||
// Moving/resizing the viewport invalidates projectile coordinates.
|
||||
win.addEventListener("resize", clear);
|
||||
const scroll = () => { if (!jumping) clear(); };
|
||||
const scroll = () => { if (!jumping && pendingFrame === null) clear(); };
|
||||
doc.addEventListener("scroll", scroll, true);
|
||||
const visibility = () => { if (doc.hidden) clear(); };
|
||||
doc.addEventListener("visibilitychange", visibility);
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@ export function createPreviewServer({ clock = Date.now, storagePath } = {}) {
|
|||
"/tactical.js": "tactical.js",
|
||||
"/threat-track.js": "threat-track.js",
|
||||
"/program-route.js": "program-route.js",
|
||||
"/program-cursor.js": "program-cursor.js",
|
||||
"/resolution-effects.js": "resolution-effects.js",
|
||||
"/sound.js": "sound.js",
|
||||
"/i18n.js": "i18n.js",
|
||||
|
|
|
|||
|
|
@ -363,6 +363,30 @@ h2 {
|
|||
.slot.selected {
|
||||
outline: 2px solid var(--gold);
|
||||
}
|
||||
#program .slot.insertion {
|
||||
outline: 2px solid var(--gold);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
#program .slot.insertion .turn { color: var(--gold); font-weight: 700; }
|
||||
.program-edit-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
|
||||
.program-edit-tools button { padding: 7px 10px; min-height: 38px; }
|
||||
.program-edit-tools kbd { color: var(--muted); font: inherit; font-size: 11px; }
|
||||
.program-edit-tools small { color: var(--gold); }
|
||||
|
||||
/* Reveal equipment in the lesson that first uses it. The room layout stays familiar. */
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .system-card,
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .ship-passage,
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .energy-conduits,
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .lift-bay { visibility: hidden; }
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) [data-station="white-upper"] :is(.weapon-system, .energy-system),
|
||||
.native-tutorial[data-chapter="energy"] [data-station="white-lower"] .energy-system,
|
||||
.native-tutorial[data-chapter="energy"] .lift-bay:has([data-inspect="lift-white"]) { visibility: visible; }
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .crew-pawn:not([data-crew="0"]):not([data-crew="2"]),
|
||||
.native-tutorial[data-chapter="first-shot"] .crew-pawn[data-crew="2"],
|
||||
.native-tutorial:is([data-chapter="first-shot"], [data-chapter="energy"]) .ship-key > span:last-child { display: none; }
|
||||
.native-tutorial[data-chapter="energy"] :is(#controls, #resources, #threats, #latest, #comms),
|
||||
.native-tutorial[data-chapter="energy"] .section-heading:has(#threat-title) { display: none; }
|
||||
.native-tutorial[data-chapter="energy"] #hand { grid-template-columns: repeat(2, 88px); }
|
||||
.controls {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
|
|
@ -424,6 +448,18 @@ h2 {
|
|||
background: var(--gold);
|
||||
color: #132430;
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.card button:not(:disabled):not(.selected):hover {
|
||||
background: #34535f;
|
||||
box-shadow: inset 0 0 0 2px #a2e3ef;
|
||||
}
|
||||
}
|
||||
.card button:not(:disabled):focus-visible {
|
||||
outline: 0;
|
||||
box-shadow: inset 0 0 0 2px #a2e3ef;
|
||||
}
|
||||
.card button.selected:focus-visible { box-shadow: inset 0 0 0 2px #132430; }
|
||||
.card button:not(:disabled):active { filter: brightness(1.2); }
|
||||
.card .tiny {
|
||||
font-size: 10px;
|
||||
line-height: 1.2;
|
||||
|
|
@ -2532,6 +2568,11 @@ input:not([type="checkbox"]):not([type="range"]) {
|
|||
.lesson-target .section-heading { margin-bottom: 10px; }
|
||||
.pending-threat > .equipment-art { opacity: .35; }
|
||||
.lesson-target .hull-gauge { border-color: #74e8bd; }
|
||||
.lesson-shield-note { display: flex; align-items: center; gap: 8px; color: #a2e3ef; font-size: 13px; max-width: 65ch; }
|
||||
.lesson-shield-note .pictogram { flex: 0 0 22px; width: 22px; height: 22px; }
|
||||
.native-tutorial .lesson-shield-focus { outline: 1px solid #8eeaff; outline-offset: 2px; }
|
||||
.native-tutorial .lesson-lane { border-left-color: #e8c984; border-right-color: #e8c984; }
|
||||
.lesson-lane-label { position: absolute; left: calc(100% + 8px); top: 4px; width: 80px; color: #e8c984; font-size: 12px; text-align: left; line-height: 1.3; }
|
||||
/* Discovery introduces the target before exposing editable program controls. */
|
||||
.native-tutorial[data-chapter="first-shot"][data-tutorial-step="0"] #planning {
|
||||
display: block !important;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ export function completedTurns(state) {
|
|||
const r = state.game.resolution;
|
||||
return r?.step === "damage" ? r.turn : Math.max(0, (r?.turn ?? 0) - 1);
|
||||
}
|
||||
export function energyObjective(state) {
|
||||
const log = state.game.resolution?.log ?? [];
|
||||
const shots = new Set(log.filter(e => e.type === 'fire' &&
|
||||
e.station === 'white-upper' && e.turn >= 1 && e.turn <= 4).map(e => e.turn)).size;
|
||||
const refilled = log.some(e => e.type === 'energy' &&
|
||||
e.station === 'white-lower' && e.amount > 0 && e.turn <= 4);
|
||||
return { shots, refilled, complete: shots === 4 && refilled };
|
||||
}
|
||||
|
||||
// BGS owns checkpoints and saved action history. All moves still use our engine.
|
||||
export async function createLessonTutorial(
|
||||
|
|
@ -36,7 +44,7 @@ export async function createLessonTutorial(
|
|||
return createTutorial({
|
||||
game: "space-alert",
|
||||
id,
|
||||
version: lesson.basics ? 4 : 2,
|
||||
version: lesson.basics ? 4 : id === "energy" ? 3 : 2,
|
||||
storage,
|
||||
onProgress,
|
||||
initialState: () => createLesson(id, 1000, { timing: lesson.basics }),
|
||||
|
|
@ -213,7 +221,9 @@ export async function createLessonTutorial(
|
|||
{
|
||||
id: "execute",
|
||||
title: t("basics.run_the_turns"),
|
||||
text: lesson.basics
|
||||
text: (state) => id === 'energy' && completedTurns(state) >= 4 && !energyObjective(state).complete
|
||||
? t('lesson.energy.retry', { count: energyObjective(state).shots })
|
||||
: lesson.basics
|
||||
? t("timing.executing")
|
||||
: t(
|
||||
"tutorial_controller.program_locked_crew_act_together_then_threats",
|
||||
|
|
@ -223,6 +233,8 @@ export async function createLessonTutorial(
|
|||
? completedTurns(state) >= 3 &&
|
||||
state.game.resolution.ship.crew[0].station ===
|
||||
state.tutorial.targetStation
|
||||
: id === 'energy'
|
||||
? completedTurns(state) >= 4 && energyObjective(state).complete
|
||||
: id === "first-shot" && state.tutorial.stopAtTarget
|
||||
? state.game.resolution.threats.some(
|
||||
(threat) =>
|
||||
|
|
|
|||
|
|
@ -137,6 +137,11 @@ export function createLesson(id, now, { timing = false } = {}) {
|
|||
structuredClone(TRACKS[6]),
|
||||
]),
|
||||
);
|
||||
// Teach ordinary refueling before introducing heroic overflow bonuses.
|
||||
if (id === "energy")
|
||||
s.game.androidCards = s.game.androidCards.filter(
|
||||
id => s.game.cards[id].kind !== "heroic",
|
||||
);
|
||||
// Public, editable teammate example, using physical cards from the shared solo deck.
|
||||
for (const turn of [1, 4]) {
|
||||
const id = s.game.hands[0].find((id) =>
|
||||
|
|
|
|||
37
test/program-cursor.test.js
Normal file
37
test/program-cursor.test.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createProgramCursor } from '../preview/program-cursor.js';
|
||||
|
||||
test('turn selection and waits allow separated actions without changing earlier slots', () => {
|
||||
const cursor = createProgramCursor();
|
||||
const program = Array.from({length: 4}, () => ({cards: []}));
|
||||
assert.equal(cursor.sync('0/1', [1,2,3,4]), 1);
|
||||
program[cursor.turn - 1].cards.push('shot');
|
||||
cursor.advance();
|
||||
cursor.advance(); // W: wait at 2
|
||||
cursor.advance(); // W: wait at 3
|
||||
assert.equal(cursor.turn, 4);
|
||||
program[cursor.turn - 1].cards.push('shot');
|
||||
cursor.advance();
|
||||
assert.equal(cursor.turn, null);
|
||||
assert.equal(cursor.sync('0/1', [1,2,3,4]), null, 'refresh does not wrap to turn 1');
|
||||
assert.deepEqual(program.map(s => s.cards), [['shot'], [], [], ['shot']]);
|
||||
assert.equal(cursor.eraseTurn(program), 4);
|
||||
cursor.select(1);
|
||||
assert.equal(cursor.eraseTurn(program), 1, 'clicking a filled turn selects it for replacement/clearing');
|
||||
});
|
||||
|
||||
test('cursor respects editable phases, crew switches and tutorial reset', () => {
|
||||
const cursor = createProgramCursor();
|
||||
assert.equal(cursor.sync('0/1', [2,3]), 2, 'first-shot turn 1 is unavailable');
|
||||
cursor.select(3);
|
||||
cursor.select(1);
|
||||
assert.equal(cursor.turn, 3);
|
||||
assert.equal(cursor.sync('2/1', [1,2,3]), 1);
|
||||
assert.equal(cursor.sync('0/1', [2,3]), 3);
|
||||
assert.equal(cursor.sync('0/2', [4,5,6,7]), 4);
|
||||
cursor.select(6);
|
||||
assert.equal(cursor.eraseTurn(Array.from({length: 7}, () => ({cards: []}))), 5);
|
||||
cursor.reset();
|
||||
assert.equal(cursor.sync('0/1', [2,3]), 2);
|
||||
});
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
completedTurns,
|
||||
} from "../src/tutorial-controller.js";
|
||||
|
||||
async function place(tutorial, turn, direction) {
|
||||
async function place(tutorial, turn, direction, crew = 0) {
|
||||
const s = tutorial.snapshot.state;
|
||||
const id = s.game.hands[0].find((id) =>
|
||||
s.game.cards[id].sides.some(
|
||||
|
|
@ -20,9 +20,9 @@ async function place(tutorial, turn, direction) {
|
|||
assert.equal(
|
||||
await tutorial.play({
|
||||
type: "program",
|
||||
crew: 0,
|
||||
crew,
|
||||
turn,
|
||||
slotVersion: s.game.slotVersions[0][turn - 1],
|
||||
slotVersion: s.game.slotVersions[crew][turn - 1],
|
||||
cards: [{ id, side }],
|
||||
}),
|
||||
true,
|
||||
|
|
@ -174,6 +174,12 @@ test("every chapter can plan, execute, complete, and replay through native contr
|
|||
} else if (lesson.id === "first-shot") {
|
||||
await place(tutorial, 2, "A");
|
||||
await place(tutorial, 3, "A");
|
||||
} else if (lesson.id === 'energy') {
|
||||
for (const turn of [1, 2, 3]) await place(tutorial, turn, 'A');
|
||||
await place(tutorial, 1, 'lift', 2);
|
||||
await place(tutorial, 2, 'B', 2);
|
||||
await tutorial.play({ type: 'practice-phase' });
|
||||
await place(tutorial, 4, 'A');
|
||||
}
|
||||
while (tutorial.snapshot.state.stage === "programming")
|
||||
assert.equal(
|
||||
|
|
@ -198,6 +204,33 @@ test("every chapter can plan, execute, complete, and replay through native contr
|
|||
}
|
||||
});
|
||||
|
||||
test('energy tutorial requires four actual center shots and a refill, not just playback', async () => {
|
||||
for (const shots of [0, 1, 4]) {
|
||||
for (const refill of [false, true]) {
|
||||
const tutorial = await createLessonTutorial('energy');
|
||||
await tutorial.continue();
|
||||
assert.ok(tutorial.snapshot.state.game.androidCards.every(id =>
|
||||
tutorial.snapshot.state.game.cards[id].kind !== 'heroic'));
|
||||
for (let turn = 1; turn <= Math.min(shots, 3); turn++)
|
||||
await place(tutorial, turn, 'A');
|
||||
if (refill) {
|
||||
await place(tutorial, 1, 'lift', 2);
|
||||
await place(tutorial, 2, 'B', 2);
|
||||
}
|
||||
await tutorial.play({type: 'practice-phase'});
|
||||
if (shots === 4) await place(tutorial, 4, 'A');
|
||||
await tutorial.play({type: 'practice-run'});
|
||||
while (completedTurns(tutorial.snapshot.state) < 4)
|
||||
assert.equal(await tutorial.play({type: 'resolve'}), true);
|
||||
assert.equal(tutorial.snapshot.completed, shots === 4 && refill, `${shots} shots/refill ${refill}`);
|
||||
assert.ok(tutorial.snapshot.state.game.resolution.frames.every(frame =>
|
||||
frame.ship.zones.white.reactor <= 5));
|
||||
if (!tutorial.snapshot.completed) assert.match(tutorial.snapshot.text, /\/4 shots fired/);
|
||||
tutorial.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("first shot stops on target destruction at turn 3, and preserves new and legacy saves", async () => {
|
||||
for (const objective of [true, false]) {
|
||||
const data = new Map();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue