diff --git a/data/commander/index.html b/data/commander/index.html index a9f46170..50521308 100644 --- a/data/commander/index.html +++ b/data/commander/index.html @@ -188,16 +188,16 @@

diff --git a/data/commander/js/state/schema.js b/data/commander/js/state/schema.js index 881ec090..bac3f4f1 100644 --- a/data/commander/js/state/schema.js +++ b/data/commander/js/state/schema.js @@ -122,8 +122,8 @@ export function validateV2State(state) { const payload = state[state.role]; // BEGIN GENERATED (tools/gen_web_schema.py; do not edit by hand) const shapes = { - bridge: ["navigation", "orders", "threat", "systems", "tactical_summary", "sightings"], - damage: ["compartments", "teams", "total", "sunk", "stability"], + bridge: ["navigation", "orders", "threat", "systems", "tactical_summary", "sightings", "crew"], + damage: ["compartments", "teams", "total", "sunk", "stability", "crew"], eloka: ["intercepts", "station_down", "status", "hardware"], engine: ["propulsion", "machinery", "controls", "environment_effects"], helicopter: ["asset", "waypoint", "buoys", "buoy_observations", "acoustic", "navigation", "tactical", "target_choices", "readiness", "dip_observations", "dip_environment"], @@ -146,6 +146,10 @@ export function validateV2State(state) { kinds: ["sar", "identify", "datum", "ras", "emcon"], states: ["offered", "active", "done", "failed", "declined"], }; + const crewFields = { + row: ["on_watch", "watches", "watch_left_s", "turnover", "action_stations", "morale", "effectiveness"], + watch: ["index", "fatigue", "on_duty"], + }; const helicopterTacticalFields = ["ref", "label", "domain", "source", "affiliation", "bearing", "range_nm", "x", "y", "course", "speed_kn", "altitude_m", "observer_x", "observer_y", "quality", "age_s", "bearing_uncertainty_deg", "range_uncertainty_nm", "visual_class", "visual_type", "classification", "released_to_opz"]; const weatherFields = { atmosphere: ["weather", "precipitation", "rain_intensity", "visibility_nm", "sea_state", "wind_from_deg", "wind_kn", "gust_kn", "beaufort", "pressure_hpa", "pressure_tendency_hpa_3h", "pressure_trend", "storm_warning", "air_temp_c", "sea_temp_c", "cloud_cover", "ceiling_ft", "icing", "sun_elevation_deg", "daylight", "moon_phase", "moon_illumination", "time"], @@ -157,7 +161,7 @@ export function validateV2State(state) { air: ["o2_pct", "co2_pct", "absorber_pct", "absorber_sets", "candles", "candle_left_s", "level", "efficiency"], ballast: ["blowing", "venting", "auto", "pumping", "compressor", "hp_air_bar", "hp_air_max_bar", "blows_left", "mbt_pct", "regulating_kg", "regulating_order_kg", "regulating_capacity_kg", "trim_kg", "trim_order_kg", "trim_capacity_kg", "load_kg", "flooding_kg", "residual_kg", "trim_deg", "drift_mps"], ballastFlags: ["blowing", "venting", "auto", "pumping", "compressor"], - damage: ["power", "pumping", "compartments", "teams"], + damage: ["power", "pumping", "compartments", "teams", "crew"], compartment: ["name", "water_kg", "capacity_kg", "leak_pct", "fire_pct", "chlorine_pct", "closed", "down"], dcTeam: ["team", "compartment", "task", "transit_s"], compartments: ["bow", "control", "quarters", "battery", "engine", "stern"], @@ -184,7 +188,18 @@ export function validateV2State(state) { if (row.altitude_m !== null && (!finite(row.altitude_m) || row.altitude_m < 0 || row.altitude_m > 30000)) throw new Error("protocol"); }); }; + // A crew's watch bill: three watches, fatigue and morale 0..1. + const crewOk = (crew) => exactKeys(crew, crewFields.row) && + Number.isInteger(crew.on_watch) && crew.on_watch >= 1 && crew.on_watch <= 3 && + Array.isArray(crew.watches) && crew.watches.length === 3 && + crew.watches.every((row, index) => exactKeys(row, crewFields.watch) && row.index === index + 1 && + finite(row.fatigue) && row.fatigue >= 0 && row.fatigue <= 1 && typeof row.on_duty === "boolean") && + (crew.watch_left_s === null || (finite(crew.watch_left_s) && crew.watch_left_s >= 0)) && + typeof crew.turnover === "boolean" && typeof crew.action_stations === "boolean" && + finite(crew.morale) && crew.morale >= 0 && crew.morale <= 1 && + finite(crew.effectiveness) && crew.effectiveness > 0 && crew.effectiveness <= 2; if (state.role === "bridge") { + if (!crewOk(payload.crew)) throw new Error("protocol"); if (!exactKeys(payload.navigation, ["x", "y", "course", "speed", "target_course", "target_speed", "rudder_angle", "yaw_rate", "turn_radius_nm"])) throw new Error("protocol"); if (!exactKeys(payload.orders, ["station_down", "speed_max_kn", "telegraph", "noise", "cavitating"]) || typeof payload.orders.station_down !== "boolean" || !finite(payload.orders.speed_max_kn) || @@ -307,7 +322,7 @@ export function validateV2State(state) { !Number.isInteger(ballast.blows_left) || ballast.blows_left < 0) throw new Error("protocol"); // Compartments and damage-control teams: own-ship state, closed vocabulary. const damage = payload.damage_control; - if (!exactKeys(damage, boatFields.damage) || + if (!exactKeys(damage, boatFields.damage) || !crewOk(damage.crew) || typeof damage.power !== "boolean" || typeof damage.pumping !== "boolean" || !Array.isArray(damage.compartments) || damage.compartments.length !== boatFields.compartments.length || damage.compartments.some((row, index) => !exactKeys(row, boatFields.compartment) || @@ -356,7 +371,7 @@ export function validateV2State(state) { tacticalRows(payload.tactical, 128); rowsExact(payload.target_choices, 128, ["ref", "label", "domain", "source", "affiliation", "classification", "bearing", "range_nm", "x", "y", "depth_m", "course", "speed_kn", "quality", "age_s", "fix_age_s", "bearing_uncertainty_deg", "range_uncertainty_nm"]); } else if (state.role === "damage") { - if (!boundedArray(payload.compartments, 16) || payload.compartments.some((row) => !exactKeys(row, ["key", "name", "state", "flood", "fire", "repairable", "trend"]) || typeof row.repairable !== "boolean" || !exactKeys(row.trend, ["flood_rate", "fire_rate", "repairable"])) || + if (!crewOk(payload.crew) || !boundedArray(payload.compartments, 16) || payload.compartments.some((row) => !exactKeys(row, ["key", "name", "state", "flood", "fire", "repairable", "trend"]) || typeof row.repairable !== "boolean" || !exactKeys(row.trend, ["flood_rate", "fire_rate", "repairable"])) || !boundedArray(payload.teams, 16) || payload.teams.some((row) => !exactKeys(row, ["team", "compartment"])) || !exactKeys(payload.stability, ["list_deg", "trim_deg", "counterflood_room", "can_counterflood"]) || typeof payload.stability.can_counterflood !== "boolean") throw new Error("protocol"); diff --git a/data/commander/js/stations/bridge.js b/data/commander/js/stations/bridge.js index da2de180..8ff1f7a6 100644 --- a/data/commander/js/stations/bridge.js +++ b/data/commander/js/stations/bridge.js @@ -4,9 +4,11 @@ import { number, t, unit } from "../core/format.js"; import { sightingText } from "../state/schema.js"; import { metrics, node, position, stationRows, tacticalEntries, yesNo } from "../views/dom.js"; import { DISPLAY_CLOCK_LAG_S, displaySimNow } from "../state/display-clock.js"; +import { renderCrew } from "../views/crew.js"; export function renderBridgeStation(payload) { const navigation = payload.navigation; + renderCrew($("bridge-crew"), $("bridge-crew-actions"), payload.crew, {actionStations: "crew_action_stations"}); metrics($("bridge-navigation"), [["position", position(navigation)], ["course", unit(navigation.course, "\u00b0", 0)], ["speed", unit(navigation.speed, "kn")], ["ordered_course", unit(navigation.target_course, "\u00b0", 0)], ["ordered_speed", unit(navigation.target_speed, "kn")], ["rudder_angle", unit(navigation.rudder_angle, "\u00b0")], diff --git a/data/commander/js/stations/damage.js b/data/commander/js/stations/damage.js index 8ca13f2d..d159b94c 100644 --- a/data/commander/js/stations/damage.js +++ b/data/commander/js/stations/damage.js @@ -1,6 +1,7 @@ import { $, damageStates } from "../core/base.js"; import { enumText, number, t, unit } from "../core/format.js"; import { actionButton, metrics, node, stationRows, yesNo } from "../views/dom.js"; +import { renderCrew } from "../views/crew.js"; function compartmentName(payload, key) { return payload.compartments.find((room) => room.key === key)?.name || key; @@ -8,6 +9,8 @@ function compartmentName(payload, key) { export function renderDamageStation(payload) { metrics($("damage-summary"), [["damage_total", unit(payload.total, "%")], ["sunk", yesNo(payload.sunk)]]); + renderCrew($("damage-crew"), $("damage-crew-actions"), payload.crew, + {actionStations: "crew_action_stations", watchChange: "crew_watch_change"}); const stability = payload.stability; metrics($("damage-stability"), [["damage_list", unit(stability.list_deg, "\u00b0")], ["damage_trim", unit(stability.trim_deg, "\u00b0")], diff --git a/data/commander/js/stations/uboot.js b/data/commander/js/stations/uboot.js index 87415c7d..3ff0d5df 100644 --- a/data/commander/js/stations/uboot.js +++ b/data/commander/js/stations/uboot.js @@ -2,6 +2,7 @@ import { S } from "../state/store.js"; import { $ } from "../core/base.js"; import { duration, number, stateText, t, unit } from "../core/format.js"; import { fillFireTargets, metrics, node, sonarEntries, stationRows, yesNo } from "../views/dom.js"; +import { renderCrew } from "../views/crew.js"; import { drawBoatBallast, drawBoatDamage, drawBoatDepth, drawBoatEsm, drawBoatScope } from "./uboot-graphics.js"; // Alarm age with the boat's own measured bearing (never the source's truth). @@ -193,6 +194,8 @@ function renderDamage(dc) { teams.length ? teams.join(", ") : "\u2013"].map((text) => node("td", text)), switchCell); return line; })); + renderCrew($("uboot-crew"), $("uboot-crew-actions"), dc.crew, + {actionStations: "uboot_action_stations", watchChange: "uboot_watch_change"}); metrics($("uboot-dc-teams"), [["uboot_dc_power", t(dc.power ? "uboot_dc_power_on" : "uboot_dc_power_off")], ...dc.teams.map((team) => [`uboot_dc_team_${team.team + 1}`, team.transit_s > 0 ? t("uboot_dc_team_transit", {compartment: t(`uboot_compartment_${team.compartment}`), seconds: number(team.transit_s, 0)}) diff --git a/data/commander/js/views/crew.js b/data/commander/js/views/crew.js new file mode 100644 index 00000000..60de53b3 --- /dev/null +++ b/data/commander/js/views/crew.js @@ -0,0 +1,20 @@ +// The crew's watch bill, fatigue and morale (frigate bridge/damage, boat +// damage control): metrics plus the two orders the role may give. +import { number, t, unit } from "../core/format.js"; +import { actionButton, metrics } from "./dom.js"; + +export function renderCrew(list, actions, crew, orders) { + const relief = crew.action_stations ? t("crew_no_relief") : crew.turnover ? t("crew_turnover") + : t("crew_relief_in", {minutes: number(Math.floor(crew.watch_left_s / 60), 0)}); + metrics(list, [ + ["crew_state", crew.action_stations ? t("crew_action_stations_on") : t("crew_watch_on", {watch: number(crew.on_watch, 0)})], + ["crew_relief", relief], + ["crew_performance", unit(crew.effectiveness * 100, "%", 0)], + ["crew_morale", unit(crew.morale * 100, "%", 0)], + ...crew.watches.map((row) => [`crew_watch_${row.index}`, + t(row.on_duty ? "crew_fatigue_on_duty" : "crew_fatigue_resting", {fatigue: number(row.fatigue * 100, 0)})])]); + const buttons = [actionButton(crew.action_stations ? "crew_stand_down" : "crew_action_stations", + orders.actionStations, {enabled: !crew.action_stations})]; + if (orders.watchChange) buttons.push(actionButton("crew_relieve", orders.watchChange, {}, !crew.action_stations)); + actions.replaceChildren(...buttons); +} diff --git a/data/i18n/de.json b/data/i18n/de.json index 365742d0..51b26d4c 100644 --- a/data/i18n/de.json +++ b/data/i18n/de.json @@ -4964,5 +4964,59 @@ "commander.web.radio_task_progress": "Fortschritt {progress} %", "commander.web.radio_task_verdict_clear": "HQ: unverdächtig", "commander.web.radio_task_verdict_suspect": "HQ: verdächtig, Datum übermittelt", - "commander.web.radio_task_points": "{points} Punkte" + "commander.web.radio_task_points": "{points} Punkte", + "station.page.damage_crew": "Besatzung", + "panel.crew_watches": "Wachplan", + "panel.crew_state": "Zustand der Besatzung", + "crew.watch_row": "Wache {watch}: {duty}, Ermüdung {fatigue}", + "crew.on_duty": "im Dienst", + "crew.off_duty": "in Ruhe", + "crew.explain": "Die Wache im Dienst ermüdet, die anderen ruhen. Die Wache wird stündlich abgelöst (W löst früher ab). Gefechtsstationen (G) holen alle Wachen in den Dienst: 10 % aufmerksamer, aber niemand ruht, und Ermüdung über 25 % kostet Leistung. Die Moral steigt mit Erfolgen und sinkt mit Schäden und gescheiterten Aufträgen.", + "crew.state.watch": "Wache {watch} im Dienst", + "crew.state.action_stations": "GEFECHTSSTATIONEN: alle Wachen im Dienst", + "crew.relief.in": "Ablösung in {minutes}:{seconds}", + "crew.relief.turnover": "Wachübergabe läuft", + "crew.relief.action_stations": "Keine Ablösung auf Gefechtsstationen", + "crew.effectiveness": "Leistung {value}", + "crew.morale": "Moral {value}", + "crew.effect.sonar": "Sonar-Erkennungsschwelle {db} dB", + "crew.effect.repair": "Tempo Leckwehr und Ausguck {value}", + "crew.action_stations_on": "Gefechtsstationen! Alle Wachen auf Station.", + "crew.action_stations_off": "Gefechtsstationen aufgehoben; die frischeste Wache übernimmt.", + "crew.watch_relieved": "Wache {watch} hat die Wache übernommen.", + "crew.watch_blocked": "Kein Wachwechsel auf Gefechtsstationen.", + "damage.footer.watch": "WACHWECHSEL", + "damage.footer.action_stations": "GEFECHTSSTATIONEN", + "help.control.watch_change": "Wache jetzt ablösen (Seite Besatzung)", + "help.control.action_stations": "Gefechtsstationen an/aus", + "help.note.crew": "Besatzung: drei Wachen wechseln stündlich. Gefechtsstationen machen die Besatzung 10 % aufmerksamer, ermüden aber alle; eine müde Besatzung hört am Sonar später, sichtet später und repariert langsamer. Siehe Schadensabwehr Seite 3.", + "telemetry.crew": "Besatzung", + "telemetry.crew.short": "BES", + "telemetry.value.crew": "{value} · Moral {morale} %", + "telemetry.value.crew_action": "GEF {value} %", + "uboot.dc.label.crew": "Besatzung", + "uboot.dc.crew": "{state} · {effect}% · Ermüdung {fatigue}% · Moral {morale}%", + "uboot.dc.crew_watch": "Wache {watch}", + "uboot.dc.crew_action": "GEFECHTSSTATIONEN", + "uboot.footer.watch": "ABLÖSEN", + "help.uboot.watch_change": "Maschine, Seite Leckwehr: Wache jetzt ablösen", + "help.uboot.action_stations": "Gefechtsstationen an/aus (alle Wachen im Dienst, aufmerksam, aber ermüdend)", + "commander.web.crew_title": "Besatzung", + "commander.web.crew_state": "Wache", + "commander.web.crew_relief": "Ablösung", + "commander.web.crew_performance": "Leistung", + "commander.web.crew_morale": "Moral", + "commander.web.crew_watch_1": "Wache 1", + "commander.web.crew_watch_2": "Wache 2", + "commander.web.crew_watch_3": "Wache 3", + "commander.web.crew_watch_on": "Wache {watch} im Dienst", + "commander.web.crew_action_stations_on": "Gefechtsstationen", + "commander.web.crew_no_relief": "keine auf Gefechtsstationen", + "commander.web.crew_turnover": "Übergabe läuft", + "commander.web.crew_relief_in": "in {minutes} min", + "commander.web.crew_fatigue_on_duty": "im Dienst, Ermüdung {fatigue} %", + "commander.web.crew_fatigue_resting": "in Ruhe, Ermüdung {fatigue} %", + "commander.web.crew_action_stations": "Gefechtsstationen", + "commander.web.crew_stand_down": "Gefechtsstationen aufheben", + "commander.web.crew_relieve": "Wache ablösen" } diff --git a/data/i18n/en.json b/data/i18n/en.json index ac8eccfc..080d3297 100644 --- a/data/i18n/en.json +++ b/data/i18n/en.json @@ -4964,5 +4964,59 @@ "commander.web.radio_task_progress": "progress {progress} %", "commander.web.radio_task_verdict_clear": "HQ: harmless", "commander.web.radio_task_verdict_suspect": "HQ: suspect, datum passed on", - "commander.web.radio_task_points": "{points} points" + "commander.web.radio_task_points": "{points} points", + "station.page.damage_crew": "Crew", + "panel.crew_watches": "Watch bill", + "panel.crew_state": "Crew state", + "crew.watch_row": "Watch {watch}: {duty}, fatigue {fatigue}", + "crew.on_duty": "on duty", + "crew.off_duty": "resting", + "crew.explain": "The duty watch tires, the others rest. The watch is relieved every hour (W relieves it early). Action stations (G) put every watch on duty: 10 % more alert, but nobody rests and fatigue above 25 % costs performance. Morale rises with successes and falls with damage and failed tasks.", + "crew.state.watch": "Watch {watch} on duty", + "crew.state.action_stations": "ACTION STATIONS: all watches on duty", + "crew.relief.in": "Relief in {minutes}:{seconds}", + "crew.relief.turnover": "Watch turnover: settling in", + "crew.relief.action_stations": "No relief at action stations", + "crew.effectiveness": "Performance {value}", + "crew.morale": "Morale {value}", + "crew.effect.sonar": "Sonar recognition threshold {db} dB", + "crew.effect.repair": "Repair and lookout pace {value}", + "crew.action_stations_on": "Action stations! All watches closed up.", + "crew.action_stations_off": "Stand down from action stations; the freshest watch keeps the watch.", + "crew.watch_relieved": "Watch {watch} has the watch.", + "crew.watch_blocked": "No watch change at action stations.", + "damage.footer.watch": "RELIEVE WATCH", + "damage.footer.action_stations": "ACTION STATIONS", + "help.control.watch_change": "Relieve the duty watch now (Crew page)", + "help.control.action_stations": "Action stations on/off", + "help.note.crew": "Crew: three watches rotate every hour. Action stations make the crew 10 % more alert but tire everybody; a tired crew hears later on sonar, sights later and repairs more slowly. See Damage page 3.", + "telemetry.crew": "Crew", + "telemetry.crew.short": "CREW", + "telemetry.value.crew": "{value} · morale {morale} %", + "telemetry.value.crew_action": "GQ {value} %", + "uboot.dc.label.crew": "Crew", + "uboot.dc.crew": "{state} · {effect}% · fatigue {fatigue}% · morale {morale}%", + "uboot.dc.crew_watch": "watch {watch}", + "uboot.dc.crew_action": "ACTION STATIONS", + "uboot.footer.watch": "RELIEVE", + "help.uboot.watch_change": "Engine room, damage page: relieve the duty watch now", + "help.uboot.action_stations": "Action stations on/off (all watches on duty, alert but tiring)", + "commander.web.crew_title": "Crew", + "commander.web.crew_state": "Watch", + "commander.web.crew_relief": "Relief", + "commander.web.crew_performance": "Performance", + "commander.web.crew_morale": "Morale", + "commander.web.crew_watch_1": "Watch 1", + "commander.web.crew_watch_2": "Watch 2", + "commander.web.crew_watch_3": "Watch 3", + "commander.web.crew_watch_on": "Watch {watch} on duty", + "commander.web.crew_action_stations_on": "Action stations", + "commander.web.crew_no_relief": "none at action stations", + "commander.web.crew_turnover": "turnover", + "commander.web.crew_relief_in": "in {minutes} min", + "commander.web.crew_fatigue_on_duty": "on duty, fatigue {fatigue} %", + "commander.web.crew_fatigue_resting": "resting, fatigue {fatigue} %", + "commander.web.crew_action_stations": "Action stations", + "commander.web.crew_stand_down": "Stand down", + "commander.web.crew_relieve": "Relieve watch" } diff --git a/data/manual/04-damage.de.md b/data/manual/04-damage.de.md index 72c50bba..01dfaa57 100644 --- a/data/manual/04-damage.de.md +++ b/data/manual/04-damage.de.md @@ -6,7 +6,7 @@ Die Schadensabwehr hält das Schiff nach einem Treffer schwimmfähig und die Sta ## Anzeigen und Instrumente {#damage-displays} -Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Tendenz, Trupps vor Ort, Krängung). +Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Tendenz, Trupps vor Ort, Krängung); Seite 3 ist der Wachplan der Besatzung. ```text Bug Heck @@ -31,6 +31,16 @@ Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Auswirkungen auf Stationen: eine Station verliert mit Flutung und Brand in ihrem Raum stufenlos an Leistung (Sonar- und Radarreichweite sinken allmählich); ein zerstörter Raum legt sie lahm. Eine beschädigte Maschine begrenzt die Fahrt auf 15 kn, eine zerstörte auf 8 kn; eine beschädigte oder zerstörte Waffenzentrale sperrt Torpedostarts; ein zerstörtes Flugdeck verhindert Start und Landung des Helikopters; eine zerstörte OPZ legt auch ESM lahm. +## Besatzung und Wachen {#damage-crew} + +Seite 3 (Besatzung) zeigt den Wachplan. Die Besatzung geht in drei Wachen: eine ist im Dienst und ermüdet, die beiden anderen ruhen und erholen sich. Die Wache im Dienst wird jede Spielstunde automatisch abgelöst (eine echte Wache dauert vier Stunden; das Spiel verkürzt sie, damit eine Partie den Wechsel erlebt) oder früher mit `W` auf dieser Seite. In der ersten Minute nach der Ablösung arbeitet sich die neue Wache ein und bringt 85 %. + +- **Ermüdung** (0 bis 100 % je Wache) steigt in einer normalen Stunde im Dienst um etwa 25 % und sinkt in der Ruhe wieder. Bis 25 % kostet sie nichts, normaler Wachwechsel hält die Besatzung also bei voller Leistung. Darüber kosten je 10 % Ermüdung 6 % Leistung. +- **Gefechtsstationen** (`G` hier oder auf der Brücke) holen alle Wachen in den Dienst: die Besatzung ist 10 % aufmerksamer, aber niemand ruht, und alle sind in 90 Minuten von frisch bis erschöpft, schneller bei Brand- oder Leckbekämpfung. Auf Gefechtsstationen gibt es keine Ablösung; beim Aufheben übernimmt die frischeste Wache. Für einen Angriff auf Station gehen und danach aufheben: nach etwa einer halben Stunde auf Gefechtsstationen ist der Vorteil aufgebraucht. +- **Moral** beginnt bei 70 %. Ein versenktes U-Boot (+15), eine Rettung (+12) oder ein anderer erfüllter Auftrag (+6) heben sie; eine beschädigte Abteilung (-6), ein gescheiterter (-8) oder abgelehnter Auftrag (-2) senken sie; eine reparierte Abteilung bringt +2. Niedrige Moral ermüdet schneller; je 10 % Moral ändern die Leistung um 2 %. +- **Leistung** ist, was die Besatzung bringt: der Sonarbediener braucht ein stärkeres Signal (je 10 % Verlust hebt die Erkennungsschwelle um 1 dB, die Passivreichweiten sinken), der Ausguck braucht mehr Kontrast zum Sichten, Erkennen und Identifizieren, und die Reparaturtrupps dichten, lenzen und löschen in diesem Tempo. Seite 3 zeigt die aktuellen Werte; der Statusticker zeigt `BES` mit der Leistung oder `GEF` auf Gefechtsstationen. +- Das besetzte Gegner-U-Boot hat einen eigenen Wachplan mit denselben Regeln (siehe Kapitel Referenz). + ## Tasten {#damage-keys} @@ -50,5 +60,5 @@ Auf der uConsole weisen die Joystick-Tasten 1-3 Trupp 1-3 direkt der gewählten ## Nicht modelliert {#damage-limits} -- Keine einzelnen Besatzungsmitglieder oder Verwundeten. +- Keine einzelnen Besatzungsmitglieder, Verwundeten oder Schlaf nach der Uhr; Wachen werden jede Spielstunde abgelöst. - Gegenfluten nur zwischen den beiden Rumpfseiten; kein gezieltes Fluten anderer Räume. diff --git a/data/manual/04-damage.en.md b/data/manual/04-damage.en.md index fb9a9a11..ba8ec2bc 100644 --- a/data/manual/04-damage.en.md +++ b/data/manual/04-damage.en.md @@ -6,7 +6,7 @@ Damage control keeps the ship afloat and the stations working after a hit. Three ## Displays and instruments {#damage-displays} -Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fire, trend, teams on scene, heel). +Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fire, trend, teams on scene, heel); page 3 is the crew's watch bill. ```text bow stern @@ -31,6 +31,16 @@ Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fi Station effects: a station loses capability continuously with flooding and fire in its room (sonar and radar range shrink gradually); a destroyed room disables it. A damaged engine room caps speed at 15 kn, a destroyed one at 8 kn; a damaged or destroyed weapons room blocks torpedo launches; a destroyed flight deck prevents helicopter launch and recovery; a destroyed operations room also disables ESM. +## Crew and watches {#damage-crew} + +Page 3 (Crew) shows the watch bill. The ship's company stands in three watches: one is on duty and tires, the other two rest and recover. The duty watch is relieved automatically every hour of game time (a real watch is four hours; the game compresses it so a session sees the rotation), or earlier with `W` on this page. For the first minute after a relief the new watch settles in and works at 85 %. + +- **Fatigue** (0 to 100 % per watch) rises by about 25 % in a normal hour on duty and falls again at rest. Up to 25 % it costs nothing, so normal rotation keeps the crew at full performance. Above it, every 10 % costs 6 % performance. +- **Action stations** (`G` here or on the Bridge) put every watch on duty: the crew is 10 % more alert, but nobody rests and everybody tires in 90 minutes from fresh to exhausted, faster while fighting fire or flooding. There is no relief at action stations; standing down hands the watch to the freshest section. Stand to for an attack and stand down afterwards: after about half an hour at action stations the bonus is used up. +- **Morale** starts at 70 %. A sunk submarine (+15), a rescue (+12) or another task done (+6) raise it; a compartment damaged (-6), a task failed (-8) or declined (-2) lower it; a repaired compartment gives +2. Low morale tires the crew faster; each 10 % of morale changes performance by 2 %. +- **Performance** is what the crew delivers: the sonar operator needs a stronger signal (every 10 % lost raises the recognition threshold by 1 dB, so the passive ranges shrink), the lookout needs more contrast to sight, recognize and identify, and the repair teams patch, pump and fight fire at that pace. Page 3 lists the current values; the status ticker shows `CREW` with the performance, or `GQ` at action stations. +- The crewed opposing submarine has its own watch bill with the same rules (see the reference chapter). + ## Keys {#damage-keys} @@ -50,5 +60,5 @@ On the uConsole the joystick buttons 1-3 assign team 1-3 directly to the selecte ## Not modelled {#damage-limits} -- No individual crew members or casualties. +- No individual crew members, casualties or sleep by the clock; watches are relieved every hour of game time. - Counter-flooding only between the two hull sides; no selective flooding of other rooms. diff --git a/data/manual/10-reference.de.md b/data/manual/10-reference.de.md index 09847460..6596f729 100644 --- a/data/manual/10-reference.de.md +++ b/data/manual/10-reference.de.md @@ -110,6 +110,7 @@ Eine zweite Crew kann den Gegner spielen. Das Boot hat sechs Stationen: Führung - **Energie und Vorräte:** die Maschine zeigt unter **Energie & Vorräte** (Karte im Browser, auf der uConsole Maschine Seite 2 **Vorräte**) die Energiebilanz bei der aktuellen Fahrt (Verbrauch, Erzeugung und Bilanz in kW, die Zeit bis die Batterie leer oder voll ist), Batterie und AIP-Sauerstoff, die Dieselbunker und eine Tabelle, wie lange die Batterie getaucht bei jeder Telegrafenstufe reicht und wie weit das Boot damit kommt. **Diesel:** die Bunker fassen 300 Stunden volle Generatorleistung, eine Fahrt beginnt mit 65 %; nur laufende Diesel verbrauchen (0,27 l je kWh), das Log warnt bei 10 %, und mit leeren Bunkern lädt Schnorcheln nicht mehr. Die **Laderate** bestimmt, was Schnorcheln tut: *voll* (die ganze Generatorleistung, +12 dB und beide Diesellinien), *halb* (die halbe Leistung, +9 dB, schwächere Linien) oder *nur lüften* (die Lüfter ohne Diesel, +4 dB, keine Linien). **Luft:** getaucht verbraucht die Crew Sauerstoff und atmet Kohlendioxid aus (je etwa 0,45 % pro Stunde); ein CO2-Absorbersatz nimmt CO2 auf, bis er verbraucht ist (8 Ersatzsätze), eine O2-Kerze setzt in 15 Minuten 1 % O2 zu (12 an Bord, eine zur Zeit), und Schnorcheln lüftet das Boot in wenigen Minuten Richtung Frischluft. Ab 3 % CO2 oder unter 18 % O2 ist die Luft verbraucht, ab 5 % CO2 oder unter 16 % O2 gefährlich; das Log warnt bei jeder Stufe. Schlechte Luft macht die Crew langsamer (bis 30 % Leistung), und die Torpedomannschaft lädt entsprechend langsamer nach. KI-Boote versorgen ihre Luft selbst und tauchen zum Lüften auf, wenn sie gefährlich wird. Ein Atom-U-Boot hat keine dieser Vorräte. - **Tauchzellen, Trimm und Pressluft:** die Maschine zeigt unter **Tauchzellen & Trimm** (Karte im Browser mit Schnittbild des Boots, auf der uConsole Maschine Seite 3 **Zellen**) die Hauptzellen, die Regelzelle, die Trimmzellen, die Pressluft und den Trimmzustand des Boots. Jede Gewichtsänderung bringt das Boot aus dem Gleichgewicht: ein Torpedo aus einem Bugrohr macht es 1,5 t leichter und achterlastig, Wasser in vollgelaufenen Abteilungen (siehe Leckwehr) macht es schwerer und trimmt es zum gefluteten Ende; die Trimmautomatik gleicht davon aus, was ihre Zellen fassen. Mit der **Trimmautomatik** pumpt der LI die Regelzelle (±8 t, 25 kg/s) und die Trimmzellen (±3 t vorn und achtern, 15 kg/s) zurück ins Gleichgewicht; von Hand verschiebt jeder Befehl die Regelzelle um 0,5 t oder das Trimmwasser um 0,25 t (und schaltet die Automatik aus). Laufende Trimmpumpen sind hörbar (+3 dB und eine Linie bei 120 Hz). Was die Zellen nicht aufnehmen, lässt das Boot mit 0,03 m/s je Tonne sinken oder steigen, und ein Trimmwinkel (1° je Tonne Moment, + vorlastig) drückt es mit Fahrt nach unten oder oben; die Tiefenruder halten das nur mit Fahrt, ein schweres Boot sinkt bei wenig Fahrt unter seine befohlene Tiefe; das Log warnt ab 2 t und ab 3°. Die **Pressluft** (200 bar) reicht für drei Notanblasungen zu je 60 bar; Anblasen leert die Hauptzellen in 20 s, das Boot steigt auf 10 m und bleibt dort, die befohlene Tiefe steht dann auf 10 m. Der nächste Befehl unter 12 m öffnet die Entlüftung: die Hauptzellen fluten in 40 s, erst dann kann das Boot tauchen. Schnorcheln auf Diesel betreibt den Kompressor (0,05 bar/s); mit nur lüften läuft er nicht. Ohne Strom laufen weder Trimmpumpen noch Kompressor. Die KI-Boote halten sich selbst im Trimm und behalten ihr eines Notanblasen. - **Leckwehr:** die Maschine zeigt unter **Leckwehr** (Karte im Browser mit den Abteilungen und einer Tabelle, auf der uConsole Maschine Seite 4 **Leckwehr**) den Druckkörper in sechs Abteilungen: Bugraum, Zentrale, Wohnraum, Batterieraum, Maschinenraum und Heckraum. Ein Treffer auf das besetzte Boot schlägt ein Leck in die getroffene Abteilung (1,5 % Leck je % Trefferschaden, höchstens ein volles Leck; ab 50 % Schaden auch in die Nachbarabteilung mit halbem Leck) und kann dort einen Brand auslösen (Wahrscheinlichkeit = Schaden / 150); ein Ermüdungsriss unter der Testtiefe öffnet ein kleines Leck. Durch ein volles Leck dringen in 100 m Tiefe 40 kg/s ein, mit der Wurzel der Tiefe mehr; über halbvoll läuft das Wasser in offene Nachbarabteilungen über (20 kg/s) und erstickt einen Brand. Ein Brand wächst in 2 min zum Vollbrand und greift dann durch offene Schotten über; Seewasser im Batterieraum (ab 2 t) setzt Chlorgas frei, das durch offene Schotten zieht und erst langsam abzieht, wenn die Batterie trocken ist. Wasser im Batterieraum (ab 5 t) oder ein Brand dort legen den **Strom** lahm: der Motor steht (keine Fahrt, also halten die Tiefenruder ein schweres Boot nicht), Trimmpumpen, Kompressor und elektrische Lenzpumpen stehen still. **Schotten schließen** hält Wasser, Brand und Gas in der Abteilung und erstickt einen Brand dort in 3 min. Zwei **Leckwehrtrupps** gehen durchs Boot (8 s je Abteilung) und **dichten ein Leck ab** (ein volles in 60 s), **lenzen** (30 kg/s, ohne Strom ein Viertel von Hand) oder **löschen einen Brand** (einen Vollbrand in 60 s); im Gas arbeiten sie halb so schnell, und in einer zu 90 % vollen Abteilung können sie nur lenzen. Eine Abteilung, die zur Hälfte voll Wasser ist, halb brennt oder halb vergast ist, legt ihre Station lahm: der Bugraum die Torpedorohre, die Zentrale Mast und Sehrohr, der Maschinenraum die Diesel, der Heckraum die halbe Höchstfahrt. Das Wasser ist Gewicht und Moment für den Trimm (siehe oben); ein Boot, das unter die 1,5-fache Testtiefe sinkt, wird zerdrückt. Das Log meldet Lecks, Brände, abgedichtete Lecks, gelöschte Brände, vollgelaufene Abteilungen, Chlorgas und den Strom. +- **Besatzung:** das Boot hat einen eigenen Wachplan mit den Regeln der Fregatte (siehe Schadensabwehr, Besatzung und Wachen): drei Wachen, Ermüdung, Gefechtsstationen und Moral. Maschine und Führung befehlen Gefechtsstationen (`B` auf der uConsole, eine Taste in der Leckwehr-Karte im Browser) und lösen die Wache ab (`M` auf der Seite Leckwehr oder die Taste). Die Moral steigt, wenn ein Schiff sinkt, und sinkt mit je 10 % Rumpfschaden. Eine müde Besatzung hört am Sonar später, sichtet durch das Sehrohr später und ihre Leckwehrtrupps dichten und löschen langsamer (die Pumpen sind Maschinen und behalten ihre Leistung). - **Lagebild:** ein gehörter Aktivping oder Torpedo wird mit der Peilung protokolliert, die das Boot selbst gemessen hat (einige Grad ungenau), und mit seinem Alter in den Alarmen angezeigt. Auf Sehrohrtiefe lässt sich der **Mast** ausfahren; sein ESM meldet dann die Radare, die das Boot überstreichen, mit Peilung (Log und ESM-Liste), und beim Tieferkommen fährt der Mast selbst ein. Mit ausgefahrenem Mast zeigt die Seite **Sehrohr** (Führung Seite 3, Mast & ESM Seite 2; `P` fährt an beiden den Mast aus) das Okular: Himmel und See im Licht der Stunde, den mit der See bewegten Horizont, eine Skala rechtweisender Peilungen und ein Fadenkreuz; das Rohr schwenkt in 2°-Schritten (`←`/`→`, `Umschalt`: 10°). Alles, was die Optik im Kontrastmodell des Fregattenausgucks bei 2,5 m Augenhöhe ausmacht (Tag/Nacht, Mond, Sicht, Seegang, Land im Weg), erscheint als Silhouette und als reine Peilungs-**Sichtung** mit grober Klasse (Kriegsschiff, Handelsschiff, Fahrzeug, Luftfahrzeug, Torpedolaufbahn) und scheinbarer Länge; das Log meldet jede neue Sichtung. `Enter` liest das **Stadimeter** an der Sichtung unter dem Fadenkreuz ab: die Entfernung folgt aus der scheinbaren Länge und der angenommenen Rumpflänge der Klasse (130 m für ein Kriegsschiff oder ein nicht erkanntes Fahrzeug, 150 m für ein Handelsschiff), ein nicht erkanntes oder bugwärts stehendes Ziel misst sich also zu weit; die Ablesung ist ±25 % und wird für 120 s zu einem VISUAL-Fix am Sonarkontakt des Boots auf dieses Ziel, für einen Schuss nutzbar wie ein Ping-Fix. Luftfahrzeuge und Laufbahnen lassen sich nicht messen. Die kartierte Küste steht auf dem Horizont des Sehrohrs, so weit seine niedrige Optik Land sieht (Hügel mit 25 bis 70 m angenommen). Die Führung kann auch ohne Sonarbediener pingen und eine BT-Messung nehmen. Die Karte zeigt das Schussfeld der Rohre, wo sie nicht rundum schießen, und das vom Sonar zugewiesene Ziel ist für den Schuss vorausgewählt. - **Mast & ESM:** mit ausgefahrenem Mast auf Sehrohrtiefe hört die ESM-Antenne des Boots (3 m über Wasser) einmal pro Sekunde die Radare ringsum: das der Fregatte, anderer Schiffe und von Flugzeugen innerhalb des Radarhorizonts, über Land nur, wo die Küste die Linie nicht verdeckt. Jede Erfassung trägt die gemessene Peilung (±4°), Band, Trägerfrequenz, PRF, Modulation und Empfangspegel, nie die Identität oder Position des Senders. Die Crew führt eine **Emitterliste** (`E1`, `E2` …) über mehrere Mastperioden: eine Erfassung gehört zu einem Emitter, wenn Peilung, Band und Signalform passen (ein frequenzagiles Radar nur nach Peilung und Band), und die Liste vergisst einen Emitter 30 Minuten nach seiner letzten Erfassung. Die **Einstufung** ist die Annotation der Crew aus der Bibliothek: die Emitter, deren veröffentlichte Frequenz- und PRF-Bereiche die Messung enthalten, ungewichtet, wie an der ELOKA der Fregatte ohne Assistenz; die Wahl legt die Leistungsklasse für die **Entfernungsschätzung** aus dem Pegel fest (ohne Einstufung die kürzeste Entfernung, die die Bibliothek zulässt). Alle 30 s behält jeder Emitter eine **Peilung** von der eigenen Position des Boots (20 Minuten); die Karte zeigt die letzten Peillinien, und sobald die eigene Fahrt die Peilung um mindestens 8° gedreht hat, ist die **Kreuzpeilung** ihr bester Schnittpunkt mit einer 95-%-Fehlerellipse, die einen seit jeder Linie bis zu 8 kn versetzten Sender einrechnet (eine schnelle Fregatte ergibt meist keine; eine Kreuzpeilung, deren Linien nicht zusammenpassen, wird markiert). Der **Stärketrend** zeigt steigend, gleichbleibend oder fallend über fünf Minuten. Die **Mastwarnung** („Radar kann Mast sehen“) kommt, wenn die geschätzte Entfernung eines erfassten Suchradars innerhalb der Entfernung liegt, auf der ein Seeraumradar bei diesem Seegang und Regen einen ausgefahrenen Mast sieht (der Wert der Wetterseite); die **empfohlene Mastzeit** ist 60 s bei ruhiger See, bis zu 300 s, wenn die Seegangsechos den Mast verbergen, und 20 s unter dieser Warnung, und das Log meldet, wenn sie überschritten ist. Ab Seegang 3 überspülen Wellen die Antenne, und manche Durchläufe hören nichts. Die Karte Mast & ESM im Browser hat die Rose, die Emittertabelle und die Auswertung des gewählten Emitters; **In den Plot übernehmen** trägt die Kreuzpeilung (Markierung und Fehlerkreis) oder sonst die letzte Peillinie in den Plot des Boots ein. Auf der Seite Mast & ESM der uConsole wählen `↑`/`↓` einen Emitter, `←`/`→` schalten seine Einstufung aus der Bibliothek weiter und `Enter` übernimmt ihn in den Plot. - **Navigation und Plot:** die Maschine hat Maschinentelegrafen-Knöpfe, und Führung und Navigation teilen den eigenen Fettstift-Plot des Boots (Markierungen, Lineale, Peillinien, Kreise, Koppellinien); die Fregatte sieht ihn nie, und der Plot des Boots wird nicht gespeichert. Die Navigation zeigt das Wasser unter dem Kiel und prüft die Seekarte entlang des Sollkurses bis 5 sm: Land oder ein Grund flacher als das Boot wird als Hindernis voraus gemeldet, im Log und als Warnung. Es zählt nur die kartierte Geografie; andere Fahrzeuge sind nicht Teil der Prüfung. diff --git a/data/manual/10-reference.en.md b/data/manual/10-reference.en.md index 0c4ae914..3f9dadfc 100644 --- a/data/manual/10-reference.en.md +++ b/data/manual/10-reference.en.md @@ -110,6 +110,7 @@ A second crew can play the enemy. The boat has six stations: Command, Sonar, Wea - **Energy and stores:** the engine room's **Energy & stores** (browser card, uConsole Engine room page 2 **Stores**) shows the energy balance at the present speed (load, supply and net kW, the time until the battery is empty or full), the battery and AIP oxygen, the diesel bunkers and a table of how long the battery lasts dived at each telegraph step and how far that carries the boat. **Diesel:** the bunkers hold 300 hours of the generators' full output and a patrol starts with 65 %; only the running diesels burn it (0.27 l per kWh), the log warns at 10 %, and with dry bunkers snorkelling no longer charges. The **charge rate** sets what snorkelling does: *full* (the whole generator output, +12 dB and both diesel lines), *half* (half the output, +9 dB, weaker lines) or *air only* (the fans without diesels, +4 dB, no lines). **Air:** dived, the crew uses oxygen and breathes out carbon dioxide (about 0.45 % per hour each); a CO2 absorber set takes CO2 out until it is spent (8 spare sets), an oxygen candle adds 1 % O2 over 15 minutes (12 aboard, one at a time), and snorkelling flushes the boat toward fresh air within minutes. From 3 % CO2 or below 18 % O2 the air is stale, from 5 % CO2 or below 16 % O2 it is foul; the log warns at each step. Stale air slows the crew (down to 30 % performance), and the torpedo gang reloads accordingly slower. AI boats manage their air by themselves and come up to air the boat when it turns foul. A nuclear boat has none of these stores. - **Tanks, trim and air:** the engine room's **Tanks & trim** (browser card with a cross-section of the boat, uConsole Engine room page 3 **Tanks**) shows the main ballast, the regulating tank, the trim tanks, the high-pressure air and the trim the boat is in. Every weight change moves the boat off neutral: a torpedo leaving a bow tube makes it 1.5 t lighter and bow light, water in flooded compartments (see damage control) makes it heavier and trims it toward the flooded end; the automatic trim takes up what its tanks can of that weight and moment. With the **automatic trim** on, the engineer pumps the regulating tank (±8 t, 25 kg/s) and the trim tanks (±3 t fore and aft, 15 kg/s) back to neutral; by hand, each order moves the regulating tank 0.5 t or the trim water 0.25 t (and switches the automatic off). Running trim pumps are audible (+3 dB and a 120 Hz line). Whatever the tanks cannot take up sinks or lifts the boat by 0.03 m/s per tonne, and a trim angle (1° per tonne of moment, + bow down) drives it down or up with speed; the hydroplanes hold that only with way on, so a heavy boat hovering at low speed sinks below its ordered depth; the log warns from 2 t and from 3°. The **high-pressure air** (200 bar) holds three emergency blows of 60 bar each; a blow empties the main ballast in 20 s and the boat rises to 10 m and stays there, the ordered depth reset to 10 m. The next order below 12 m opens the vents: the main ballast floods in 40 s before the boat can dive. Snorkelling on the diesels runs the compressor (0.05 bar/s); with the air only on the fans it does not. Without power neither the trim pumps nor the compressor run. The AI's boats keep themselves trimmed and keep their one legacy blow. - **Damage control:** the engine room's **Damage control** (browser card with the compartments and a table, uConsole Engine room page 4 **Damage**) divides the pressure hull into six compartments: bow room, control room, quarters, battery room, engine room and stern room. A hit on the crewed boat holes the compartment it strikes (a leak of 1.5 % per % of hit damage, up to a full hole; from 50 % damage the neighbour too, with half the leak) and may start a fire there (chance = damage / 150); a fatigue crack below test depth opens a small leak. Water comes in at 40 kg/s through a full hole at 100 m, growing with the square root of depth; above half a compartment it spills into open neighbours (20 kg/s) and smothers a fire. A fire grows to full in 2 min and then spreads through open bulkheads; seawater in the battery room (from 2 t) gives off chlorine gas that drifts through open bulkheads and clears slowly once the battery is dry. Water in the battery room (from 5 t) or a fire there cuts the **power**: the motor stops (no way on, so the hydroplanes do not hold a heavy boat), and the trim pumps, compressor and electric bilge pumps stand still. **Shutting the bulkheads** of a compartment keeps water, fire and gas in it and starves a fire there in 3 min. Two **damage-control teams** walk the boat (8 s per compartment) and **seal a leak** (a full hole in 60 s), **pump out** (30 kg/s, a quarter by hand without power) or **fight a fire** (a full fire in 60 s); in gas they work at half rate, and in a compartment 90 % full they can only pump. A compartment half full of water, half on fire or half gassed takes its station out: the bow room the torpedo tubes, the control room the mast and periscope, the engine room the diesels, the stern room half the top speed. The floodwater is weight and moment for the trim (see above); a boat that sinks below 1.5 x test depth is crushed. The log reports leaks, fires, sealed leaks, fires out, flooded compartments, chlorine and power. +- **Crew:** the boat has its own watch bill with the frigate's rules (see Damage control, Crew and watches): three watches, fatigue, action stations and morale. The Engine room and Command order action stations (`B` on the uConsole, a button in the browser's Damage control card) and relieve the watch (`M` on the Damage page, or the button). Morale rises when a ship sinks and falls with every 10 % of hull damage. A tired crew hears later on sonar, sights later through the periscope and its damage-control teams seal and fight fire more slowly (the pumps are machinery and keep their rate). - **Situation picture:** an intercepted active ping or torpedo is logged with the bearing the boat's own ears measured (a few degrees off) and shown with its age in the alarms. At periscope depth the **mast** can be raised; its ESM then reports the radars sweeping the boat with bearing (log and ESM list), and the mast lowers by itself when the boat goes deeper. With the mast up the **periscope** page (Command page 3, Mast & ESM page 2; `P` raises the mast at both) shows the eyepiece: sky and sea in the light of the hour, the horizon moving with the sea, a true-bearing scale and a crosshair; the scope trains in 2° steps (`←`/`→`, `Shift`: 10°). Everything the optics make out within the frigate lookout's contrast model at 2.5 m eye height (day/night, moon, visibility, sea state, land in the way) appears as a silhouette and as a bearing-only **sighting** with a coarse class (warship, merchant ship, vessel, aircraft, torpedo wake) and its apparent length; the log reports each new sighting. `Enter` reads the **stadimeter** on the sighting under the crosshair: the range follows from its apparent length and the assumed hull length of the class (130 m for a warship or an unrecognized vessel, 150 m for a merchant), so an unrecognized or bow-on target reads long; the reading is ±25 % and becomes a VISUAL fix on the boat's sonar contact of that target for 120 s, usable for a shot like a ping fix. Aircraft and wakes cannot be ranged. The charted coast stands on the periscope's horizon as far as its low optics see land (hills assumed 25 to 70 m). Command can also ping and take a BT without a sonar operator. The chart shows the tube firing arc where the tubes cannot fire all round, and the sonar room's assigned target is preselected for the shot. - **Mast & ESM:** with the mast up at periscope depth the boat's own ESM antenna (3 m above the water) hears the radars around it once a second: the frigate's, other ships' and aircraft radars inside the radar horizon, over land only where the coast does not block the line. Each intercept carries the measured bearing (±4°), band, carrier frequency, PRF, modulation and received level, never the emitter's identity or position. The crew keeps an **emitter list** (`E1`, `E2` …) across mast periods: an intercept joins an emitter when bearing, band and waveform agree (a frequency-agile radar by bearing and band only), and the list forgets an emitter 30 minutes after its last intercept. **Classification** is the crew's annotation from the library: the emitters whose published frequency and PRF ranges hold the measurement, unranked, as at the frigate's ELOKA without assistance; the choice sets the power class for the **range estimate** from the level (unclassified: the shortest range the library allows). Every 30 s each emitter keeps a **bearing** from the boat's own position (20 minutes); the chart shows the latest bearing lines, and once the boat's own motion has swung the bearing by at least 8°, the **cross-fix** is their best crossing with a 95 % error ellipse that allows for an emitter drifting up to 8 kn since each line (a fast frigate usually gives none; a fix whose lines disagree is marked). The **level trend** reads rising, steady or falling over five minutes. The **mast warning** ("radar can see the mast") comes when a live search radar's estimated range is inside the range at which a surface radar sees a raised mast in this sea and rain (the weather page's value); the **recommended mast time** is 60 s in a calm sea, up to 300 s when sea clutter hides the mast and 20 s under that warning, and the log reports when it is exceeded. From sea state 3 waves wash over the antenna and some scans hear nothing. The browser's Mast & ESM card has the rose, the emitter table and the selected emitter's evaluation; **Transfer to plot** puts the cross-fix (mark and error circle) or else the latest bearing line into the boat's plot. On the uConsole's Mast & ESM page `↑`/`↓` select an emitter, `←`/`→` step through its library classification and `Enter` transfers it to the plot. - **Navigation and plot:** the engine room has telegraph buttons, and Command and Navigation share the boat's own grease-pencil plot (marks, rulers, bearing lines, circles, DR lines); the frigate never sees it, and the boat's plot is not saved. The navigation display shows the water under the keel and checks the chart along the ordered course up to 5 NM: land or a seabed shallower than the boat is reported as an obstacle ahead, in the log and as a warning. Only charted geography counts; other vessels are not in the check. diff --git a/docs/manual/manual.de.md b/docs/manual/manual.de.md index 4be90788..ead0c0ed 100644 --- a/docs/manual/manual.de.md +++ b/docs/manual/manual.de.md @@ -185,6 +185,7 @@ Klasse und Typ brauchen eine feiner aufgelöste Silhouette als die Sichtung (Joh | `K` | Kamera-Follow an/aus | | `, / .` | Ausguck-Seite: Radius kleiner / größer | | `B` | Ausguck-Seite: Fernglas über der Karte ein/aus (, / . schwenken) | +| `G` | Gefechtsstationen an/aus | Auf der Brücke steuert der Trackball das Ruder. `U` und `V` öffnen die direkte Zahleneingabe; die Simulation läuft währenddessen weiter. `Enter` bestätigt, `Esc` bricht ab. @@ -508,7 +509,7 @@ Die Schadensabwehr hält das Schiff nach einem Treffer schwimmfähig und die Sta ### Anzeigen und Instrumente -Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Tendenz, Trupps vor Ort, Krängung). +Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Tendenz, Trupps vor Ort, Krängung); Seite 3 ist der Wachplan der Besatzung. ```text Bug Heck @@ -533,6 +534,16 @@ Seite 1 ist der Schiffsplan; Seite 2 zeigt Details je Abteilung (Flutung, Brand, Auswirkungen auf Stationen: eine Station verliert mit Flutung und Brand in ihrem Raum stufenlos an Leistung (Sonar- und Radarreichweite sinken allmählich); ein zerstörter Raum legt sie lahm. Eine beschädigte Maschine begrenzt die Fahrt auf 15 kn, eine zerstörte auf 8 kn; eine beschädigte oder zerstörte Waffenzentrale sperrt Torpedostarts; ein zerstörtes Flugdeck verhindert Start und Landung des Helikopters; eine zerstörte OPZ legt auch ESM lahm. +### Besatzung und Wachen + +Seite 3 (Besatzung) zeigt den Wachplan. Die Besatzung geht in drei Wachen: eine ist im Dienst und ermüdet, die beiden anderen ruhen und erholen sich. Die Wache im Dienst wird jede Spielstunde automatisch abgelöst (eine echte Wache dauert vier Stunden; das Spiel verkürzt sie, damit eine Partie den Wechsel erlebt) oder früher mit `W` auf dieser Seite. In der ersten Minute nach der Ablösung arbeitet sich die neue Wache ein und bringt 85 %. + +- **Ermüdung** (0 bis 100 % je Wache) steigt in einer normalen Stunde im Dienst um etwa 25 % und sinkt in der Ruhe wieder. Bis 25 % kostet sie nichts, normaler Wachwechsel hält die Besatzung also bei voller Leistung. Darüber kosten je 10 % Ermüdung 6 % Leistung. +- **Gefechtsstationen** (`G` hier oder auf der Brücke) holen alle Wachen in den Dienst: die Besatzung ist 10 % aufmerksamer, aber niemand ruht, und alle sind in 90 Minuten von frisch bis erschöpft, schneller bei Brand- oder Leckbekämpfung. Auf Gefechtsstationen gibt es keine Ablösung; beim Aufheben übernimmt die frischeste Wache. Für einen Angriff auf Station gehen und danach aufheben: nach etwa einer halben Stunde auf Gefechtsstationen ist der Vorteil aufgebraucht. +- **Moral** beginnt bei 70 %. Ein versenktes U-Boot (+15), eine Rettung (+12) oder ein anderer erfüllter Auftrag (+6) heben sie; eine beschädigte Abteilung (-6), ein gescheiterter (-8) oder abgelehnter Auftrag (-2) senken sie; eine reparierte Abteilung bringt +2. Niedrige Moral ermüdet schneller; je 10 % Moral ändern die Leistung um 2 %. +- **Leistung** ist, was die Besatzung bringt: der Sonarbediener braucht ein stärkeres Signal (je 10 % Verlust hebt die Erkennungsschwelle um 1 dB, die Passivreichweiten sinken), der Ausguck braucht mehr Kontrast zum Sichten, Erkennen und Identifizieren, und die Reparaturtrupps dichten, lenzen und löschen in diesem Tempo. Seite 3 zeigt die aktuellen Werte; der Statusticker zeigt `BES` mit der Leistung oder `GEF` auf Gefechtsstationen. +- Das besetzte Gegner-U-Boot hat einen eigenen Wachplan mit denselben Regeln (siehe Kapitel Referenz). + ### Tasten | Taste | Funktion | @@ -542,6 +553,8 @@ Auswirkungen auf Stationen: eine Station verliert mit Flutung und Brand in ihrem | `Eingabe` | Gewähltes Team dem gewählten Kompartiment zuweisen | | `Backspace` | Gewähltes Team zurückziehen | | `C` | Hohe Rumpfseite gegen Krängung gegenfluten (erneut: Ventil schließen) | +| `W` | Wache jetzt ablösen (Seite Besatzung) | +| `G` | Gefechtsstationen an/aus | | `1-9` | Immer Station wechseln, keine Teamzuweisung | | `Klick` | Raum oder Beschriftung wählen; Enter weist das gewählte Team zu | @@ -564,7 +577,7 @@ Auf der uConsole weisen die Joystick-Tasten 1-3 Trupp 1-3 direkt der gewählten ### Nicht modelliert -- Keine einzelnen Besatzungsmitglieder oder Verwundeten. +- Keine einzelnen Besatzungsmitglieder, Verwundeten oder Schlaf nach der Uhr; Wachen werden jede Spielstunde abgelöst. - Gegenfluten nur zwischen den beiden Rumpfseiten; kein gezieltes Fluten anderer Räume. ## 5 OPZ / CIC @@ -1071,6 +1084,7 @@ Eine zweite Crew kann den Gegner spielen. Das Boot hat sechs Stationen: Führung - **Energie und Vorräte:** die Maschine zeigt unter **Energie & Vorräte** (Karte im Browser, auf der uConsole Maschine Seite 2 **Vorräte**) die Energiebilanz bei der aktuellen Fahrt (Verbrauch, Erzeugung und Bilanz in kW, die Zeit bis die Batterie leer oder voll ist), Batterie und AIP-Sauerstoff, die Dieselbunker und eine Tabelle, wie lange die Batterie getaucht bei jeder Telegrafenstufe reicht und wie weit das Boot damit kommt. **Diesel:** die Bunker fassen 300 Stunden volle Generatorleistung, eine Fahrt beginnt mit 65 %; nur laufende Diesel verbrauchen (0,27 l je kWh), das Log warnt bei 10 %, und mit leeren Bunkern lädt Schnorcheln nicht mehr. Die **Laderate** bestimmt, was Schnorcheln tut: *voll* (die ganze Generatorleistung, +12 dB und beide Diesellinien), *halb* (die halbe Leistung, +9 dB, schwächere Linien) oder *nur lüften* (die Lüfter ohne Diesel, +4 dB, keine Linien). **Luft:** getaucht verbraucht die Crew Sauerstoff und atmet Kohlendioxid aus (je etwa 0,45 % pro Stunde); ein CO2-Absorbersatz nimmt CO2 auf, bis er verbraucht ist (8 Ersatzsätze), eine O2-Kerze setzt in 15 Minuten 1 % O2 zu (12 an Bord, eine zur Zeit), und Schnorcheln lüftet das Boot in wenigen Minuten Richtung Frischluft. Ab 3 % CO2 oder unter 18 % O2 ist die Luft verbraucht, ab 5 % CO2 oder unter 16 % O2 gefährlich; das Log warnt bei jeder Stufe. Schlechte Luft macht die Crew langsamer (bis 30 % Leistung), und die Torpedomannschaft lädt entsprechend langsamer nach. KI-Boote versorgen ihre Luft selbst und tauchen zum Lüften auf, wenn sie gefährlich wird. Ein Atom-U-Boot hat keine dieser Vorräte. - **Tauchzellen, Trimm und Pressluft:** die Maschine zeigt unter **Tauchzellen & Trimm** (Karte im Browser mit Schnittbild des Boots, auf der uConsole Maschine Seite 3 **Zellen**) die Hauptzellen, die Regelzelle, die Trimmzellen, die Pressluft und den Trimmzustand des Boots. Jede Gewichtsänderung bringt das Boot aus dem Gleichgewicht: ein Torpedo aus einem Bugrohr macht es 1,5 t leichter und achterlastig, Wasser in vollgelaufenen Abteilungen (siehe Leckwehr) macht es schwerer und trimmt es zum gefluteten Ende; die Trimmautomatik gleicht davon aus, was ihre Zellen fassen. Mit der **Trimmautomatik** pumpt der LI die Regelzelle (±8 t, 25 kg/s) und die Trimmzellen (±3 t vorn und achtern, 15 kg/s) zurück ins Gleichgewicht; von Hand verschiebt jeder Befehl die Regelzelle um 0,5 t oder das Trimmwasser um 0,25 t (und schaltet die Automatik aus). Laufende Trimmpumpen sind hörbar (+3 dB und eine Linie bei 120 Hz). Was die Zellen nicht aufnehmen, lässt das Boot mit 0,03 m/s je Tonne sinken oder steigen, und ein Trimmwinkel (1° je Tonne Moment, + vorlastig) drückt es mit Fahrt nach unten oder oben; die Tiefenruder halten das nur mit Fahrt, ein schweres Boot sinkt bei wenig Fahrt unter seine befohlene Tiefe; das Log warnt ab 2 t und ab 3°. Die **Pressluft** (200 bar) reicht für drei Notanblasungen zu je 60 bar; Anblasen leert die Hauptzellen in 20 s, das Boot steigt auf 10 m und bleibt dort, die befohlene Tiefe steht dann auf 10 m. Der nächste Befehl unter 12 m öffnet die Entlüftung: die Hauptzellen fluten in 40 s, erst dann kann das Boot tauchen. Schnorcheln auf Diesel betreibt den Kompressor (0,05 bar/s); mit nur lüften läuft er nicht. Ohne Strom laufen weder Trimmpumpen noch Kompressor. Die KI-Boote halten sich selbst im Trimm und behalten ihr eines Notanblasen. - **Leckwehr:** die Maschine zeigt unter **Leckwehr** (Karte im Browser mit den Abteilungen und einer Tabelle, auf der uConsole Maschine Seite 4 **Leckwehr**) den Druckkörper in sechs Abteilungen: Bugraum, Zentrale, Wohnraum, Batterieraum, Maschinenraum und Heckraum. Ein Treffer auf das besetzte Boot schlägt ein Leck in die getroffene Abteilung (1,5 % Leck je % Trefferschaden, höchstens ein volles Leck; ab 50 % Schaden auch in die Nachbarabteilung mit halbem Leck) und kann dort einen Brand auslösen (Wahrscheinlichkeit = Schaden / 150); ein Ermüdungsriss unter der Testtiefe öffnet ein kleines Leck. Durch ein volles Leck dringen in 100 m Tiefe 40 kg/s ein, mit der Wurzel der Tiefe mehr; über halbvoll läuft das Wasser in offene Nachbarabteilungen über (20 kg/s) und erstickt einen Brand. Ein Brand wächst in 2 min zum Vollbrand und greift dann durch offene Schotten über; Seewasser im Batterieraum (ab 2 t) setzt Chlorgas frei, das durch offene Schotten zieht und erst langsam abzieht, wenn die Batterie trocken ist. Wasser im Batterieraum (ab 5 t) oder ein Brand dort legen den **Strom** lahm: der Motor steht (keine Fahrt, also halten die Tiefenruder ein schweres Boot nicht), Trimmpumpen, Kompressor und elektrische Lenzpumpen stehen still. **Schotten schließen** hält Wasser, Brand und Gas in der Abteilung und erstickt einen Brand dort in 3 min. Zwei **Leckwehrtrupps** gehen durchs Boot (8 s je Abteilung) und **dichten ein Leck ab** (ein volles in 60 s), **lenzen** (30 kg/s, ohne Strom ein Viertel von Hand) oder **löschen einen Brand** (einen Vollbrand in 60 s); im Gas arbeiten sie halb so schnell, und in einer zu 90 % vollen Abteilung können sie nur lenzen. Eine Abteilung, die zur Hälfte voll Wasser ist, halb brennt oder halb vergast ist, legt ihre Station lahm: der Bugraum die Torpedorohre, die Zentrale Mast und Sehrohr, der Maschinenraum die Diesel, der Heckraum die halbe Höchstfahrt. Das Wasser ist Gewicht und Moment für den Trimm (siehe oben); ein Boot, das unter die 1,5-fache Testtiefe sinkt, wird zerdrückt. Das Log meldet Lecks, Brände, abgedichtete Lecks, gelöschte Brände, vollgelaufene Abteilungen, Chlorgas und den Strom. +- **Besatzung:** das Boot hat einen eigenen Wachplan mit den Regeln der Fregatte (siehe Schadensabwehr, Besatzung und Wachen): drei Wachen, Ermüdung, Gefechtsstationen und Moral. Maschine und Führung befehlen Gefechtsstationen (`B` auf der uConsole, eine Taste in der Leckwehr-Karte im Browser) und lösen die Wache ab (`M` auf der Seite Leckwehr oder die Taste). Die Moral steigt, wenn ein Schiff sinkt, und sinkt mit je 10 % Rumpfschaden. Eine müde Besatzung hört am Sonar später, sichtet durch das Sehrohr später und ihre Leckwehrtrupps dichten und löschen langsamer (die Pumpen sind Maschinen und behalten ihre Leistung). - **Lagebild:** ein gehörter Aktivping oder Torpedo wird mit der Peilung protokolliert, die das Boot selbst gemessen hat (einige Grad ungenau), und mit seinem Alter in den Alarmen angezeigt. Auf Sehrohrtiefe lässt sich der **Mast** ausfahren; sein ESM meldet dann die Radare, die das Boot überstreichen, mit Peilung (Log und ESM-Liste), und beim Tieferkommen fährt der Mast selbst ein. Mit ausgefahrenem Mast zeigt die Seite **Sehrohr** (Führung Seite 3, Mast & ESM Seite 2; `P` fährt an beiden den Mast aus) das Okular: Himmel und See im Licht der Stunde, den mit der See bewegten Horizont, eine Skala rechtweisender Peilungen und ein Fadenkreuz; das Rohr schwenkt in 2°-Schritten (`←`/`→`, `Umschalt`: 10°). Alles, was die Optik im Kontrastmodell des Fregattenausgucks bei 2,5 m Augenhöhe ausmacht (Tag/Nacht, Mond, Sicht, Seegang, Land im Weg), erscheint als Silhouette und als reine Peilungs-**Sichtung** mit grober Klasse (Kriegsschiff, Handelsschiff, Fahrzeug, Luftfahrzeug, Torpedolaufbahn) und scheinbarer Länge; das Log meldet jede neue Sichtung. `Enter` liest das **Stadimeter** an der Sichtung unter dem Fadenkreuz ab: die Entfernung folgt aus der scheinbaren Länge und der angenommenen Rumpflänge der Klasse (130 m für ein Kriegsschiff oder ein nicht erkanntes Fahrzeug, 150 m für ein Handelsschiff), ein nicht erkanntes oder bugwärts stehendes Ziel misst sich also zu weit; die Ablesung ist ±25 % und wird für 120 s zu einem VISUAL-Fix am Sonarkontakt des Boots auf dieses Ziel, für einen Schuss nutzbar wie ein Ping-Fix. Luftfahrzeuge und Laufbahnen lassen sich nicht messen. Die kartierte Küste steht auf dem Horizont des Sehrohrs, so weit seine niedrige Optik Land sieht (Hügel mit 25 bis 70 m angenommen). Die Führung kann auch ohne Sonarbediener pingen und eine BT-Messung nehmen. Die Karte zeigt das Schussfeld der Rohre, wo sie nicht rundum schießen, und das vom Sonar zugewiesene Ziel ist für den Schuss vorausgewählt. - **Mast & ESM:** mit ausgefahrenem Mast auf Sehrohrtiefe hört die ESM-Antenne des Boots (3 m über Wasser) einmal pro Sekunde die Radare ringsum: das der Fregatte, anderer Schiffe und von Flugzeugen innerhalb des Radarhorizonts, über Land nur, wo die Küste die Linie nicht verdeckt. Jede Erfassung trägt die gemessene Peilung (±4°), Band, Trägerfrequenz, PRF, Modulation und Empfangspegel, nie die Identität oder Position des Senders. Die Crew führt eine **Emitterliste** (`E1`, `E2` …) über mehrere Mastperioden: eine Erfassung gehört zu einem Emitter, wenn Peilung, Band und Signalform passen (ein frequenzagiles Radar nur nach Peilung und Band), und die Liste vergisst einen Emitter 30 Minuten nach seiner letzten Erfassung. Die **Einstufung** ist die Annotation der Crew aus der Bibliothek: die Emitter, deren veröffentlichte Frequenz- und PRF-Bereiche die Messung enthalten, ungewichtet, wie an der ELOKA der Fregatte ohne Assistenz; die Wahl legt die Leistungsklasse für die **Entfernungsschätzung** aus dem Pegel fest (ohne Einstufung die kürzeste Entfernung, die die Bibliothek zulässt). Alle 30 s behält jeder Emitter eine **Peilung** von der eigenen Position des Boots (20 Minuten); die Karte zeigt die letzten Peillinien, und sobald die eigene Fahrt die Peilung um mindestens 8° gedreht hat, ist die **Kreuzpeilung** ihr bester Schnittpunkt mit einer 95-%-Fehlerellipse, die einen seit jeder Linie bis zu 8 kn versetzten Sender einrechnet (eine schnelle Fregatte ergibt meist keine; eine Kreuzpeilung, deren Linien nicht zusammenpassen, wird markiert). Der **Stärketrend** zeigt steigend, gleichbleibend oder fallend über fünf Minuten. Die **Mastwarnung** („Radar kann Mast sehen“) kommt, wenn die geschätzte Entfernung eines erfassten Suchradars innerhalb der Entfernung liegt, auf der ein Seeraumradar bei diesem Seegang und Regen einen ausgefahrenen Mast sieht (der Wert der Wetterseite); die **empfohlene Mastzeit** ist 60 s bei ruhiger See, bis zu 300 s, wenn die Seegangsechos den Mast verbergen, und 20 s unter dieser Warnung, und das Log meldet, wenn sie überschritten ist. Ab Seegang 3 überspülen Wellen die Antenne, und manche Durchläufe hören nichts. Die Karte Mast & ESM im Browser hat die Rose, die Emittertabelle und die Auswertung des gewählten Emitters; **In den Plot übernehmen** trägt die Kreuzpeilung (Markierung und Fehlerkreis) oder sonst die letzte Peillinie in den Plot des Boots ein. Auf der Seite Mast & ESM der uConsole wählen `↑`/`↓` einen Emitter, `←`/`→` schalten seine Einstufung aus der Bibliothek weiter und `Enter` übernimmt ihn in den Plot. - **Navigation und Plot:** die Maschine hat Maschinentelegrafen-Knöpfe, und Führung und Navigation teilen den eigenen Fettstift-Plot des Boots (Markierungen, Lineale, Peillinien, Kreise, Koppellinien); die Fregatte sieht ihn nie, und der Plot des Boots wird nicht gespeichert. Die Navigation zeigt das Wasser unter dem Kiel und prüft die Seekarte entlang des Sollkurses bis 5 sm: Land oder ein Grund flacher als das Boot wird als Hindernis voraus gemeldet, im Log und als Warnung. Es zählt nur die kartierte Geografie; andere Fahrzeuge sind nicht Teil der Prüfung. @@ -1123,6 +1137,8 @@ Die obere Leiste zeigt die sechs Stationen des Boots als Reiter: `1` Führung, ` | `Pfeiltasten` | Maschine, Seite Leckwehr: Abteilung wählen (auf/ab) und Aufgabe (links/rechts) | | `Eingabe` | Maschine, Seite Leckwehr: Trupp 1 (Umschalt: Trupp 2) mit der Aufgabe schicken | | `I` | Maschine, Seite Leckwehr: Schotten der Abteilung schließen oder öffnen | +| `M` | Maschine, Seite Leckwehr: Wache jetzt ablösen | +| `B` | Gefechtsstationen an/aus (alle Wachen im Dienst, aufmerksam, aber ermüdend) | | `0` | Wetterseite des Boots (0 oder Esc schließt) | | `S / L / F9` | Speichern / Laden / Remote Crew (die Fregatten-Crew) | diff --git a/docs/manual/manual.en.md b/docs/manual/manual.en.md index e6c59c79..8eddc68c 100644 --- a/docs/manual/manual.en.md +++ b/docs/manual/manual.en.md @@ -185,6 +185,7 @@ Class and type need a finer resolved silhouette than the sighting (Johnson crite | `K` | Camera follow on/off | | `, / .` | Lookout page: scope radius smaller / larger | | `B` | Lookout page: binoculars over the chart on/off (, / . train them) | +| `G` | Action stations on/off | The trackball steers the rudder while the Bridge is selected. `U` and `V` open direct numeric entry; the simulation keeps running while you type. `Enter` confirms, `Esc` cancels. @@ -507,7 +508,7 @@ Damage control keeps the ship afloat and the stations working after a hit. Three ### Displays and instruments -Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fire, trend, teams on scene, heel). +Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fire, trend, teams on scene, heel); page 3 is the crew's watch bill. ```text bow stern @@ -532,6 +533,16 @@ Page 1 is the ship schematic; page 2 lists details per compartment (flooding, fi Station effects: a station loses capability continuously with flooding and fire in its room (sonar and radar range shrink gradually); a destroyed room disables it. A damaged engine room caps speed at 15 kn, a destroyed one at 8 kn; a damaged or destroyed weapons room blocks torpedo launches; a destroyed flight deck prevents helicopter launch and recovery; a destroyed operations room also disables ESM. +### Crew and watches + +Page 3 (Crew) shows the watch bill. The ship's company stands in three watches: one is on duty and tires, the other two rest and recover. The duty watch is relieved automatically every hour of game time (a real watch is four hours; the game compresses it so a session sees the rotation), or earlier with `W` on this page. For the first minute after a relief the new watch settles in and works at 85 %. + +- **Fatigue** (0 to 100 % per watch) rises by about 25 % in a normal hour on duty and falls again at rest. Up to 25 % it costs nothing, so normal rotation keeps the crew at full performance. Above it, every 10 % costs 6 % performance. +- **Action stations** (`G` here or on the Bridge) put every watch on duty: the crew is 10 % more alert, but nobody rests and everybody tires in 90 minutes from fresh to exhausted, faster while fighting fire or flooding. There is no relief at action stations; standing down hands the watch to the freshest section. Stand to for an attack and stand down afterwards: after about half an hour at action stations the bonus is used up. +- **Morale** starts at 70 %. A sunk submarine (+15), a rescue (+12) or another task done (+6) raise it; a compartment damaged (-6), a task failed (-8) or declined (-2) lower it; a repaired compartment gives +2. Low morale tires the crew faster; each 10 % of morale changes performance by 2 %. +- **Performance** is what the crew delivers: the sonar operator needs a stronger signal (every 10 % lost raises the recognition threshold by 1 dB, so the passive ranges shrink), the lookout needs more contrast to sight, recognize and identify, and the repair teams patch, pump and fight fire at that pace. Page 3 lists the current values; the status ticker shows `CREW` with the performance, or `GQ` at action stations. +- The crewed opposing submarine has its own watch bill with the same rules (see the reference chapter). + ### Keys | Key | Action | @@ -541,6 +552,8 @@ Station effects: a station loses capability continuously with flooding and fire | `Enter` | Assign selected team to selected compartment | | `Backspace` | Withdraw selected team | | `C` | Counter-flood the high hull side against a list (again: close the valve) | +| `W` | Relieve the duty watch now (Crew page) | +| `G` | Action stations on/off | | `1-9` | Always switch station; never assign a team | | `Click` | Select compartment or its label; Enter assigns the selected team | @@ -563,7 +576,7 @@ On the uConsole the joystick buttons 1-3 assign team 1-3 directly to the selecte ### Not modelled -- No individual crew members or casualties. +- No individual crew members, casualties or sleep by the clock; watches are relieved every hour of game time. - Counter-flooding only between the two hull sides; no selective flooding of other rooms. ## 5 Operations / CIC @@ -1070,6 +1083,7 @@ A second crew can play the enemy. The boat has six stations: Command, Sonar, Wea - **Energy and stores:** the engine room's **Energy & stores** (browser card, uConsole Engine room page 2 **Stores**) shows the energy balance at the present speed (load, supply and net kW, the time until the battery is empty or full), the battery and AIP oxygen, the diesel bunkers and a table of how long the battery lasts dived at each telegraph step and how far that carries the boat. **Diesel:** the bunkers hold 300 hours of the generators' full output and a patrol starts with 65 %; only the running diesels burn it (0.27 l per kWh), the log warns at 10 %, and with dry bunkers snorkelling no longer charges. The **charge rate** sets what snorkelling does: *full* (the whole generator output, +12 dB and both diesel lines), *half* (half the output, +9 dB, weaker lines) or *air only* (the fans without diesels, +4 dB, no lines). **Air:** dived, the crew uses oxygen and breathes out carbon dioxide (about 0.45 % per hour each); a CO2 absorber set takes CO2 out until it is spent (8 spare sets), an oxygen candle adds 1 % O2 over 15 minutes (12 aboard, one at a time), and snorkelling flushes the boat toward fresh air within minutes. From 3 % CO2 or below 18 % O2 the air is stale, from 5 % CO2 or below 16 % O2 it is foul; the log warns at each step. Stale air slows the crew (down to 30 % performance), and the torpedo gang reloads accordingly slower. AI boats manage their air by themselves and come up to air the boat when it turns foul. A nuclear boat has none of these stores. - **Tanks, trim and air:** the engine room's **Tanks & trim** (browser card with a cross-section of the boat, uConsole Engine room page 3 **Tanks**) shows the main ballast, the regulating tank, the trim tanks, the high-pressure air and the trim the boat is in. Every weight change moves the boat off neutral: a torpedo leaving a bow tube makes it 1.5 t lighter and bow light, water in flooded compartments (see damage control) makes it heavier and trims it toward the flooded end; the automatic trim takes up what its tanks can of that weight and moment. With the **automatic trim** on, the engineer pumps the regulating tank (±8 t, 25 kg/s) and the trim tanks (±3 t fore and aft, 15 kg/s) back to neutral; by hand, each order moves the regulating tank 0.5 t or the trim water 0.25 t (and switches the automatic off). Running trim pumps are audible (+3 dB and a 120 Hz line). Whatever the tanks cannot take up sinks or lifts the boat by 0.03 m/s per tonne, and a trim angle (1° per tonne of moment, + bow down) drives it down or up with speed; the hydroplanes hold that only with way on, so a heavy boat hovering at low speed sinks below its ordered depth; the log warns from 2 t and from 3°. The **high-pressure air** (200 bar) holds three emergency blows of 60 bar each; a blow empties the main ballast in 20 s and the boat rises to 10 m and stays there, the ordered depth reset to 10 m. The next order below 12 m opens the vents: the main ballast floods in 40 s before the boat can dive. Snorkelling on the diesels runs the compressor (0.05 bar/s); with the air only on the fans it does not. Without power neither the trim pumps nor the compressor run. The AI's boats keep themselves trimmed and keep their one legacy blow. - **Damage control:** the engine room's **Damage control** (browser card with the compartments and a table, uConsole Engine room page 4 **Damage**) divides the pressure hull into six compartments: bow room, control room, quarters, battery room, engine room and stern room. A hit on the crewed boat holes the compartment it strikes (a leak of 1.5 % per % of hit damage, up to a full hole; from 50 % damage the neighbour too, with half the leak) and may start a fire there (chance = damage / 150); a fatigue crack below test depth opens a small leak. Water comes in at 40 kg/s through a full hole at 100 m, growing with the square root of depth; above half a compartment it spills into open neighbours (20 kg/s) and smothers a fire. A fire grows to full in 2 min and then spreads through open bulkheads; seawater in the battery room (from 2 t) gives off chlorine gas that drifts through open bulkheads and clears slowly once the battery is dry. Water in the battery room (from 5 t) or a fire there cuts the **power**: the motor stops (no way on, so the hydroplanes do not hold a heavy boat), and the trim pumps, compressor and electric bilge pumps stand still. **Shutting the bulkheads** of a compartment keeps water, fire and gas in it and starves a fire there in 3 min. Two **damage-control teams** walk the boat (8 s per compartment) and **seal a leak** (a full hole in 60 s), **pump out** (30 kg/s, a quarter by hand without power) or **fight a fire** (a full fire in 60 s); in gas they work at half rate, and in a compartment 90 % full they can only pump. A compartment half full of water, half on fire or half gassed takes its station out: the bow room the torpedo tubes, the control room the mast and periscope, the engine room the diesels, the stern room half the top speed. The floodwater is weight and moment for the trim (see above); a boat that sinks below 1.5 x test depth is crushed. The log reports leaks, fires, sealed leaks, fires out, flooded compartments, chlorine and power. +- **Crew:** the boat has its own watch bill with the frigate's rules (see Damage control, Crew and watches): three watches, fatigue, action stations and morale. The Engine room and Command order action stations (`B` on the uConsole, a button in the browser's Damage control card) and relieve the watch (`M` on the Damage page, or the button). Morale rises when a ship sinks and falls with every 10 % of hull damage. A tired crew hears later on sonar, sights later through the periscope and its damage-control teams seal and fight fire more slowly (the pumps are machinery and keep their rate). - **Situation picture:** an intercepted active ping or torpedo is logged with the bearing the boat's own ears measured (a few degrees off) and shown with its age in the alarms. At periscope depth the **mast** can be raised; its ESM then reports the radars sweeping the boat with bearing (log and ESM list), and the mast lowers by itself when the boat goes deeper. With the mast up the **periscope** page (Command page 3, Mast & ESM page 2; `P` raises the mast at both) shows the eyepiece: sky and sea in the light of the hour, the horizon moving with the sea, a true-bearing scale and a crosshair; the scope trains in 2° steps (`←`/`→`, `Shift`: 10°). Everything the optics make out within the frigate lookout's contrast model at 2.5 m eye height (day/night, moon, visibility, sea state, land in the way) appears as a silhouette and as a bearing-only **sighting** with a coarse class (warship, merchant ship, vessel, aircraft, torpedo wake) and its apparent length; the log reports each new sighting. `Enter` reads the **stadimeter** on the sighting under the crosshair: the range follows from its apparent length and the assumed hull length of the class (130 m for a warship or an unrecognized vessel, 150 m for a merchant), so an unrecognized or bow-on target reads long; the reading is ±25 % and becomes a VISUAL fix on the boat's sonar contact of that target for 120 s, usable for a shot like a ping fix. Aircraft and wakes cannot be ranged. The charted coast stands on the periscope's horizon as far as its low optics see land (hills assumed 25 to 70 m). Command can also ping and take a BT without a sonar operator. The chart shows the tube firing arc where the tubes cannot fire all round, and the sonar room's assigned target is preselected for the shot. - **Mast & ESM:** with the mast up at periscope depth the boat's own ESM antenna (3 m above the water) hears the radars around it once a second: the frigate's, other ships' and aircraft radars inside the radar horizon, over land only where the coast does not block the line. Each intercept carries the measured bearing (±4°), band, carrier frequency, PRF, modulation and received level, never the emitter's identity or position. The crew keeps an **emitter list** (`E1`, `E2` …) across mast periods: an intercept joins an emitter when bearing, band and waveform agree (a frequency-agile radar by bearing and band only), and the list forgets an emitter 30 minutes after its last intercept. **Classification** is the crew's annotation from the library: the emitters whose published frequency and PRF ranges hold the measurement, unranked, as at the frigate's ELOKA without assistance; the choice sets the power class for the **range estimate** from the level (unclassified: the shortest range the library allows). Every 30 s each emitter keeps a **bearing** from the boat's own position (20 minutes); the chart shows the latest bearing lines, and once the boat's own motion has swung the bearing by at least 8°, the **cross-fix** is their best crossing with a 95 % error ellipse that allows for an emitter drifting up to 8 kn since each line (a fast frigate usually gives none; a fix whose lines disagree is marked). The **level trend** reads rising, steady or falling over five minutes. The **mast warning** ("radar can see the mast") comes when a live search radar's estimated range is inside the range at which a surface radar sees a raised mast in this sea and rain (the weather page's value); the **recommended mast time** is 60 s in a calm sea, up to 300 s when sea clutter hides the mast and 20 s under that warning, and the log reports when it is exceeded. From sea state 3 waves wash over the antenna and some scans hear nothing. The browser's Mast & ESM card has the rose, the emitter table and the selected emitter's evaluation; **Transfer to plot** puts the cross-fix (mark and error circle) or else the latest bearing line into the boat's plot. On the uConsole's Mast & ESM page `↑`/`↓` select an emitter, `←`/`→` step through its library classification and `Enter` transfers it to the plot. - **Navigation and plot:** the engine room has telegraph buttons, and Command and Navigation share the boat's own grease-pencil plot (marks, rulers, bearing lines, circles, DR lines); the frigate never sees it, and the boat's plot is not saved. The navigation display shows the water under the keel and checks the chart along the ordered course up to 5 NM: land or a seabed shallower than the boat is reported as an obstacle ahead, in the log and as a warning. Only charted geography counts; other vessels are not in the check. @@ -1122,6 +1136,8 @@ The top bar shows the boat's six stations as tabs: `1` Command, `2` Sonar, `3` W | `Arrow keys` | Engine room, damage page: pick a compartment (up/down) and a task (left/right) | | `Enter` | Engine room, damage page: send team 1 (Shift: team 2) with the task | | `I` | Engine room, damage page: shut or open the compartment's bulkheads | +| `M` | Engine room, damage page: relieve the duty watch now | +| `B` | Action stations on/off (all watches on duty, alert but tiring) | | `0` | Weather panel of the boat (0 or Esc closes) | | `S / L / F9` | Save / load / Remote Crew (the frigate's crew) | diff --git a/src/commander/bridge.py b/src/commander/bridge.py index 0ba10b41..6424a323 100644 --- a/src/commander/bridge.py +++ b/src/commander/bridge.py @@ -223,6 +223,14 @@ def _radio_capture_hfdf(game, params, bindings): return game.capture_hfdf_report(binding[4]) +def _crew_action_stations(game, params, _bindings): + return game.set_action_stations(params["enabled"]) + + +def _crew_watch_change(game, params, _bindings): + return game.change_watch() + + def _radio_task_accept(game, params, _bindings): return game.accept_task(params["task"]) @@ -652,6 +660,14 @@ def _uboot_bulkhead(game, boat, params, _bindings): return _uboot_result(boat.sub.command_bulkhead(params["compartment"], params["closed"])) +def _uboot_action_stations(game, boat, params, _bindings): + return game.boat_set_action_stations(params["enabled"]) + + +def _uboot_watch_change(game, boat, params, _bindings): + return game.boat_change_watch() + + def _uboot_mast(game, boat, params, _bindings): return _uboot_result(boat.sub.command_mast(params["enabled"])) @@ -704,6 +720,8 @@ _UBOOT_ACTION_HANDLERS = { "uboot_ballast": _uboot_ballast, "uboot_dc_team": _uboot_dc_team, "uboot_bulkhead": _uboot_bulkhead, + "uboot_action_stations": _uboot_action_stations, + "uboot_watch_change": _uboot_watch_change, "uboot_o2_candle": _uboot_o2_candle, "uboot_mast": _uboot_mast, "uboot_silent": _uboot_silent, @@ -743,6 +761,8 @@ _V2_ACTION_HANDLERS = { "engine_set_quiet_mode": _engine_set_quiet_mode, "damage_assign_team": _damage_assign_team, "damage_counterflood": _damage_counterflood, + "crew_action_stations": _crew_action_stations, + "crew_watch_change": _crew_watch_change, "engine_set_plant": _engine_set_plant, "damage_unassign_team": _damage_unassign_team, "radio_capture_hfdf": _radio_capture_hfdf, diff --git a/src/commander/projections.py b/src/commander/projections.py index 9897d653..a99e8d9b 100644 --- a/src/commander/projections.py +++ b/src/commander/projections.py @@ -656,6 +656,20 @@ def _weapons(game, rows, target_ref, asset_refs, direct_refs): active_assets=torpedoes + asrocs + nixies) +def _crew(game, watch=None): + """A crew's watch bill, fatigue and morale (own-ship truth).""" + view = game.crew_view(watch) + left = view["watch_left_s"] + return dict(on_watch=int(view["on_watch"]), + watches=[dict(index=int(row["index"]), fatigue=_number(row["fatigue"]), + on_duty=bool(row["on_duty"])) for row in view["watches"]], + watch_left_s=None if left is None else _number(left), + turnover=bool(view["turnover"]), + action_stations=bool(view["action_stations"]), + morale=_number(view["morale"]), + effectiveness=_number(view["effectiveness"])) + + def _damage(game): compartments = [dict(key=room.key, name=game.tr("compartment." + room.key), state=room.state, flood=_number(room.flood), @@ -667,7 +681,7 @@ def _damage(game): for room in game.damage.compartments.values()] teams = [dict(team=team, compartment=game.damage.teams[team]) for team in sorted(game.damage.teams)] - return dict(compartments=compartments, teams=teams, + return dict(compartments=compartments, teams=teams, crew=_crew(game), total=_number(game.damage.total), sunk=bool(game.damage.ship_sunk), stability=dict(list_deg=_number(game.damage.list_deg()), trim_deg=_number(game.damage.trim_deg()), @@ -1084,7 +1098,7 @@ def build_role_states(game, status, rows, target_ref, focus_ref, ref_by_track, if row.get("_opz") and row["source"] not in ("ESM", "FUSION") and not row["source"].startswith("SONAR")], - sightings=_sightings(game)), + sightings=_sightings(game), crew=_crew(game)), "sonar": _sonar(game, rows, focus_ref, target_ref, sonar_refs), "weapons": _weapons(game, rows, target_ref, asset_refs, direct_fire_refs["weapons"]), @@ -1333,10 +1347,12 @@ def _uboot_ballast(sub): drift_mps=_number(ballast.vertical_drift_mps(flooding, sub.speed, moment))) -def _uboot_damage(sub): - """The boat's own compartments and damage-control teams (own-ship truth).""" +def _uboot_damage(game, boat): + """The boat's own compartments, damage-control teams and crew (own-ship truth).""" + sub = boat.sub control = sub.damage_control return dict( + crew=_crew(game, boat.watch), power=bool(control.power()), pumping=bool(control.pumping), compartments=[dict( name=name, water_kg=_number(c.water_kg), capacity_kg=_number(capacity_kg(index)), @@ -1480,7 +1496,7 @@ def _uboot(game, boat, rows, target_ref, asset_refs): plant=_uboot_plant(sub), esm=_uboot_esm(game, boat), ballast=_uboot_ballast(sub), - damage_control=_uboot_damage(sub), + damage_control=_uboot_damage(game, boat), feed=[dict(seq=int(row["seq"]), age_s=_age(game.sim_t, row["t"]), message=str(localize(row["text"], game.tr))[:256]) for row in list(boat.feed)[-16:]]) diff --git a/src/commander/v2/commands.py b/src/commander/v2/commands.py index 52350264..c3fbd2ac 100644 --- a/src/commander/v2/commands.py +++ b/src/commander/v2/commands.py @@ -486,6 +486,11 @@ V2_ACTION_REGISTRY = { "engine_set_plant": V2Action(frozenset({"engine"}), _enum_params("mode", ("AUTO", "DIESEL", "TURBINE"))), "damage_counterflood": V2Action(frozenset({"damage"}), _bool_params("enabled")), + # Crew watch bill: action stations from the bridge or damage control, + # the watch relieved by damage control (the ship's company is its job). + "crew_action_stations": V2Action(frozenset({"bridge", "damage"}), + _bool_params("enabled")), + "crew_watch_change": V2Action(frozenset({"damage"}), _no_params), "damage_assign_team": V2Action(frozenset({"damage"}), _team_compartment_params), "damage_unassign_team": V2Action(frozenset({"damage"}), @@ -612,6 +617,10 @@ V2_ACTION_REGISTRY = { # ... and runs damage control: two teams, the bulkheads. "uboot_dc_team": V2Action(frozenset({"uboot", "uboot_engine"}), _uboot_dc_team_params), "uboot_bulkhead": V2Action(frozenset({"uboot", "uboot_engine"}), _uboot_bulkhead_params), + # ... and keeps the watch bill (Command orders action stations as well). + "uboot_action_stations": V2Action(frozenset({"uboot", "uboot_engine"}), + _bool_params("enabled")), + "uboot_watch_change": V2Action(frozenset({"uboot", "uboot_engine"}), _no_params), "uboot_mast": V2Action(frozenset({"uboot", "uboot_esm"}), _bool_params("enabled")), "uboot_wire_steer": V2Action(frozenset({"uboot_weapons"}), _uboot_wire_params), "uboot_wire_cut": V2Action(frozenset({"uboot_weapons"}), _single_ref_params), diff --git a/src/commander/v2/schema.py b/src/commander/v2/schema.py index 56e1b008..b9852bd1 100644 --- a/src/commander/v2/schema.py +++ b/src/commander/v2/schema.py @@ -27,6 +27,11 @@ RADIO_TASK_FIELDS = ("id", "kind", "state", "name", "persons", "x", "y", "radius "remaining_s", "progress", "sighted", "verdict", "points", "can_answer") RADIO_TASK_KINDS = ("sar", "identify", "datum", "ras", "emcon") +# The crew's watch bill, fatigue and morale (``src/core/crew.py``): the +# frigate's on the bridge and damage roles, the boat's in ``damage_control``. +CREW_FIELDS = ("on_watch", "watches", "watch_left_s", "turnover", "action_stations", + "morale", "effectiveness") +CREW_WATCH_FIELDS = ("index", "fatigue", "on_duty") RADIO_TASK_STATES = ("offered", "active", "done", "failed", "declined") # The common ``weather_station`` block: own-ship atmosphere (every role) and @@ -64,7 +69,7 @@ UBOOT_BALLAST_FIELDS = UBOOT_BALLAST_FLAGS + ( "regulating_order_kg", "regulating_capacity_kg", "trim_kg", "trim_order_kg", "trim_capacity_kg", "load_kg", "flooding_kg", "residual_kg", "trim_deg", "drift_mps") # The boat's compartments and damage-control teams (``damage_control``). -UBOOT_DAMAGE_FIELDS = ("power", "pumping", "compartments", "teams") +UBOOT_DAMAGE_FIELDS = ("power", "pumping", "compartments", "teams", "crew") UBOOT_COMPARTMENT_FIELDS = ("name", "water_kg", "capacity_kg", "leak_pct", "fire_pct", "chlorine_pct", "closed", "down") UBOOT_DC_TEAM_FIELDS = ("team", "compartment", "task", "transit_s") @@ -84,12 +89,13 @@ UBOOT_ESM_CANDIDATE_FIELDS = ("name", "role") UBOOT_ESM_FIX_FIELDS = ("x", "y", "major_nm", "minor_nm", "axis_deg", "lines", "consistent") # Top-level keys of every role payload (exact sets on both sides). ROLE_SHAPES = { - "bridge": ("navigation", "orders", "threat", "systems", "tactical_summary", "sightings"), + "bridge": ("navigation", "orders", "threat", "systems", "tactical_summary", "sightings", + "crew"), "sonar": ("observations", "settings", "visualization"), "weapons": ("inventory", "readiness", "designated_target", "navigation", "tactical", "target_choices", "depth_m", "tubes", "settings", "own_weapons", "active_assets"), - "damage": ("compartments", "teams", "total", "sunk", "stability"), + "damage": ("compartments", "teams", "total", "sunk", "stability", "crew"), "opz": ("observations", "fusions", "radar", "defense", "asm_observations", "source_classifications", "radar_blips", "designated_target_ref", "own_assets"), "radio": ("observations", "logged_fixes", "logged_bearings", "messages", "station_down", diff --git a/src/core/commands.py b/src/core/commands.py index 85dc240e..bc775ca3 100644 --- a/src/core/commands.py +++ b/src/core/commands.py @@ -21,7 +21,7 @@ STATION_PAGES = { "ACTIVE", ), Station.WEAPONS: ("WEAPONS_TARGET", "WEAPONS_AMMO"), - Station.DAMAGE: ("DAMAGE_PLAN", "DAMAGE_DETAIL"), + Station.DAMAGE: ("DAMAGE_PLAN", "DAMAGE_DETAIL", "DAMAGE_CREW"), Station.OPZ: ("OPZ_PICTURE", "OPZ_TARGET"), Station.RADIO: ("RADIO_HFDF", "RADIO_MESSAGES", "RADIO_TASKS"), Station.ENGINE: ("ENGINE_TELEGRAPH", "ENGINE_SYSTEMS"), diff --git a/src/core/config.py b/src/core/config.py index 1ffe3e32..cb1783f1 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -834,6 +834,27 @@ SCORE_TASK = { # (done, failed, declined) "emcon": (200, -250, -200), } +# Crew fatigue, watches and morale (src/core/crew.py; game assumptions). +# A real watch is four hours; the game relieves the watch every hour so a +# session sees the rotation. Normal rotation keeps the duty watch fresh +# (effectiveness 1.0); action stations tire everybody. +CREW_WATCH_S = 3600.0 # duty watch relieved after this +CREW_TURNOVER_S = 60.0 # new watch settling in +CREW_TURNOVER_FACTOR = 0.85 +CREW_TIRE_WATCH_S = 4.0 * 3600.0 # duty watch: fatigue 0 -> 1 +CREW_TIRE_ACTION_S = 1.5 * 3600.0 # action stations: everybody +CREW_RECOVER_S = 1.5 * 3600.0 # off watch: fatigue 1 -> 0 +CREW_FATIGUE_FREE = 0.25 # fatigue below this costs nothing +CREW_FATIGUE_WEIGHT = 0.6 # effectiveness lost per unit above it +CREW_ACTION_BONUS = 1.1 # alert crew at action stations +CREW_MORALE_START = 0.7 +CREW_MORALE_WEIGHT = 0.2 # effectiveness per unit of morale +CREW_MORALE_FATIGUE = 0.5 # low morale tires faster +CREW_DAMAGE_STRESS = 1.5 # fatigue pace while fighting damage +CREW_EFFECT_MIN = 0.5 +CREW_EFFECT_MAX = 1.15 +CREW_SONAR_DB = 10.0 # dB of recognition differential per unit lost + # Missionstypen: Zeitfenster in Echtzeit-Simulationssekunden. # Lange Einsatzfenster lassen Zeit für Aufmerksamkeits- und Suchphasen. # win = "sink" (Ziel versenken) oder "survive" (Zeitlimit überstehen) diff --git a/src/core/crew.py b/src/core/crew.py new file mode 100644 index 00000000..3940d6fe --- /dev/null +++ b/src/core/crew.py @@ -0,0 +1,212 @@ +"""Crew fatigue, watches and morale (frigate and crewed boat). + +The ship's company stands in ``WATCHES`` watch sections. One section is on +duty and tires; the others rest and recover. A watch is relieved +automatically after ``config.CREW_WATCH_S`` (a game assumption: a real +watch is four hours, the game compresses it so a session sees relief), or +early on the operator's order. During the turnover the new watch takes +``config.CREW_TURNOVER_S`` to settle in and works less well. + +Action stations ("general quarters") put every section on duty: the crew +is alert (a bonus) but nobody rests and everybody tires quickly, so it pays +to stand to for an attack and stand down afterwards. + +Morale (0..1) moves with events: tasks done or failed, kills, damage. It +scales how fast the crew tires and, slightly, how well it works. + +``effectiveness()`` is the one number the rest of the game reads. It is +anchored at 1.0 for a normally rotating, fresh crew at the starting morale, +so gameplay calibration at mission start is unchanged; normal watch +rotation keeps the duty watch below ``CREW_FATIGUE_FREE`` and at 1.0. +Every step is deterministic (no random draws). +""" + +from __future__ import annotations + +import math + +from src.core import config + +WATCHES = 3 +VERSION = 1 +STATE_FIELDS = frozenset({ + "version", "fatigue", "on_watch", "watch_t", "turnover_t", + "action_stations", "morale", "kills", "damaged", +}) +MAX_TIME_S = 1e9 +MAX_COUNT = 10_000 + +# Morale events (delta), named by what happened. +MORALE_EVENTS = { + "kill": 0.15, + "damage": -0.06, + "repair": 0.02, + "task_done_sar": 0.12, + "task_done": 0.06, + "task_failed": -0.08, + "task_declined": -0.02, + "watch_change": 0.0, +} + + +def _number(value) -> bool: + return (type(value) in (int, float) and not isinstance(value, bool) + and math.isfinite(value)) + + +class CrewState: + """One ship's watch bill, fatigue and morale.""" + + def __init__(self, sim_t: float = 0.0): + self.fatigue = [0.0] * WATCHES + self.on_watch = 0 + self.watch_t = float(sim_t) # when the duty watch took over + self.turnover_t = None # turnover ends at this sim time + self.action_stations = False + self.morale = config.CREW_MORALE_START + self.kills = 0 # event counters already credited + self.damaged = 0 + + # --- the one number the game reads ------------------------------------- + + def duty_fatigue(self) -> float: + if self.action_stations: + return max(self.fatigue) + return self.fatigue[self.on_watch] + + def in_turnover(self, sim_t: float) -> bool: + return self.turnover_t is not None and sim_t < self.turnover_t + + def effectiveness(self, sim_t: float) -> float: + """Operator performance factor; 1.0 for a fresh crew at start.""" + tired = max(0.0, self.duty_fatigue() - config.CREW_FATIGUE_FREE) + value = 1.0 - config.CREW_FATIGUE_WEIGHT * tired + value *= 1.0 + config.CREW_MORALE_WEIGHT * (self.morale - config.CREW_MORALE_START) + if self.action_stations: + value *= config.CREW_ACTION_BONUS + if self.in_turnover(sim_t): + value *= config.CREW_TURNOVER_FACTOR + return config.clamp(value, config.CREW_EFFECT_MIN, config.CREW_EFFECT_MAX) + + def watch_left_s(self, sim_t: float) -> float | None: + if self.action_stations: + return None + return max(0.0, self.watch_t + config.CREW_WATCH_S - sim_t) + + # --- orders ------------------------------------------------------------ + + def change_watch(self, sim_t: float) -> bool: + """Relieve the duty watch by the most rested section.""" + if self.action_stations: + return False + rested = min((index for index in range(WATCHES) if index != self.on_watch), + key=lambda index: (self.fatigue[index], index)) + self.on_watch = rested + self.watch_t = float(sim_t) + self.turnover_t = float(sim_t) + config.CREW_TURNOVER_S + return True + + def set_action_stations(self, enabled: bool, sim_t: float) -> bool: + enabled = bool(enabled) + if enabled == self.action_stations: + return False + self.action_stations = enabled + if not enabled: + # Stand down: the least tired section keeps the watch. + self.on_watch = min(range(WATCHES), key=lambda index: (self.fatigue[index], index)) + self.watch_t = float(sim_t) + self.turnover_t = float(sim_t) + config.CREW_TURNOVER_S + else: + self.turnover_t = None + return True + + def event(self, name: str) -> None: + delta = MORALE_EVENTS.get(name) + if delta is None: + prefix = name.rsplit("_", 1)[0] + delta = MORALE_EVENTS.get(prefix, 0.0) + self.morale = config.clamp(self.morale + delta, 0.0, 1.0) + + # --- time -------------------------------------------------------------- + + def update(self, dt: float, sim_t: float, stress: float = 1.0) -> bool: + """Advance fatigue; returns True when the watch was relieved.""" + pace = (1.0 + config.CREW_MORALE_FATIGUE * (config.CREW_MORALE_START - self.morale)) + pace = max(0.25, pace) * max(1.0, stress) + for index in range(WATCHES): + if self.action_stations: + rate = pace / config.CREW_TIRE_ACTION_S + elif index == self.on_watch: + rate = pace / config.CREW_TIRE_WATCH_S + else: + rate = -1.0 / config.CREW_RECOVER_S + self.fatigue[index] = config.clamp(self.fatigue[index] + rate * dt, 0.0, 1.0) + if self.turnover_t is not None and sim_t >= self.turnover_t: + self.turnover_t = None + if (not self.action_stations + and sim_t - self.watch_t >= config.CREW_WATCH_S): + return self.change_watch(sim_t) + return False + + # --- save -------------------------------------------------------------- + + def serialize(self) -> dict: + return dict(version=VERSION, fatigue=[float(value) for value in self.fatigue], + on_watch=self.on_watch, watch_t=self.watch_t, + turnover_t=self.turnover_t, + action_stations=self.action_stations, morale=self.morale, + kills=self.kills, damaged=self.damaged) + + @staticmethod + def valid_state(state) -> bool: + if not isinstance(state, dict) or set(state) != STATE_FIELDS: + return False + if type(state["version"]) is not int or state["version"] != VERSION: + return False + fatigue = state["fatigue"] + if (not isinstance(fatigue, list) or len(fatigue) != WATCHES + or not all(_number(value) and 0.0 <= value <= 1.0 for value in fatigue)): + return False + if type(state["on_watch"]) is not int or not 0 <= state["on_watch"] < WATCHES: + return False + if not (_number(state["watch_t"]) and 0.0 <= state["watch_t"] <= MAX_TIME_S): + return False + turnover = state["turnover_t"] + if turnover is not None and not (_number(turnover) and 0.0 <= turnover <= MAX_TIME_S): + return False + if type(state["action_stations"]) is not bool: + return False + if state["action_stations"] and turnover is not None: + return False + if not (_number(state["morale"]) and 0.0 <= state["morale"] <= 1.0): + return False + return all(type(state[key]) is int and 0 <= state[key] <= MAX_COUNT + for key in ("kills", "damaged")) + + @classmethod + def restore(cls, state) -> "CrewState": + if not cls.valid_state(state): + raise ValueError("invalid crew watch state") + crew = cls() + crew.fatigue = [float(value) for value in state["fatigue"]] + crew.on_watch = state["on_watch"] + crew.watch_t = float(state["watch_t"]) + crew.turnover_t = None if state["turnover_t"] is None else float(state["turnover_t"]) + crew.action_stations = state["action_stations"] + crew.morale = float(state["morale"]) + crew.kills = state["kills"] + crew.damaged = state["damaged"] + return crew + + +BOAT_DAMAGE_STEP = 10.0 # boat damage points per morale "damage" event + + +def stress(fighting_damage: bool) -> float: + """Fatigue pace factor: fighting fire and flooding wears a crew out.""" + return config.CREW_DAMAGE_STRESS if fighting_damage else 1.0 + + +def sonar_penalty_db(effectiveness: float) -> float: + """Extra recognition differential of a tired (or alert) sonar watch.""" + return config.CREW_SONAR_DB * (1.0 - effectiveness) diff --git a/src/core/game.py b/src/core/game.py index bdf231c1..465d97bd 100644 --- a/src/core/game.py +++ b/src/core/game.py @@ -82,10 +82,11 @@ from src.core.game_draw import (DrawMixin) from src.core.game_operator import (OperatorMixin) from src.core.game_pictures import (PicturesMixin) from src.core.game_tasking import TaskingMixin +from src.core.game_crew import CrewMixin class Game(PicturesMixin, OperatorMixin, DrawMixin, MissionBridgeMixin, EventMixin, SimMixin, - SaveMixin, TaskingMixin): + SaveMixin, TaskingMixin, CrewMixin): # Options overlay rows in display order; the last two open sub-menus. _OPTION_ROWS = ("language", "fullscreen", "audio", "large_text", "tooltips", "simlog", "night_mode", "high_contrast", "frame_rate", @@ -306,12 +307,17 @@ class Game(PicturesMixin, OperatorMixin, DrawMixin, MissionBridgeMixin, EventMix return None sub.claim_manual() self._opfor = opfor.CrewedBoat(sub, self.runtime_catalog) + self._opfor.watch = self._boat_watch(self._opfor) + self._apply_crew_effects() return self._opfor def release_opfor_sub(self) -> None: """Hand the crewed submarine back to the AI.""" boat = self._opfor self._opfor = None + if boat is not None: + # The AI crew works at the calibrated pace again. + boat.sub.damage_control.crew_factor = 1.0 if boat is not None and boat.sub in self.subs and not boat.sub.sunk: boat.sub.release_manual() @@ -394,6 +400,8 @@ class Game(PicturesMixin, OperatorMixin, DrawMixin, MissionBridgeMixin, EventMix self.score = 0 # HQ orders and incidents (save ``tasking``); none in custom missions. self._reset_tasking() + # Watches, fatigue and morale of the frigate crew (save ``watch``). + self._reset_crew() self.mission_result = None # None | "SIEG" | "VERLOREN" self.result_reason = "" diff --git a/src/core/game_crew.py b/src/core/game_crew.py new file mode 100644 index 00000000..205b1173 --- /dev/null +++ b/src/core/game_crew.py @@ -0,0 +1,167 @@ +"""Crew watches, fatigue and morale in the game (frigate and crewed boat). + +``src/core/crew.py`` holds the model; this mixin advances it, credits +morale events from the world (kills, damage, tasks) and hands the crew's +effectiveness to the sonar operator, the lookout and the damage-control +teams. The effects are derived from saved state, so a load re-applies +them exactly (``_apply_crew_effects``). +""" + +from __future__ import annotations + +from src.core import crew as crew_model +from src.core.crew import CrewState +from src.core.i18n import message + + +class CrewMixin: + """Crew watch bill of the frigate and the crewed submarine.""" + + def _reset_crew(self) -> None: + self.crew_watch = CrewState(self.sim_t) + + def _boat_watch(self, boat) -> CrewState: + """A fresh watch bill for a newly crewed boat; past events are not + credited again.""" + watch = CrewState(self.sim_t) + watch.kills = self._boat_sinkings() + watch.damaged = int(boat.sub.damage // crew_model.BOAT_DAMAGE_STEP) + return watch + + def _boat_sinkings(self) -> int: + return (sum(1 for ship in self.civilians if ship.sunk) + + sum(1 for ship in self.warships if ship.sunk) + + int(bool(self.damage.ship_sunk))) + + # --- read by sensors and views ------------------------------------------- + + def crew_effect(self) -> float: + """The frigate crew's performance factor (1.0 fresh at start).""" + watch = getattr(self, "crew_watch", None) + return 1.0 if watch is None else watch.effectiveness(self.sim_t) + + def crew_view(self, watch: CrewState | None = None) -> dict: + """Display state of one crew (the frigate's by default).""" + watch = self.crew_watch if watch is None else watch + return dict( + watches=[dict(index=index + 1, fatigue=watch.fatigue[index], + on_duty=watch.action_stations or index == watch.on_watch) + for index in range(crew_model.WATCHES)], + on_watch=watch.on_watch + 1, + watch_left_s=watch.watch_left_s(self.sim_t), + turnover=watch.in_turnover(self.sim_t), + action_stations=watch.action_stations, + morale=watch.morale, + effectiveness=watch.effectiveness(self.sim_t)) + + # --- orders ------------------------------------------------------------------ + + def set_action_stations(self, enabled: bool): + """Frigate: action stations on/off (Bridge ``G``, Remote Crew).""" + if self.game_over: + return "not_ready" + if not self.crew_watch.set_action_stations(enabled, self.sim_t): + return "not_ready" + self._crew_notice("crew.action_stations_on" if enabled else "crew.action_stations_off") + self._apply_crew_effects() + return True + + def toggle_action_stations(self) -> None: + self.set_action_stations(not self.crew_watch.action_stations) + + def change_watch(self): + """Frigate: relieve the duty watch early (Damage page 3 ``W``).""" + if self.game_over: + return "not_ready" + if not self.crew_watch.change_watch(self.sim_t): + return "not_ready" + self._crew_notice("crew.watch_relieved", + watch=str(self.crew_watch.on_watch + 1)) + self._apply_crew_effects() + return True + + def boat_set_action_stations(self, enabled: bool): + boat = self._opfor + if boat is None or self.game_over: + return "not_ready" + if not boat.watch.set_action_stations(enabled, self.sim_t): + return "not_ready" + self._boat_crew_notice(boat, "crew.action_stations_on" if enabled + else "crew.action_stations_off") + self._apply_crew_effects() + return True + + def boat_change_watch(self): + boat = self._opfor + if boat is None or self.game_over: + return "not_ready" + if not boat.watch.change_watch(self.sim_t): + return "not_ready" + self._boat_crew_notice(boat, "crew.watch_relieved", + watch=str(boat.watch.on_watch + 1)) + self._apply_crew_effects() + return True + + def _crew_event(self, name: str) -> None: + """A morale event of the frigate crew (tasks call this).""" + self.crew_watch.event(name) + + # --- notices ------------------------------------------------------------------- + + def _crew_notice(self, key: str, **params) -> None: + text = message(key, **params) + self.feed.add(self.world.format_time(), "navigation", text) + if getattr(self, "local_side", "frigate") != "uboot": + self.flash(text, 3.0) + + def _boat_crew_notice(self, boat, key: str, **params) -> None: + text = message(key, **params) + boat.notice(self.sim_t, "navigation", text, stamp=self.world.format_time()) + if getattr(self, "local_side", "frigate") == "uboot": + self.flash(text, 3.0) + + # --- time --------------------------------------------------------------------- + + def _update_crew(self, dt: float) -> None: + watch = self.crew_watch + damaged = sum(1 for room in self.damage.compartments.values() if room.state != "OK") + kills = sum(1 for sub in self.subs if sub.side == "hostile" and sub.sunk) + self._credit_morale(watch, kills, damaged) + stress = crew_model.stress(damaged > 0) + if watch.update(dt, self.sim_t, stress) and not self.game_over: + self._crew_notice("crew.watch_relieved", watch=str(watch.on_watch + 1)) + boat = self._opfor + if boat is not None and boat.sub in self.subs: + sub = boat.sub + sunk = self._boat_sinkings() + hurt = int(sub.damage // crew_model.BOAT_DAMAGE_STEP) + self._credit_morale(boat.watch, sunk, hurt) + if (boat.watch.update(dt, self.sim_t, crew_model.stress(hurt > 0)) + and not self.game_over): + self._boat_crew_notice(boat, "crew.watch_relieved", + watch=str(boat.watch.on_watch + 1)) + self._apply_crew_effects() + + @staticmethod + def _credit_morale(watch: CrewState, kills: int, damaged: int) -> None: + for _ in range(max(0, kills - watch.kills)): + watch.event("kill") + watch.kills = max(watch.kills, min(kills, crew_model.MAX_COUNT)) + if damaged > watch.damaged: + for _ in range(damaged - watch.damaged): + watch.event("damage") + elif damaged < watch.damaged: + for _ in range(watch.damaged - damaged): + watch.event("repair") + watch.damaged = min(damaged, crew_model.MAX_COUNT) + + def _apply_crew_effects(self) -> None: + """Hand the crews' effectiveness to their sonar and repair teams.""" + effect = self.crew_effect() + self._frigate_sonar.sonar.operator_dt_db = crew_model.sonar_penalty_db(effect) + self.damage.crew_factor = effect + boat = self._opfor + if boat is not None: + boat_effect = boat.watch.effectiveness(self.sim_t) + boat.station.sonar.operator_dt_db = crew_model.sonar_penalty_db(boat_effect) + boat.sub.damage_control.crew_factor = boat_effect diff --git a/src/core/game_events.py b/src/core/game_events.py index 015d1cc8..24f88ae9 100644 --- a/src/core/game_events.py +++ b/src/core/game_events.py @@ -979,6 +979,14 @@ class EventMixin: else: self._assign_selected_team() return + crew_page = self.station is Station.DAMAGE and self.station_page == 2 + if e.key == pygame.K_w and crew_page: + if self.change_watch() is not True: + self.flash(message("crew.watch_blocked"), 2.0) + return + if e.key == pygame.K_g and (self.station is Station.BRIDGE or crew_page): + self.toggle_action_stations() + return if (e.key in (pygame.K_a, pygame.K_d) and self.station is Station.RADIO and self.station_page == 2): if e.key == pygame.K_a: diff --git a/src/core/game_save.py b/src/core/game_save.py index 58919cbe..4f51e442 100644 --- a/src/core/game_save.py +++ b/src/core/game_save.py @@ -32,6 +32,7 @@ from src.enemies.sub import Sub from src.enemies.ballast import BoatBallast from src.enemies.damage_control import BoatDamageControl from src.core.tasking import TaskBoard +from src.core.crew import CrewState from src.enemies.endurance import SubmarineEndurance from src.enemies.surface import SurfaceShip from src.sensors.tracks import TrackPicture @@ -460,6 +461,7 @@ class SaveMixin: "mission_time": self.mission_time, "mission_events": list(self.mission_events_pending), "tasking": self.tasking.serialize(), + "watch": self.crew_watch.serialize(), "ping_intercepts": [list(row) for row in sorted(self._ping_intercepts)], "score": self.score, "incident": self.incident, @@ -999,6 +1001,7 @@ class SaveMixin: self.mission_events_pending = [str(item) for item in data["mission_events"]] self.tasking = TaskBoard.restore(data["tasking"]) self.task_sel = 0 + self.crew_watch = CrewState.restore(data["watch"]) self._ping_intercepts = [tuple(row) for row in data["ping_intercepts"]] self.score = data["score"] self.incident = data["incident"] @@ -1520,6 +1523,7 @@ class SaveMixin: self.flights._spawn_cd = flight_data["spawn_cd"] self._restore_sonar_system(data.get("sonar"), by_id) self._restore_crew(data["crew"], by_id) + self._apply_crew_effects() settings = data["weapon_settings"] self.torpedo_type = settings["torpedo_type"] self.torpedo_pattern = settings["pattern"] diff --git a/src/core/game_sim.py b/src/core/game_sim.py index c2dd9439..8cf8ca17 100644 --- a/src/core/game_sim.py +++ b/src/core/game_sim.py @@ -1133,6 +1133,7 @@ class SimMixin: def _update_damage_and_mission(self, dt: float) -> None: """Fortschritt von Schaden, Flugverkehr und Missionszielen.""" + self._update_crew(dt) self.damage.update(dt, draft_m=self.ship.dynamic_draft_m()) self.flights.update(dt, world=self.world, near=(self.ship.x, self.ship.y)) @@ -1363,8 +1364,10 @@ class SimMixin: dx, dy = actor.x - self.ship.x, actor.y - self.ship.y distance = math.hypot(dx, dy) environment = self._lookout_environment() - margin = LOOKOUT_MODEL.margin(kind, distance, altitude_m=altitude_m, - **environment) + # A tired lookout needs more contrast (crew watch, 1.0 when fresh). + alert = self.crew_effect() + margin = alert * LOOKOUT_MODEL.margin(kind, distance, altitude_m=altitude_m, + **environment) if (margin < 1.0 or self.world.land_blocks_line( self.ship.x, self.ship.y, actor.x, actor.y)): return @@ -1390,12 +1393,12 @@ class SimMixin: if LOOKOUT_MODEL.margin( kind, distance, altitude_m=altitude_m, detail=lookout_id.RECOGNIZE_CYCLES / lookout_id.CLASS_SIZE[recognized], - **environment) >= 1.0: + **environment) * alert >= 1.0: level = lookout_id.RECOGNIZED if LOOKOUT_MODEL.margin( kind, distance, altitude_m=altitude_m, detail=lookout_id.IDENTIFY_CYCLES / lookout_id.CLASS_SIZE[identified], - **environment) >= 1.0: + **environment) * alert >= 1.0: level = lookout_id.IDENTIFIED previous = self.air_picture.current(track_id, self.sim_t) previous_level = (lookout_id.decode(previous.label)[0] diff --git a/src/core/help.py b/src/core/help.py index 572d4415..be52d849 100644 --- a/src/core/help.py +++ b/src/core/help.py @@ -48,8 +48,10 @@ STATION_HELP = { ("U", "help.control.course_input"), ("V", "help.control.speed_input"), ("+ / -", "help.control.engine_order"), ("help.key.chart", "help.control.mouse_map"), ("Q / E", "help.control.zoom"), ("K", "help.control.follow"), - (", / .", "help.bridge.lookout_range"), ("B", "help.bridge.lookout_glasses")], - ["help.note.bridge_noise", "help.note.bridge_coast"], "help.note.bridge_tactic"), + (", / .", "help.bridge.lookout_range"), ("B", "help.bridge.lookout_glasses"), + ("G", "help.control.action_stations")], + ["help.note.bridge_noise", "help.note.bridge_coast", "help.note.crew"], + "help.note.bridge_tactic"), Station.SONAR: _station( "help.sonar.intro", [("Shift+A", "help.control.active_ping"), ("Shift+B", "help.control.array"), @@ -106,9 +108,11 @@ STATION_HELP = { [("<- / ->", "help.control.compartment"), ("help.key.up_down", "help.control.team"), ("Enter", "help.control.assign"), ("Backspace", "help.control.withdraw"), ("C", "help.control.counterflood"), + ("W", "help.control.watch_change"), ("G", "help.control.action_stations"), ("1-9", "help.control.station_only"), ("control.help.click", "control.help.compartment")], ["help.note.damage_states", "help.note.destroyed", "help.note.sinking", - "help.note.fire", "help.note.assignment", "help.note.counterflood"], + "help.note.fire", "help.note.assignment", "help.note.counterflood", + "help.note.crew"], "help.note.damage_tactic"), Station.OPZ: _station( "help.opz.intro", @@ -255,6 +259,8 @@ _UBOOT_HELP = ( ("help.key.arrows", "help.uboot.dc_select"), ("help.key.enter", "help.uboot.dc_team"), ("I", "help.uboot.dc_bulkhead"), + ("M", "help.uboot.watch_change"), + ("B", "help.uboot.action_stations"), ("0", "help.uboot.weather"), ("S / L / F9", "help.uboot.admin"), ], diff --git a/src/core/i18n.py b/src/core/i18n.py index 5e744f63..b09fdfe6 100644 --- a/src/core/i18n.py +++ b/src/core/i18n.py @@ -144,6 +144,7 @@ DISPLAY_KEYS = { "RADIO_HFDF": "station.page.radio_hfdf", "RADIO_MESSAGES": "station.page.radio_messages", "RADIO_TASKS": "station.page.radio_tasks", + "DAMAGE_CREW": "station.page.damage_crew", "ENGINE_TELEGRAPH": "station.page.engine_telegraph", "ENGINE_SYSTEMS": "station.page.engine_systems", "HELO_STATUS": "station.page.helo_status", diff --git a/src/core/opfor.py b/src/core/opfor.py index 99368e2e..6be50c60 100644 --- a/src/core/opfor.py +++ b/src/core/opfor.py @@ -15,6 +15,7 @@ import math from src.core import config, detrand from src.core.boat_esm import BoatESM +from src.core.crew import CrewState from src.core.i18n import message from src.core.plot import PlotLayer from src.physics import torpedo_dyn @@ -209,6 +210,9 @@ class CrewedBoat: self.sub_id = sub.id self.orders = CrewOrders() sub.crew = self.orders + # Watches, fatigue and morale of the boat's crew (saved; the game + # replaces it with one that knows the current sim time on claim). + self.watch = CrewState() platform = SubSonarPlatform(sub) sonar = SonarSystem(seed=(int(sub.sensor_seed) ^ _SONAR_SEED_SALT) & 0x7FFFFFFF, acoustic_profiles=runtime_catalog.acoustic_profiles) @@ -252,7 +256,8 @@ class CrewedBoat: plot=self.plot.to_save(), esm=self.esm.to_save(), feed=[dict(row) for row in self.feed], - feed_seq=int(self.feed_seq)) + feed_seq=int(self.feed_seq), + watch=self.watch.serialize()) def restore(self, data: dict) -> None: self.orders.restore(data["orders"]) @@ -262,6 +267,7 @@ class CrewedBoat: self.esm = BoatESM.from_save(data["esm"]) self.feed = deque((dict(row) for row in data["feed"]), maxlen=OPFOR_FEED_MAX) self.feed_seq = data["feed_seq"] + self.watch = CrewState.restore(data["watch"]) def sonar_targets(self, game) -> list: """Everything this boat's sonar can hear (never the boat itself).""" @@ -598,12 +604,15 @@ def update_sightings(game, boat: CrewedBoat) -> None: epoch = math.floor((now + 1e-9) / config.LOOKOUT_EPOCH_S) previous = {row["ref"]: row for row in orders.sightings} rows = [] + # A tired watch on the periscope needs more contrast (1.0 when fresh). + alert = boat.watch.effectiveness(game.sim_t) for target_id, actor, cls, length_m, altitude_m in _scope_candidates(game, boat): dx, dy = actor.x - sub.x, actor.y - sub.y distance = math.hypot(dx, dy) kind = SIGHTING_KINDS[cls] - margin = _SCOPE_MODEL.margin(kind, distance, altitude_m=altitude_m, - eye_m=config.UBOOT_SCOPE_EYE_HEIGHT_M, **environment) + margin = alert * _SCOPE_MODEL.margin(kind, distance, altitude_m=altitude_m, + eye_m=config.UBOOT_SCOPE_EYE_HEIGHT_M, + **environment) if margin < 1.0 or game.world.land_blocks_line(sub.x, sub.y, actor.x, actor.y): continue recognized = cls @@ -612,7 +621,7 @@ def update_sightings(game, boat: CrewedBoat) -> None: eye_m=config.UBOOT_SCOPE_EYE_HEIGHT_M, detail=lookout_id.RECOGNIZE_CYCLES / lookout_id.CLASS_SIZE[_RECOGNIZE_CLASS[cls]], - **environment) < 1.0: + **environment) * alert < 1.0: recognized = "unknown" true_bearing = math.degrees(math.atan2(dx, -dy)) % 360.0 error = (0.7 * detrand.normal(seed, "scope-bias", target_id) diff --git a/src/core/save_schema.py b/src/core/save_schema.py index b477b796..f50167c5 100644 --- a/src/core/save_schema.py +++ b/src/core/save_schema.py @@ -24,7 +24,7 @@ SAVE_ROOT_FIELDS = frozenset({ "schedulers", "rngs", "ui", "autocrew", "ais", "plot", "crew", "weapon_settings", "mission_events", - "ping_intercepts", "tasking", + "ping_intercepts", "tasking", "watch", }) # Save v16: foreign active pings still travelling to the frigate, as @@ -37,7 +37,7 @@ WEAPON_SETTINGS_FIELDS = frozenset({"torpedo_type", "pattern", "enable_nm", "sal # Save v15: the crewed submarine binding (``Game._opfor``), or None. CREW_FIELDS = frozenset({ "sub_id", "orders", "command_page", "chart_follow", "plot", "esm", "feed", - "feed_seq", "hold_s", "station", + "feed_seq", "hold_s", "station", "watch", }) CREW_ORDERS_FIELDS = frozenset({ "silent", "bottomed", "mast", "alarm_seq", "ping_bearing", diff --git a/src/core/save_validate.py b/src/core/save_validate.py index df6507d7..eb04b476 100644 --- a/src/core/save_validate.py +++ b/src/core/save_validate.py @@ -35,6 +35,7 @@ from src.data.catalog import CATALOG, catalog_from_runtime_snapshot from src.enemies.ballast import BoatBallast from src.enemies.damage_control import BoatDamageControl from src.core.tasking import TaskBoard +from src.core.crew import CrewState from src.enemies.endurance import SubmarineEndurance from src.sensors.esm import valid_esm_state from src.sensors.platform import validate_suite_state @@ -108,6 +109,9 @@ def _valid_crew_block(data, *, valid_sonar, valid_sonar_controls, entity_ids, if (not identity(sub_id) or sub_id not in sub_rows or manual_ids != {sub_id}): return False + if (not CrewState.valid_state(crew["watch"]) + or crew["watch"]["watch_t"] > data.get("sim_t", 0.0)): + return False torpedo_ids = {row.get("id") for row in data.get("enemy_torpedoes", ()) if isinstance(row, dict)} @@ -437,6 +441,10 @@ def valid_save_document(data, runtime_catalog=None) -> bool: for item in pending_events) or len(set(pending_events)) != len(pending_events)): return False + # Save v21: the frigate crew's watch bill, fatigue and morale. + watch = data.get("watch") + if not CrewState.valid_state(watch) or watch["watch_t"] > save_sim_t: + return False # Save v21: the radio tasking board; a task's ship must be in this save. board = data.get("tasking") if not TaskBoard.valid_state(board): diff --git a/src/core/uboot_local.py b/src/core/uboot_local.py index c3ec1b6b..4d6e7259 100644 --- a/src/core/uboot_local.py +++ b/src/core/uboot_local.py @@ -563,6 +563,12 @@ def _command_key(game, current, key, mods) -> None: team, compartment, current.dc_task), team=team + 1, compartment=message(f"uboot.compartment.{compartment}"), task=message(f"uboot.dc.task.{current.dc_task}")) + elif page == "UBOOT_DAMAGE" and key == pygame.K_m: + if order_allowed(game, "uboot_watch_change") and game.boat_change_watch() is not True: + game.flash(message("crew.watch_blocked"), 2.0) + elif key == pygame.K_b and not mods & pygame.KMOD_SHIFT: + if order_allowed(game, "uboot_action_stations"): + game.boat_set_action_stations(not current.watch.action_stations) elif page == "UBOOT_DAMAGE" and key == pygame.K_i: if order_allowed(game, "uboot_bulkhead"): compartment = damage_control.COMPARTMENTS[current.dc_selected diff --git a/src/enemies/damage_control.py b/src/enemies/damage_control.py index 64674460..1a25de70 100644 --- a/src/enemies/damage_control.py +++ b/src/enemies/damage_control.py @@ -54,6 +54,8 @@ class BoatDamageControl: for _ in range(TEAMS)] self.hits = 0 # counter for the hit draws self.pumping = False # this step (display) + # Crew watch performance (derived from the crew state, not saved). + self.crew_factor = 1.0 # --- derived ----------------------------------------------------------- @@ -235,6 +237,7 @@ class BoatDamageControl: index = COMPARTMENTS.index(team["compartment"]) c = self.compartments[index] rate = config.UBOOT_DC_GAS_FACTOR if c.chlorine >= 0.5 else 1.0 + rate *= self.crew_factor swamped = c.water_kg >= 0.9 * capacity_kg(index) task = team["task"] if task == "seal" and not swamped: @@ -243,7 +246,8 @@ class BoatDamageControl: c.fire = max(0.0, c.fire - rate * dt / config.UBOOT_DC_FIRE_FIGHT_S) elif task == "pump" and c.water_kg > 0.0: pump = config.UBOOT_DC_PUMP_KG_S * (1.0 if power else config.UBOOT_DC_HAND_PUMP) - c.water_kg = max(0.0, c.water_kg - rate * pump * dt) + gas = config.UBOOT_DC_GAS_FACTOR if c.chlorine >= 0.5 else 1.0 + c.water_kg = max(0.0, c.water_kg - gas * pump * dt) self.pumping = self.pumping or power # --- crew orders ------------------------------------------------------- diff --git a/src/ship/damage.py b/src/ship/damage.py index d9aaa20f..56994e92 100644 --- a/src/ship/damage.py +++ b/src/ship/damage.py @@ -180,6 +180,8 @@ class DamageModel: def __init__(self, rng: random.Random, repair_mult: float = 1.0): self.rng = rng self.repair_mult = repair_mult # M7: Level-Faktor Reparaturrate + # Crew watch performance (derived from the crew state, not saved). + self.crew_factor = 1.0 self.compartments = {k: Compartment(k, n) for k, n in COMPARTMENTS} self.teams: dict[int, str | None] = {1: None, 2: None, 3: None} # Where each team stands and how long until it arrives (saved). @@ -445,8 +447,9 @@ class DamageModel: """Flood/fire removal per second with the current team assignment.""" count = len(self.teams_on(key)) factor = 0.0 if not count else 1.0 + .6 * (count - 1) - return (config.DMG_REPAIR_RATE * self.repair_mult * factor, - config.DMG_FIRE_REPAIR_RATE * count) + crew = self.crew_factor + return (config.DMG_REPAIR_RATE * self.repair_mult * factor * crew, + config.DMG_FIRE_REPAIR_RATE * count * crew) def _inflow_pct_s(self, c: Compartment) -> float: geo = c.geometry diff --git a/src/sonar/equation.py b/src/sonar/equation.py index 8d271815..0e4be2d9 100644 --- a/src/sonar/equation.py +++ b/src/sonar/equation.py @@ -183,13 +183,16 @@ def passive_terms(*, frequency_hz: float, distance_nm: float, own_range_factor: float, array_range_factor: float, sea_state: float, rain: float, shipping_contacts: int, sensitivity_db: float = 0.0, - hull_self_noise: bool = True) -> PassiveTerms: + hull_self_noise: bool = True, + threshold_db: float = 0.0) -> PassiveTerms: """Assemble the passive sonar equation for one band. ``target_bonus`` is the 1.0.0 source-level multiplier (louder target), expressed here as +20 log10 dB of source level; the array factor becomes directivity; path excess (layer, surface/bottom/refraction) and the Francois-Garrison absorption replace the legacy fixed absorption. + ``threshold_db`` is the operator's recognition differential above the + calibrated 0 dB (a tired watch needs a stronger signal). """ anchor = passive_figure_of_merit_offset(frequency_hz) source = anchor + 20.0 * math.log10(max(target_bonus, 1e-6)) @@ -208,7 +211,7 @@ def passive_terms(*, frequency_hz: float, distance_nm: float, directivity -= reference_noise_db(frequency_hz) - ambient_noise_db( frequency_hz, REFERENCE_SEA_STATE) return PassiveTerms(frequency_hz, source, transmission, noise, directivity, - 0.0) + threshold_db) # --- active --------------------------------------------------------------------- diff --git a/src/sonar/sonar.py b/src/sonar/sonar.py index 252a879c..03677dd1 100644 --- a/src/sonar/sonar.py +++ b/src/sonar/sonar.py @@ -688,6 +688,9 @@ class SonarSystem: def __init__(self, seed: int = 42, acoustic_profiles=None): self.rng = random.Random(seed + 1000) self.acoustic_profiles = acoustic_profiles + # Crew watch: extra recognition differential of the operator (dB), + # set by the game from the crew state (derived, never saved). + self.operator_dt_db = 0.0 self.contacts: dict[int, Contact] = {} self._tracks: dict[int, BearingTrack] = {} self._next_contact_id = 1 @@ -1165,7 +1168,8 @@ class SonarSystem: own_range_factor=own_factor, array_range_factor=array_factor, sea_state=sea_state, rain=float(getattr(world, "rain_intensity", 0.0)), - shipping_contacts=self.shipping_contacts) + shipping_contacts=self.shipping_contacts, + threshold_db=self.operator_dt_db) def update_dipping_passive(self, dt: float, t: float, helicopter, targets, world, range_factor: float = 1.0) -> None: diff --git a/src/ui/observations.py b/src/ui/observations.py index 309572a6..977794f2 100644 --- a/src/ui/observations.py +++ b/src/ui/observations.py @@ -127,9 +127,9 @@ def position_age(observation, now: float): TELEMETRY_KEYS = ("telemetry.course_speed", "telemetry.noise", "telemetry.sea_state", "telemetry.flooding", "telemetry.torpedoes", "telemetry.vls_chaff", - "telemetry.helo_roe") + "telemetry.helo_roe", "telemetry.crew") TICKER_KEYS = ("telemetry.course_speed", "telemetry.noise", - "telemetry.flooding", "telemetry.torpedoes") + "telemetry.flooding", "telemetry.torpedoes", "telemetry.crew") def telemetry_rows(game) -> list: @@ -155,6 +155,13 @@ def telemetry_rows(game) -> list: helo=message("telemetry.helo.airborne" if game.helo.airborne else "telemetry.helo.hangar"), roe=raw_roe(game.roe)) + view = game.crew_view() + crew_short = message("telemetry.value.crew_action" if view["action_stations"] + else "telemetry.value.percent", + value=f"{view['effectiveness'] * 100:.0f}") + crew = message("telemetry.value.crew", value=crew_short, + morale=f"{view['morale'] * 100:.0f}") + crew_level = "warn" if view["effectiveness"] < 0.9 else "ok" return [ ("telemetry.course_speed", course_speed, "ok", course_speed), ("telemetry.noise", noise, "warn" if ship.cavitating else "ok", noise), @@ -177,6 +184,7 @@ def telemetry_rows(game) -> list: message("telemetry.value.count", count=game.vls_cells, total=game.vls_loadout_total)), ("telemetry.helo_roe", helo_roe, "ok", helo_roe), + ("telemetry.crew", crew, crew_level, crew_short), ] diff --git a/src/ui/stations/damage.py b/src/ui/stations/damage.py index 565cf7e3..734618b5 100644 --- a/src/ui/stations/damage.py +++ b/src/ui/stations/damage.py @@ -102,6 +102,8 @@ def damage_regions(game=None, station_rect=None, page=0) -> dict: def damage_compartment_at(game, pos, page=0): """Return compartment ID for polygon OR callout, otherwise None; no mutation.""" + if page not in (0, 1): + return None regions = damage_regions(game, page=page) if pos is None or not regions["station"].collidepoint(pos): return None @@ -131,6 +133,9 @@ def draw_damage_view(game, tr=None) -> None: items = list(game.damage.compartments.items()) selected_key, selected = items[game.dmg_cursor] + if page == 2: + _draw_crew(game, s, rect) + return if page == 0: plan = regions["schematic"] layout.record_geometry("schematic", plan, "damage.schematic.title") @@ -266,3 +271,82 @@ def draw_damage_view(game, tr=None) -> None: ("Enter", "damage.footer.assign"), ("Backspace", "damage.footer.withdraw"), )) + + +def crew_lines(view) -> dict: + """Localized crew facts for the crew page (and its tests).""" + left = view["watch_left_s"] + if view["action_stations"]: + relief = message("crew.relief.action_stations") + elif view["turnover"]: + relief = message("crew.relief.turnover") + else: + relief = message("crew.relief.in", minutes=f"{left // 60:.0f}", + seconds=f"{left % 60:02.0f}") + effect = view["effectiveness"] + from src.core.crew import sonar_penalty_db + return dict( + state=message("crew.state.action_stations" if view["action_stations"] + else "crew.state.watch", watch=str(view["on_watch"])), + relief=relief, + effectiveness=message("crew.effectiveness", value=f"{effect:.0%}"), + morale=message("crew.morale", value=f"{view['morale']:.0%}"), + sonar=message("crew.effect.sonar", db=f"{sonar_penalty_db(effect):+.1f}"), + repair=message("crew.effect.repair", value=f"{effect:.0%}")) + + +def _bar(s, rect, value, color) -> None: + pygame.draw.rect(s, (18, 42, 39), rect) + fill = pygame.Rect(rect) + fill.w = max(0, min(rect.w, round(rect.w * value))) + pygame.draw.rect(s, color, fill) + pygame.draw.rect(s, config.COLOR_GRID, rect, 1) + + +def _draw_crew(game, s, rect) -> None: + """Page 3: watch bill, fatigue, morale and what they do to the crew.""" + view = game.crew_view() + lines = crew_lines(view) + top = _station_content_top(rect, 3) + bottom = rect.bottom - 58 + x, w = rect.x + 16, rect.w - 32 + split = int(w * .5) + left = layout.box(s, (x, top, split - 6, bottom - top), "panel.crew_watches") + right = layout.box(s, (x + split + 6, top, w - split - 6, bottom - top), "panel.crew_state") + lx, ly, lw, _ = left + for row in view["watches"]: + color = config.COLOR_OK if row["on_duty"] else config.COLOR_TEXT_DIM + layout.blit_line(s, message("crew.watch_row", watch=str(row["index"]), + duty=localize("crew.on_duty" if row["on_duty"] + else "crew.off_duty"), + fatigue=f"{row['fatigue']:.0%}"), + (lx, ly, lw, 26), color, size=18) + tired = row["fatigue"] > config.CREW_FATIGUE_FREE + _bar(s, pygame.Rect(lx, ly + 28, lw, 12), row["fatigue"], + config.COLOR_WARN if tired else config.COLOR_OK) + ly += 56 + layout.blit_block(s, "crew.explain", lx, ly, lw, max(1, left[1] + left[3] - ly), + config.COLOR_TEXT_DIM, size=16) + rx, ry, rw, _ = right + effect = view["effectiveness"] + state_color = config.COLOR_WARN if view["action_stations"] else config.COLOR_TEXT + for key, color in (("state", state_color), ("relief", config.COLOR_TEXT)): + layout.blit_line(s, lines[key], (rx, ry, rw, 26), color, size=18) + ry += 30 + layout.blit_line(s, lines["effectiveness"], (rx, ry, rw, 26), + config.COLOR_OK if effect >= .95 else config.COLOR_WARN, size=18) + _bar(s, pygame.Rect(rx, ry + 28, rw, 10), effect / config.CREW_EFFECT_MAX, + config.COLOR_OK if effect >= .95 else config.COLOR_WARN) + ry += 50 + layout.blit_line(s, lines["morale"], (rx, ry, rw, 26), config.COLOR_TEXT, size=18) + _bar(s, pygame.Rect(rx, ry + 28, rw, 10), view["morale"], + config.COLOR_OK if view["morale"] >= .5 else config.COLOR_WARN) + ry += 50 + for key in ("sonar", "repair"): + layout.blit_line(s, lines[key], (rx, ry, rw, 24), config.COLOR_TEXT_DIM, size=16) + ry += 28 + footer_y = rect.bottom - 52 + _shortcut_footer(s, (rect.x + 16, footer_y + 26, rect.w - 32, 19), ( + ("W", "damage.footer.watch"), + ("G", "damage.footer.action_stations"), + )) diff --git a/src/ui/stations_view.py b/src/ui/stations_view.py index 8bb8e107..9624ddba 100644 --- a/src/ui/stations_view.py +++ b/src/ui/stations_view.py @@ -329,7 +329,7 @@ def station_hit_target(game, pos): max_total=str(len(game.damage.compartments) * 100)), "tooltip.compartment_controls", target_id="damage:schematic") - elif regions["detail"].collidepoint(pos): + elif page == 1 and regions["detail"].collidepoint(pos): selected = items[game.dmg_cursor][1] assignment = game.damage.teams[game.dmg_team] return layout.tooltip_payload( diff --git a/src/ui/uboot_damage.py b/src/ui/uboot_damage.py index 2be1520a..aae6f7e0 100644 --- a/src/ui/uboot_damage.py +++ b/src/ui/uboot_damage.py @@ -128,6 +128,15 @@ def draw_damage_page(s, game, boat, x, y, w, h) -> None: f"uboot.compartment.{team['compartment']}"), task=message(f"uboot.dc.task.{team['task']}"))) rows.append((message("uboot.dc.label.team", number=number + 1), state, None)) + watch = boat.watch + rows.append(("uboot.dc.label.crew", message( + "uboot.dc.crew", state=message( + "uboot.dc.crew_action" if watch.action_stations else "uboot.dc.crew_watch", + watch=str(watch.on_watch + 1)), + effect=f"{watch.effectiveness(game.sim_t) * 100:.0f}", + fatigue=f"{watch.duty_fatigue() * 100:.0f}", + morale=f"{watch.morale * 100:.0f}"), + config.COLOR_WARN if watch.effectiveness(game.sim_t) < 0.9 else None)) rows.append(("uboot.dc.label.order", message( "uboot.dc.order", compartment=message(f"uboot.compartment.{COMPARTMENTS[selected]}"), task=message(f"uboot.dc.task.{task}")), config.COLOR_WARN)) diff --git a/src/ui/uboot_view.py b/src/ui/uboot_view.py index 5ffdbb53..6acc014e 100644 --- a/src/ui/uboot_view.py +++ b/src/ui/uboot_view.py @@ -652,7 +652,8 @@ _FOOTERS = { ("Z", "uboot.footer.trim_auto")), ("uboot_engine", "UBOOT_DAMAGE"): (("↑/↓ ←/→", "uboot.footer.dc_pick"), ("help.key.enter", "uboot.footer.dc_team"), - ("I", "uboot.footer.dc_bulkhead")), + ("I", "uboot.footer.dc_bulkhead"), + ("M", "uboot.footer.watch")), } diff --git a/tests/test_boat_damage_control.py b/tests/test_boat_damage_control.py index ca812fd3..1f363c6b 100644 --- a/tests/test_boat_damage_control.py +++ b/tests/test_boat_damage_control.py @@ -207,7 +207,7 @@ def test_damage_control_over_remote_crew_and_projection(): assert sub.damage_control.compartments[_index("engine")].closed assert apply(game, "uboot_bulkhead", {"compartment": "engine", "closed": False}, "uboot_nav") is False - payload = _uboot_damage(sub) + payload = _uboot_damage(game, game.opfor) assert [row["name"] for row in payload["compartments"]] == list(COMPARTMENTS) assert payload["teams"][1]["task"] == "seal" and payload["power"] is True blob = json.dumps(payload) diff --git a/tests/test_commander_assets.py b/tests/test_commander_assets.py index d2d2212a..1241306d 100644 --- a/tests/test_commander_assets.py +++ b/tests/test_commander_assets.py @@ -437,7 +437,8 @@ def test_v2_nonlethal_station_controls_are_native_and_exactly_wired(): "engine_set_telegraph", "engine_set_course", "engine_set_speed", "engine_set_quiet_mode", "damage_assign_team", "damage_unassign_team", "radio_capture_hfdf", - "radio_task_accept", "radio_task_decline", + "radio_task_accept", "radio_task_decline", "crew_action_stations", + "crew_watch_change", "eloka_annotate", "eloka_clear_annotation", "sonar_set_listen_bearing", "sonar_set_focus", "sonar_clear_focus", "sonar_set_array_mode", "sonar_set_tas", "sonar_set_tow_depth", diff --git a/tests/test_commander_commands_v2.py b/tests/test_commander_commands_v2.py index fc662af5..8a191dfa 100644 --- a/tests/test_commander_commands_v2.py +++ b/tests/test_commander_commands_v2.py @@ -619,6 +619,9 @@ def test_fusion_schema_rejects_duplicate_refs_and_action_role_mismatch(server): ("damage", "damage_unassign_team", {"team": 3, "compartment": "engine"}), ("radio", "radio_capture_hfdf", {"ref": "opaque"}), ("radio", "radio_task_accept", {"task": 1}), + ("bridge", "crew_action_stations", {"enabled": True}), + ("damage", "crew_action_stations", {"enabled": False}), + ("damage", "crew_watch_change", {}), ("radio", "radio_task_decline", {"task": 10_000}), ("eloka", "eloka_annotate", {"ref": "opaque", "candidate_ref": "choice"}), ("eloka", "eloka_clear_annotation", {"ref": "opaque"}), diff --git a/tests/test_commander_projections_v2.py b/tests/test_commander_projections_v2.py index 0a31bc2f..ac82ac9a 100644 --- a/tests/test_commander_projections_v2.py +++ b/tests/test_commander_projections_v2.py @@ -109,12 +109,12 @@ def test_role_allowlists_detachment_bounds_and_no_hidden_identifiers(published): game, _, server = published expected = { "bridge": {"navigation", "orders", "threat", "systems", - "tactical_summary", "sightings"}, + "tactical_summary", "sightings", "crew"}, "sonar": {"observations", "settings", "visualization"}, "weapons": {"inventory", "readiness", "designated_target", "navigation", "tactical", "target_choices", "depth_m", "tubes", "settings", "own_weapons", "active_assets"}, - "damage": {"compartments", "teams", "total", "sunk", "stability"}, + "damage": {"compartments", "teams", "total", "sunk", "stability", "crew"}, "opz": {"observations", "fusions", "radar", "source_classifications", "radar_blips", "designated_target_ref", "own_assets", "defense", "asm_observations"}, diff --git a/tests/test_crew_watch.py b/tests/test_crew_watch.py new file mode 100644 index 00000000..3f10c3ef --- /dev/null +++ b/tests/test_crew_watch.py @@ -0,0 +1,217 @@ +"""Crew watches, fatigue and morale (frigate and crewed boat; save v21).""" + +import copy +import json +import sys +from pathlib import Path + +import pygame +import pytest + +from src.core import config, uboot_local +from src.core.crew import CrewState, sonar_penalty_db +from src.core.game import Game +from src.core.station import Station +from src.sonar import equation + +sys.path.insert(0, str(Path(__file__).parent)) +from test_opfor_sub import _crewed # noqa: E402 +from test_uboot_scope import _key, _local_boat # noqa: E402 + + +def _game(seed=5201): + game = Game(seed=seed, start_menu=False, audio_enabled=False) + game.tasking.next_offer_t = 1e9 + return game + + +def _run(game, seconds, dt=5.0): + for _ in range(int(seconds / dt)): + game.sim_t += dt + game._update_crew(dt) + + +def test_a_fresh_crew_is_the_calibrated_crew(): + game = _game() + assert game.crew_effect() == 1.0 + assert game.sonar.operator_dt_db == 0.0 and game.damage.crew_factor == 1.0 + # Normal rotation keeps the duty watch below the free fatigue for hours. + _run(game, 4 * config.CREW_WATCH_S + 120.0) + assert game.crew_watch.duty_fatigue() <= config.CREW_FATIGUE_FREE + assert game.crew_effect() == pytest.approx(1.0) + + +def test_watch_is_relieved_every_hour_with_a_short_turnover(): + game = _game() + _run(game, config.CREW_WATCH_S) + watch = game.crew_watch + assert watch.on_watch == 1 and watch.in_turnover(game.sim_t) + assert game.crew_effect() == pytest.approx(config.CREW_TURNOVER_FACTOR) + _run(game, config.CREW_TURNOVER_S + 5.0) + assert not watch.in_turnover(game.sim_t) and game.crew_effect() == pytest.approx(1.0) + + +def test_action_stations_alert_first_then_tired(): + game = _game() + assert game.set_action_stations(True) is True + assert game.set_action_stations(True) == "not_ready" + assert game.crew_effect() == pytest.approx(config.CREW_ACTION_BONUS) + assert game.change_watch() == "not_ready" # nobody to relieve + _run(game, 90 * 60.0) + assert all(value > 0.9 for value in game.crew_watch.fatigue) + assert game.crew_effect() < 0.8 + assert game.sonar.operator_dt_db > 1.0 + assert game.damage.crew_factor == pytest.approx(game.crew_effect()) + assert game.set_action_stations(False) is True + assert game.crew_watch.watch_left_s(game.sim_t) == config.CREW_WATCH_S + _run(game, 3 * config.CREW_WATCH_S + 120.0) + assert game.crew_effect() == pytest.approx(1.0) # rested again + + +def test_morale_follows_kills_damage_and_tasks(): + game = _game() + start = game.crew_watch.morale + task = game._offer_task("emcon") + game.decline_task(task["id"]) + assert game.crew_watch.morale < start + hostile = next(sub for sub in game.subs if sub.side == "hostile") + hostile.sunk = True + _run(game, 5.0) + assert game.crew_watch.morale > start + morale = game.crew_watch.morale + game.damage.compartments["engine"].state = "BESCHAEDIGT" + _run(game, 5.0) + assert game.crew_watch.morale < morale + _run(game, 5.0) + assert game.crew_watch.damaged == 1 # credited once + + +def test_tired_sonar_needs_a_stronger_signal(): + terms = dict(frequency_hz=300.0, distance_nm=5.0, target_bonus=1.0, + excess_path_loss_db=0.0, absorption_db_per_km=0.0, + legacy_absorption_db=0.0, own_range_factor=1.0, + array_range_factor=1.0, sea_state=3, rain=0.0, shipping_contacts=0) + fresh = equation.passive_terms(**terms) + tired = equation.passive_terms(**terms, threshold_db=sonar_penalty_db(0.8)) + assert fresh.signal_excess_db - tired.signal_excess_db == pytest.approx(2.0) + + +def test_tired_damage_control_is_slower(): + game = _game() + room = game.damage.compartments["engine"] + fresh = game.damage.repair_rates("engine") + game.damage.teams[1] = "engine" + game.damage.team_eta[1] = 0.0 + fresh = game.damage.repair_rates("engine") + game.damage.crew_factor = 0.8 + tired = game.damage.repair_rates("engine") + assert tired[0] == pytest.approx(0.8 * fresh[0]) and tired[1] == pytest.approx(0.8 * fresh[1]) + assert room is game.damage.compartments["engine"] + + +def test_crew_page_keys_and_draw(): + game = _game() + game.station, game.station_page = Station.DAMAGE, 2 + _key(game, pygame.K_g) + assert game.crew_watch.action_stations + _key(game, pygame.K_w) # blocked at action stations + assert game.crew_watch.on_watch == 0 + game.draw() + game.station, game.station_page = Station.BRIDGE, 0 + _key(game, pygame.K_g) + assert not game.crew_watch.action_stations + game.station, game.station_page = Station.DAMAGE, 2 + game.crew_watch.turnover_t = None + _key(game, pygame.K_w) + assert game.crew_watch.on_watch != 0 + game.station, game.station_page = Station.DAMAGE, 0 + before = game.crew_watch.on_watch + _key(game, pygame.K_w) # plan page: no watch order + assert game.crew_watch.on_watch == before + + +def test_crew_state_schema_is_exact(): + state = CrewState(12.0).serialize() + assert CrewState.valid_state(state) + assert CrewState.restore(state).serialize() == state + for key, value in (("morale", 1.5), ("on_watch", 3), ("fatigue", [0.0, 0.0]), + ("turnover_t", float("nan")), ("kills", -1), ("version", 2)): + broken = copy.deepcopy(state) + broken[key] = value + assert not CrewState.valid_state(broken) + broken = dict(state, action_stations=True, turnover_t=20.0) + assert not CrewState.valid_state(broken) + broken = dict(state, extra=1) + assert not CrewState.valid_state(broken) + with pytest.raises(ValueError): + CrewState.restore(broken) + + +def test_save_load_continues_the_watch_bill_identically(): + game = _game() + game.set_action_stations(True) + _run(game, 1200.0) + game.damage.compartments["engine"].state = "BESCHAEDIGT" + _run(game, 5.0) + document = json.loads(json.dumps(game.save_state())) + other = _game() + assert other._load_save_data(document) + assert other.damage.crew_factor == game.damage.crew_factor + assert other.sonar.operator_dt_db == game.sonar.operator_dt_db + for runner in (game, other): + runner.set_action_stations(False) + _run(runner, 1800.0) + assert game.crew_watch.serialize() == other.crew_watch.serialize() + for mutate in (lambda doc: doc.pop("watch"), + lambda doc: doc["watch"].update(watch_t=doc["sim_t"] + 10.0), + lambda doc: doc["watch"].update(morale="high")): + broken = copy.deepcopy(document) + mutate(broken) + assert not other._load_save_data(broken) + + +def test_crewed_boat_has_its_own_watch_bill(): + game, _server, bridge = _crewed() + boat = game.opfor + assert boat.watch.watch_t == game.sim_t + apply = bridge._apply_opfor_action + assert apply(game, "uboot_action_stations", {"enabled": True}, "uboot_engine") is True + assert boat.watch.action_stations and not game.crew_watch.action_stations + assert apply(game, "uboot_watch_change", {}, "uboot") == "not_ready" + assert apply(game, "uboot_action_stations", {"enabled": False}, "uboot_sonar") is False + _run(game, 5400.0) + effect = boat.watch.effectiveness(game.sim_t) + assert effect < 0.8 + assert boat.sub.damage_control.crew_factor == pytest.approx(effect) + assert boat.station.sonar.operator_dt_db == pytest.approx(sonar_penalty_db(effect)) + assert game.sonar.operator_dt_db == 0.0 # the frigate is not tired + document = json.loads(json.dumps(game.save_state())) + assert document["crew"]["watch"] == boat.watch.serialize() + broken = copy.deepcopy(document) + del broken["crew"]["watch"] + assert not game._load_save_data(broken) + game.release_opfor_sub() + assert boat.sub.damage_control.crew_factor == 1.0 + + +def test_boat_keys_order_the_watch_bill(): + game, boat = _local_boat() + uboot_local.set_local_station(game, "uboot_engine") + boat.command_page = 3 + _key(game, pygame.K_b) + assert boat.watch.action_stations + _key(game, pygame.K_b) + assert not boat.watch.action_stations + boat.watch.turnover_t = None + _key(game, pygame.K_m) + assert boat.watch.on_watch != 0 + game.draw() + + +def test_remote_crew_projection(): + from src.commander.projections import _crew + game = _game() + payload = _crew(game) + assert payload["effectiveness"] == 1.0 and payload["on_watch"] == 1 + assert [row["index"] for row in payload["watches"]] == [1, 2, 3] + assert json.loads(json.dumps(payload)) == payload diff --git a/tests/test_save_v12_hygiene.py b/tests/test_save_v12_hygiene.py index f0d97451..b564ddba 100644 --- a/tests/test_save_v12_hygiene.py +++ b/tests/test_save_v12_hygiene.py @@ -19,11 +19,11 @@ def _game(seed=1201): return Game(seed=seed, start_menu=False, audio_enabled=False) -def test_save_is_v20_and_older_documents_are_rejected(): +def test_save_is_v21_and_older_documents_are_rejected(): game = _game() state = json.loads(json.dumps(game.save_state())) - assert (state["version"], state["save_schema"]) == (20, "u-jagd-save-v20") - assert (SAVE_VERSION, SAVE_SCHEMA) == (20, "u-jagd-save-v20") + assert (state["version"], state["save_schema"]) == (21, "u-jagd-save-v21") + assert (SAVE_VERSION, SAVE_SCHEMA) == (21, "u-jagd-save-v21") assert set(state) == SAVE_ROOT_FIELDS before = game.save_state() legacy = copy.deepcopy(state) @@ -86,6 +86,13 @@ def test_save_is_v20_and_older_documents_are_rejected(): for row in v19["subs"]: del row["damage_control"] assert not game._load_save_data(v19) + # v20 differs by HQ tasking and the crew's watch bill. + v20 = copy.deepcopy(state) + v20["version"] = 20 + v20["save_schema"] = "u-jagd-save-v20" + del v20["tasking"] + del v20["watch"] + assert not game._load_save_data(v20) assert game.save_state() == before diff --git a/tests/test_station_page_metadata.py b/tests/test_station_page_metadata.py index 443df8e8..7481dd00 100644 --- a/tests/test_station_page_metadata.py +++ b/tests/test_station_page_metadata.py @@ -15,7 +15,6 @@ SONAR_PAGES = ( TWO_PAGE_STATIONS = { Station.WEAPONS: ("WEAPONS_TARGET", "WEAPONS_AMMO"), - Station.DAMAGE: ("DAMAGE_PLAN", "DAMAGE_DETAIL"), Station.OPZ: ("OPZ_PICTURE", "OPZ_TARGET"), Station.ENGINE: ("ENGINE_TELEGRAPH", "ENGINE_SYSTEMS"), Station.ELOKA: ("ELOKA_INTERCEPTS", "ELOKA_EVIDENCE"), @@ -28,6 +27,7 @@ def test_page_metadata_covers_every_canonical_station(): assert STATION_PAGES[Station.HELICOPTER] == ("HELO_STATUS", "HELO_MISSION", "HELO_SONAR", "HELO_ACOUSTIC") assert STATION_PAGES[Station.BRIDGE] == ("BRIDGE_NAV", "BRIDGE_MISSION", "BRIDGE_LOOKOUT") assert STATION_PAGES[Station.RADIO] == ("RADIO_HFDF", "RADIO_MESSAGES", "RADIO_TASKS") + assert STATION_PAGES[Station.DAMAGE] == ("DAMAGE_PLAN", "DAMAGE_DETAIL", "DAMAGE_CREW") for station, pages in TWO_PAGE_STATIONS.items(): assert STATION_PAGES[station] == pages @@ -38,7 +38,7 @@ def test_page_metadata_covers_every_canonical_station(): assert all(isinstance(page, str) and page for page in pages) assert len(pages) == (6 if station is Station.SONAR else 4 if station is Station.HELICOPTER else - 3 if station in (Station.BRIDGE, Station.RADIO) else 2) + 3 if station in (Station.BRIDGE, Station.RADIO, Station.DAMAGE) else 2) def test_helicopter_sonar_page_wraps(): @@ -71,9 +71,10 @@ def test_two_page_stations_wrap_within_two_pages(station): assert station_page_step(station, 0, -1) == 1 -def test_radio_tasks_page_wraps(): - assert station_page_step(Station.RADIO, 1, 1) == 2 - assert station_page_step(Station.RADIO, 2, 1) == 0 +@pytest.mark.parametrize("station", (Station.RADIO, Station.DAMAGE)) +def test_three_page_stations_wrap(station): + assert station_page_step(station, 1, 1) == 2 + assert station_page_step(station, 2, 1) == 0 def test_station_alias_uses_canonical_opz_metadata(): diff --git a/tools/gen_web_schema.py b/tools/gen_web_schema.py index f0eb2995..6c251567 100644 --- a/tools/gen_web_schema.py +++ b/tools/gen_web_schema.py @@ -43,6 +43,10 @@ def render_block() -> str: lines.append(f" kinds: {_array(schema.RADIO_TASK_KINDS)},\n") lines.append(f" states: {_array(schema.RADIO_TASK_STATES)},\n") lines.append(" };\n") + lines.append(" const crewFields = {\n") + lines.append(f" row: {_array(schema.CREW_FIELDS)},\n") + lines.append(f" watch: {_array(schema.CREW_WATCH_FIELDS)},\n") + lines.append(" };\n") lines.append(" const helicopterTacticalFields = " f"{_array(schema.HELICOPTER_TACTICAL_FIELDS)};\n") lines.append(" const weatherFields = {\n")