Show threat arrival beside planned shots and keep the target in view
This commit is contained in:
parent
3b9388a8da
commit
acb3f92f65
5 changed files with 23 additions and 5 deletions
|
|
@ -31,6 +31,14 @@ export async function mountLesson(target, { chapter = "basics", locale = "en", o
|
|||
target.querySelector("#planning").append(target.querySelector("#basics-guide"));
|
||||
target.querySelector("#ship").classList.add("training-ship");
|
||||
}
|
||||
if (chapter === "first-shot") {
|
||||
const threats = target.querySelector("#threats");
|
||||
const heading = target.querySelector("#threat-title").closest(".section-heading");
|
||||
const objective = document.createElement("section");
|
||||
objective.className = "lesson-target";
|
||||
target.querySelector("#planning").append(objective);
|
||||
objective.append(heading, threats);
|
||||
}
|
||||
const goChapter = id => {
|
||||
if (standalone) location.assign(`/learn?chapter=${encodeURIComponent(id)}&locale=${encodeURIComponent(locale)}`);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ export function mountConsole(root, host = null) {
|
|||
threats
|
||||
.map(
|
||||
(th) =>
|
||||
`<article class="threat illustrated-threat" style="--zone:var(--${th.zone ?? "gold"})"><button class="threat-card" data-inspect="${th.instance}" data-inspect-title="${esc(th.name)} · T+${th.turn}" aria-haspopup="dialog" aria-label="${esc(th.name)} · ${t("Tour", "Turn")} ${th.turn} · ${esc(th.position === "internal" ? th.stations.map((s) => stationLabel(s, locale)).join(", ") : zoneName(th.zone))} · ${t("Détails", "Details")}"><span class="threat-heading"><strong>${esc(th.name)}</strong><span class="threat-timing" title="${t("Arrivée au tour", "Arrival on turn")} ${th.turn}">T+${th.turn}</span></span>${threatPortrait(th)}<span class="threat-footer">${symbol("speed", `${t("Vitesse", "Speed")} : ${th.speed}`, th.speed)}<span>${t("Détails", "Details")}</span></span></button>${(th.track ?? g.tracks[th.zone ?? "internal"]) ? trackHtml(th, g) : ""}<template>${threatPortrait(th)}<div class="threat-facts">${symbol("speed", `${t("Vitesse", "Speed")} : ${th.speed}`, th.speed)}</div><p>${th.position === "internal" ? esc(th.stations.map((s) => stationLabel(s, locale)).join(", ")) + " · " + esc(label(th.repair)) : esc(zoneName(th.zone))}</p>${traitDescriptions(
|
||||
`<article class="threat illustrated-threat" style="--zone:var(--${th.zone ?? "gold"})"><button class="threat-card" data-inspect="${th.instance}" data-inspect-title="${esc(th.name)} · T+${th.turn}" aria-haspopup="dialog" aria-label="${esc(th.name)} · ${t("Tour", "Turn")} ${th.turn} · ${esc(th.position === "internal" ? th.stations.map((s) => stationLabel(s, locale)).join(", ") : zoneName(th.zone))} · ${t("Détails", "Details")}"><span class="threat-heading"><strong>${esc(th.name)}</strong><span class="threat-timing" title="${t("Arrivée au tour", "Arrival on turn")} ${th.turn}">${t("Arrivée", "Arrival")} T+${th.turn}</span></span>${threatPortrait(th)}<span class="threat-footer">${symbol("speed", `${t("Vitesse", "Speed")} : ${th.speed}`, th.speed)}<span>${t("Détails", "Details")}</span></span></button>${(th.track ?? g.tracks[th.zone ?? "internal"]) ? trackHtml(th, g) : ""}<template>${threatPortrait(th)}<div class="threat-facts">${symbol("speed", `${t("Vitesse", "Speed")} : ${th.speed}`, th.speed)}</div><p>${th.position === "internal" ? esc(th.stations.map((s) => stationLabel(s, locale)).join(", ")) + " · " + esc(label(th.repair)) : esc(zoneName(th.zone))}</p>${traitDescriptions(
|
||||
th,
|
||||
locale,
|
||||
)
|
||||
|
|
@ -480,7 +480,7 @@ export function mountConsole(root, host = null) {
|
|||
!own.finishedPlanning &&
|
||||
phaseFor(slot.turn) === ownPhase;
|
||||
const description = `T+${slot.turn} · ${slot.cards.map((c) => (c.sides ? c.sides[c.side].map(label).join(" → ") : c.category === "movement" ? t("Déplacement", "Movement") : t("Action", "Action"))).join(" + ") || t("Vide", "Empty")}`;
|
||||
return `<button class="slot ${slot.cards.length ? "filled" : "empty"} ${basic && resolution && slot.turn === (resolution.step === "damage" ? resolution.turn : Math.max(0, resolution.turn - 1)) ? "current" : ""} ${phaseFor(slot.turn) < ownPhase ? "locked" : ""} ${phaseFor(slot.turn) > ownPhase ? "future" : ""}" data-turn="${slot.turn}" ${editable ? "" : "disabled"} title="${esc(description)}" aria-label="${esc(description)}"><span class="turn">T+${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></button>`;
|
||||
return `<button class="slot ${slot.cards.length ? "filled" : "empty"} ${basic && resolution && slot.turn === (resolution.step === "damage" ? resolution.turn : Math.max(0, resolution.turn - 1)) ? "current" : ""} ${phaseFor(slot.turn) < ownPhase ? "locked" : ""} ${phaseFor(slot.turn) > ownPhase ? "future" : ""}" data-turn="${slot.turn}" ${editable ? "" : "disabled"} title="${esc(description)}" aria-label="${esc(description)}">${firstShot && slot.turn === 2 ? `<span class="slot-arrival" title="${t("La cible arrive avant ce tir", "Target arrives before this shot")}">${pictogram("down")}${t("Arrivée", "Arrival")}</span>` : ""}<span class="turn">T+${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></button>`;
|
||||
})
|
||||
.join("");
|
||||
$("#program").setAttribute("aria-keyshortcuts", "ArrowLeft ArrowRight ArrowUp ArrowDown Backspace");
|
||||
|
|
|
|||
|
|
@ -2495,3 +2495,12 @@ input:not([type="checkbox"]):not([type="range"]) {
|
|||
.native-guide-row { gap: 6px; }
|
||||
.native-guide-row .native-guide-tools a { display: none; }
|
||||
}
|
||||
|
||||
.native-tutorial[data-chapter="first-shot"] #program { margin-top: 32px; }
|
||||
.slot-arrival { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 3px; white-space: nowrap; color: #e8c984; font-size: 12px; }
|
||||
.slot-arrival .pictogram { width: 16px; height: 16px; }
|
||||
.lesson-target { margin-top: 24px; max-width: 340px; }
|
||||
.lesson-target .section-heading { margin-bottom: 10px; }
|
||||
.pending-threat > .equipment-art { opacity: .35; }
|
||||
.threat-pending { position: absolute; top: 68px; right: 10px; color: var(--muted); font-size: 12px; }
|
||||
.lesson-target .hull-gauge { border-color: #74e8bd; }
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ export function createTacticalView({
|
|||
|
||||
function threatPortrait(th) {
|
||||
const hp = Math.max(0, th.hp - (th.damage ?? 0));
|
||||
const pending = ["pending", "announced", "waiting"].includes(th.status);
|
||||
const gone = ["destroyed", "survived", "discarded"].includes(th.status);
|
||||
const status =
|
||||
th.status === "destroyed"
|
||||
|
|
@ -193,7 +194,7 @@ export function createTacticalView({
|
|||
.join(", ")}`
|
||||
: `${t("Trajectoire", "Trajectory")} : ${zoneName(th.zone)}`;
|
||||
const target = `<span class="threat-target" style="--zone:var(--${["red", "white", "blue"].includes(th.zone) ? th.zone : "cyan"})" role="img" aria-label="${esc(targetName)}" title="${esc(targetName)}">${shipLocator(stations, internal ? null : th.zone)}</span>`;
|
||||
return `<span class="threat-portrait ${gone ? "resolved-threat" : ""}">${target}${visual}<span class="threat-hud"><span class="hull-gauge"><span>${symbol("hull", `${t("Points de vie", "Hit points")} : ${hp}/${th.hp}`, `<b>${hp}<small>/${th.hp}</small></b>`)}</span><span class="hull-bar"><i style="width:${Math.max(0, Math.min(100, (hp / Math.max(1, th.hp)) * 100))}%"></i></span></span><span class="shield-badge">${symbol("shield", `${t("Bouclier", "Shield")} : ${th.shield}`, `<b>${th.shield}</b>`)}</span></span>${status ? `<span class="threat-outcome">${esc(status)}</span>` : ""}</span>`;
|
||||
return `<span class="threat-portrait ${pending ? "pending-threat" : ""} ${gone ? "resolved-threat" : ""}">${target}${visual}<span class="threat-hud"><span class="hull-gauge"><span>${symbol("hull", `${t("Points de vie", "Hit points")} : ${hp}/${th.hp}`, `<b>${hp}<small>/${th.hp}</small></b>`)}</span><span class="hull-bar"><i style="width:${Math.max(0, Math.min(100, (hp / Math.max(1, th.hp)) * 100))}%"></i></span></span><span class="shield-badge">${symbol("shield", `${t("Bouclier", "Shield")} : ${th.shield}`, `<b>${th.shield}</b>`)}</span></span>${pending ? `<span class="threat-pending">${t("À venir", "Incoming")}</span>` : ""}${status ? `<span class="threat-outcome">${esc(status)}</span>` : ""}</span>`;
|
||||
}
|
||||
return { shipCutaway, threatPortrait };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ export const LESSONS = [
|
|||
lesson(
|
||||
"first-shot",
|
||||
["Votre premier tir", "Your first shot"],
|
||||
[["Détruisez la cible avec le laser surligné. Tirez aux tours 2 et 3.",
|
||||
"Destroy the target with the highlighted laser. Fire on turns 2 and 3."]],
|
||||
[["Détruisez la cible avec le laser surligné.",
|
||||
"Destroy the target with the highlighted laser."]],
|
||||
{ threat: "E1-07", turn: 2 },
|
||||
),
|
||||
lesson(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue