Add typed depot logistics visibility, auto-strike, 16-block reach, and web panel controls
build / mod (push) Failing after 15s
build / mod (push) Failing after 15s
This commit is contained in:
@@ -69,7 +69,7 @@ async function api(path, {method = "GET", data} = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
const groups = [["units", "unit"], ["objects", "object"], ["contacts", "contact"], ["interceptors", "interceptor"]];
|
||||
const groups = [["units", "unit"], ["objects", "object"], ["contacts", "contact"], ["interceptors", "interceptor"], ["sites", "site"]];
|
||||
const prefs = read("view", {layers: {}, views: {}, selected: null});
|
||||
prefs.layers ||= {};
|
||||
prefs.views ||= {};
|
||||
@@ -81,7 +81,7 @@ let selected = prefs.selected, connected = false, http = false, polling = false,
|
||||
let events = [], raids = [], raid = null, more = false, historyGeneration = 0, frameGeneration = 0, chainGeneration = 0;
|
||||
let eventTimer, frameTimer, receiptTimer, latestRequest = read("launch-request", null), installPrompt;
|
||||
let offlineEvents = [], offlineFrames = {}, offlineRaids = {raids: []};
|
||||
let offlineTimelines = {}, selectedEvent = null, timelineGeneration = 0;
|
||||
let offlineTimelines = {}, selectedEvent = null, timelineGeneration = 0, actionBusy = false;
|
||||
const timelineRequests = new Map();
|
||||
const timeline = createTimeline($("timeline-markers"), openEvent, time);
|
||||
const viewKey = () => mapMode === "radar" ? `radar:${perspective}` : perspective;
|
||||
@@ -185,12 +185,40 @@ function draw() {
|
||||
if (frame.summary) status.push(`Сбито ${frame.summary.kills} · попаданий ${frame.summary.hits}`);
|
||||
if (frame.summary?.planning) status.push("Игра готовит налёт");
|
||||
if (frame.summary?.hold) status.push("Огонь запрещён");
|
||||
if (frame.summary?.autoStrike) status.push("Автоудар вкл");
|
||||
if (perspective === "enemy") status.push(`Донесений ${frame.contacts?.length || 0} · вылетов разведки ${frame.sorties?.length || 0}`);
|
||||
if (perspective === "truth") status.push("Песочница · истинные позиции");
|
||||
}
|
||||
if (frame?.limited) status.push("Часть отметок за пределом отображения");
|
||||
$("map-status").textContent = status.join(" · ");
|
||||
|
||||
const autoBtn = $("autostrike-toggle");
|
||||
const showAuto = !historical && perspective === "network" && frame?.summary != null;
|
||||
autoBtn.hidden = !showAuto;
|
||||
if (showAuto) {
|
||||
const autoOn = !!frame.summary.autoStrike;
|
||||
autoBtn.setAttribute("aria-pressed", String(autoOn));
|
||||
autoBtn.textContent = autoOn ? "Автоудар: вкл" : "Автоудар: выкл";
|
||||
autoBtn.disabled = !auth?.permissions?.launch || !connected || !live?.session || actionBusy;
|
||||
}
|
||||
|
||||
const logBox = $("logistics-summary");
|
||||
if (!historical && perspective === "network" && frame?.logistics) {
|
||||
const l = frame.logistics;
|
||||
const rows = [
|
||||
make("h3", "Снабжение и склады"),
|
||||
paragraph(`Склады ${l.depots} · ТЗМ ${l.trucksBusy}/${l.trucks} · БК ${l.ammoTotal} · RM48U ${l.rm48uDepot}+${l.rm48uTruck} (в ПУ ${l.rm48uLoaded})`),
|
||||
paragraph(`Ждут БК ${l.waitingAmmo} · ждут RM48U ${l.waitingRm48u} · перезарядка ${l.reloading}`),
|
||||
];
|
||||
if (l.kinds?.length) {
|
||||
rows.push(paragraph(l.kinds.map(k => `${k.name}: ${k.depot + k.truck}`).join(" · ")));
|
||||
}
|
||||
logBox.replaceChildren(...rows);
|
||||
logBox.hidden = false;
|
||||
} else {
|
||||
logBox.hidden = true;
|
||||
}
|
||||
|
||||
const data = groups.flatMap(([group, kind]) => prefs.layers[group] === false ? [] : (frame?.[group] || [])
|
||||
.map(row => ({row, kind, key: `${kind}:${row.id}`})));
|
||||
const opened = data.find(item => item.key === selected);
|
||||
@@ -247,7 +275,20 @@ function showObject(opened, frame) {
|
||||
if (row.confidence) nodes.push(paragraph(`Достоверность · ${row.confidence}`));
|
||||
if (row.quality != null) nodes.push(paragraph(`Качество · ${row.quality}`));
|
||||
if (row.radarRange > 0) nodes.push(paragraph(`Номинальная дальность радара · ${Math.round(row.radarRange)} бл.`));
|
||||
if (row.depotReach > 0) nodes.push(paragraph(`Зона прямой перезарядки · ${Math.round(row.depotReach)} бл.`));
|
||||
if (row.supply) nodes.push(paragraph(`Снабжение · ${row.supply}`));
|
||||
if (row.radius > 0) nodes.push(paragraph(`Область оценки · ±${Math.round(row.radius)} бл.`));
|
||||
if (kind === "site") {
|
||||
if (row.className) nodes.push(paragraph(`Тип · ${row.className}`));
|
||||
if (row.accuracy) nodes.push(paragraph(`Точность · ${row.accuracy}`));
|
||||
if (row.launches != null) nodes.push(paragraph(`Пусков замечено · ${row.launches}`));
|
||||
if (row.aimed) nodes.push(paragraph("Ракета по ПУ уже в полёте"));
|
||||
if (row.canStrike && !historical && perspective === "network" && auth?.permissions?.launch) {
|
||||
const strikeBtn = button("Нанести удар", () => sendAction("strike", row.id));
|
||||
strikeBtn.disabled = !connected || !live?.session || actionBusy;
|
||||
nodes.push(strikeBtn);
|
||||
}
|
||||
}
|
||||
if (row.target) nodes.push(button(`Контакт №${row.target}`, () => select(`contact:${row.target}`, true)));
|
||||
if (row.source) {
|
||||
const linked = frame?.units?.some(unit => unit.id === row.source);
|
||||
@@ -792,6 +833,29 @@ $("confirm-launch").addEventListener("click", async () => {
|
||||
}
|
||||
});
|
||||
$("cancel-launch").addEventListener("click", () => $("confirmation").close());
|
||||
async function sendAction(action, value) {
|
||||
if (!auth?.permissions?.launch || historical || !connected || !live?.session || actionBusy) return;
|
||||
const id = Array.from(crypto.getRandomValues(new Uint8Array(16)), n => n.toString(16).padStart(2, "0")).join("");
|
||||
actionBusy = true;
|
||||
$("action-status").textContent = "Отправляем команду…";
|
||||
draw();
|
||||
try {
|
||||
const result = await api("/action", {
|
||||
method: "POST",
|
||||
data: {id, session: live.session, action, value},
|
||||
});
|
||||
$("action-status").textContent = result?.message || "Команда отправлена";
|
||||
poll();
|
||||
} catch (error) {
|
||||
$("action-status").textContent = error.message || "Ошибка отправки команды";
|
||||
} finally {
|
||||
actionBusy = false;
|
||||
draw();
|
||||
}
|
||||
}
|
||||
$("autostrike-toggle").addEventListener("click", () => {
|
||||
sendAction("autostrike", activeFrame()?.summary?.autoStrike ? "off" : "on");
|
||||
});
|
||||
$("preset").addEventListener("change", () => {
|
||||
applyDraft(catalog?.presets[Number($("preset").value)]);
|
||||
write("draft", draft());
|
||||
|
||||
Reference in New Issue
Block a user