mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 12:54:18 +01:00
Hits, fire, flooding and gas wound people at the sonar, weapons and damage-control stations of the frigate and every submarine; empty posts slow recognition, reloading and repairs. Both sides send the medical team and re-man the worst station from the resting watches; AI ships re-man on their own. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ezHkjXB8fqbp1sWev2J9D
37 lines
2.1 KiB
JavaScript
37 lines
2.1 KiB
JavaScript
// 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)});
|
|
const hurt = crew.casualties;
|
|
const rows = [
|
|
["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)})])];
|
|
if (orders.medic) {
|
|
// The wounded: empty posts per station, the medical team, spare hands.
|
|
rows.push(["crew_wounded", t("crew_wounded_value", {wounded: number(hurt.wounded, 0),
|
|
serious: number(hurt.serious, 0), returned: number(hurt.returned, 0)})],
|
|
...hurt.stations.map((row) => [`crew_posts_${row.station}`,
|
|
t("crew_posts_value", {gaps: number(row.gaps, 0), posts: number(row.posts, 0)})]),
|
|
["crew_medic", hurt.medic ? t(`crew_posts_${hurt.medic}`) : "\u2013"],
|
|
["crew_spare", number(hurt.spare, 0)]);
|
|
}
|
|
metrics(list, rows);
|
|
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));
|
|
if (orders.medic) {
|
|
const gaps = hurt.stations.some((row) => row.gaps > 0);
|
|
buttons.push(actionButton("crew_medic_next", orders.medic, {}, gaps));
|
|
buttons.push(actionButton("crew_reassign", orders.reassign, {}, gaps && hurt.spare > 0 && hurt.reassign_in_s <= 0));
|
|
}
|
|
actions.replaceChildren(...buttons);
|
|
}
|