Files
uconsole_asw_game/data/commander/js/stations/weapons.js
T
Claude 02f35cf5d9 Give the frigate its own ASROC and depth charges (1.3.63)
Weapons station: A fires one of four ASROC at the designated submarine's
observed position (1-10 NM, fresh range) and drops the helicopter's
lightweight torpedo there; Z drops a five-charge pattern over the stern
(20 in the rack, 45 s reload, at least 10 kn) that sinks to the preset
depth and damages by shock factor. Remote Crew weapons page gets both as
direct-fire actions. Saves are now v29 (asw.depth_charges, own_stores).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGvKG7oVxvDAFoEk15CCFZ
2026-09-29 06:05:16 +00:00

43 lines
2.8 KiB
JavaScript

import { S } from "../state/store.js";
import { $ } from "../core/base.js";
import { number, stateText, unit } from "../core/format.js";
import { fillFireTargets, metrics, position, stationRows, weaponTargetEntries, yesNo } from "../views/dom.js";
function renderTorpedoSettings(settings) {
const typeSelect = $("weapons-torpedo-type");
const wanted = settings.choices.map((row) => `${row.key}|${row.name}|${row.stock}|${row.loaded}`).join("\n");
if (typeSelect.dataset.choices !== wanted) {
typeSelect.replaceChildren(...settings.choices.map((row) => {
const option = document.createElement("option");
option.value = row.key;
option.textContent = `${row.name} \u00b7 ${number(row.stock, 0)} (${number(row.loaded, 0)})`;
return option;
}));
typeSelect.dataset.choices = wanted;
}
if (!S.stationDrafts.has("weapons-torpedo-type")) typeSelect.value = settings.torpedo_type;
if (!S.stationDrafts.has("weapons-pattern")) $("weapons-pattern").value = settings.pattern;
if (!S.stationDrafts.has("weapons-enable")) $("weapons-enable").value = String(settings.enable_nm);
if (!S.stationDrafts.has("weapons-salvo")) $("weapons-salvo").value = String(settings.salvo);
}
export function renderWeaponsStation(payload) {
const inventory = payload.inventory;
metrics($("weapons-inventory"), [["torpedoes", number(inventory.torpedoes, 0)], ["vls", number(inventory.vls, 0)],
["ciws", number(inventory.ciws, 0)], ["aa", number(inventory.aa, 0)], ["chaff", yesNo(inventory.chaff_ready)],
["nixies", number(inventory.nixies, 0)], ["asroc", number(inventory.asroc, 0)],
["depth_charges", number(inventory.depth_charges, 0)]]);
const readiness = payload.readiness;
metrics($("weapons-readiness"), [["station_down", yesNo(readiness.station_down)], ["roe", stateText("roe", readiness.roe)],
["ciws_ready", yesNo(readiness.ciws_ready)], ["aa_ready", yesNo(readiness.aa_ready)],
["state", stateText("battery_state", readiness.state)], ["interlock", readiness.interlock], ["reload", unit(readiness.reload_s, "s", 0)]]);
stationRows($("weapons-target"), payload.designated_target ? [payload.designated_target] : [], weaponTargetEntries, "station_no_target");
stationRows($("weapons-tubes"), payload.tubes, (row) => [["weapons_tube", number(row.tube, 0)],
["state", stateText("tube_state", row.state)], ["reload", unit(row.reload_s, "s", 0)]]);
fillFireTargets("weapons-fire-target", payload.target_choices);
if (!S.stationDrafts.has("weapons-fire-depth")) $("weapons-fire-depth").value = String(payload.depth_m);
renderTorpedoSettings(payload.settings);
stationRows($("weapons-own"), payload.own_weapons, (row) => [["reference", row.ref], ["position", position(row)],
["depth", unit(row.depth_m, "m", 0)], ["course", unit(row.course, "\u00b0", 0)], ["state", stateText("weapon_state", row.state)]]);
}