mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 21:04:18 +01:00
A new main-menu entry "Multiplayer" opens a lobby: Remote Crew starts in crew mode by itself, the uConsole shows QR code, address and join code, the players with their stations and ready ticks, and the host's mission, unit and own station. Browsers see the same crew room above the station cards and tick Ready. The host starts a five-second countdown every browser sees; the mission then begins for all at once and the uConsole opens on its lobby station. A mission started from the lobby returns everyone to the lobby. Ready ticks and the lobby are transient. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CdekJguPyu1j8yasw3BYWx
133 lines
3.9 KiB
JavaScript
133 lines
3.9 KiB
JavaScript
import { defaultSonarPage } from "./shared.js";
|
|
|
|
// Mutable client state shared by several modules. Transient: never sent to
|
|
// the host, stored or placed in the DOM.
|
|
// Pages open in the host's saved language (the server names it in a meta
|
|
// tag); without one, in the browser's.
|
|
export function initialLanguage() {
|
|
const host = document.querySelector('meta[name="u-jagd-host-language"]')?.getAttribute("content");
|
|
if (host === "en" || host === "de") return host;
|
|
return (navigator.language || "en").toLowerCase().startsWith("de") ? "de" : "en";
|
|
}
|
|
|
|
export const S = {
|
|
language: initialLanguage(),
|
|
catalog: {},
|
|
// Session metadata stays closure-local: no URL, DOM or persistence.
|
|
session: null,
|
|
pairingAvailable: false,
|
|
generation: 0,
|
|
snapshot: null,
|
|
chart: null,
|
|
chartSession: null,
|
|
chartEpoch: null,
|
|
chartRole: null,
|
|
selected: null,
|
|
connected: false,
|
|
linkState: "unpaired",
|
|
lastSuccess: 0,
|
|
lastSessionFetch: 0,
|
|
failures: 0,
|
|
pollTimer: null,
|
|
polling: false,
|
|
pending: null,
|
|
v2State: null,
|
|
roleStale: false,
|
|
// Solo host surface: the published host view and the one host command in flight.
|
|
hostView: null,
|
|
hostPending: null,
|
|
hostMessage: null,
|
|
hostMessageTimer: null,
|
|
stationRenderSignature: null,
|
|
nextCommandSeq: 0,
|
|
stationMutation: false,
|
|
activatingStation: null,
|
|
queuedSonarFocus: null,
|
|
// Focus this client last sent, until the state shows it or it is rejected.
|
|
requestedSonarFocus: null,
|
|
stationPickerOpen: false,
|
|
lobbyMessage: null,
|
|
lobbyRoomMessage: null,
|
|
// Unit chosen in the lobby ("frigate" | "opfor"); held stations decide otherwise.
|
|
lobbySide: "frigate",
|
|
commandMessage: null,
|
|
lastToastedMessage: null,
|
|
opzMarked: new Set(),
|
|
opzSuppressed: new Set(),
|
|
opzManage: false,
|
|
stationDrafts: new Set(),
|
|
// Emitter the mast station has selected in the boat's ESM list (by number).
|
|
ubootEsmSelected: null,
|
|
// Bridge route mode: a chart click adds an autopilot waypoint.
|
|
bridgeRouteMode: false,
|
|
requestQueue: Promise.resolve(),
|
|
activeRequest: null,
|
|
languageRequest: 0,
|
|
audio: null,
|
|
soundEnabled: false,
|
|
speechEnabled: false,
|
|
speechQueued: 0,
|
|
calloutContext: null,
|
|
calloutHighWater: 0,
|
|
sonarAudioEnabled: false,
|
|
sonarAudioController: null,
|
|
sonarAudioTimer: null,
|
|
sonarAudioSequence: null,
|
|
sonarAudioNextTime: 0,
|
|
helicopterAudioSource: null,
|
|
sonarAudioSources: [],
|
|
sonarAudioGain: null,
|
|
sonarAudioHighpass: null,
|
|
sonarAudioLowpass: null,
|
|
sonarAudioWorklet: null,
|
|
sonarAudioSocket: null,
|
|
sonarAudioReconnect: null,
|
|
sonarAudioMetrics: {buffered: 0, gaps: 0, concealed: 0, rate: 1, stale: false},
|
|
gameSoundContext: null,
|
|
gameSoundHighWater: 0,
|
|
chartHits: [],
|
|
drag: null,
|
|
activeTab: "operations",
|
|
contactAnalysis: null,
|
|
analysisSelected: null,
|
|
analysisImageKey: null,
|
|
lastSimlogFetch: 0,
|
|
proposals: null,
|
|
eventContext: null,
|
|
eventBaselinePending: false,
|
|
eventHighWater: 0,
|
|
eventHistory: [],
|
|
analysisError: false,
|
|
latestSimlogState: null,
|
|
simlogMapData: null,
|
|
simlogMapSeq: null,
|
|
simlogMapLatest: false,
|
|
simlogMapFit: "world",
|
|
roleMapHits: [],
|
|
// Hover information for the maps (tracks, own ship, assets, chart items);
|
|
// separate from the click hit lists so selection semantics are unchanged.
|
|
roleMapInfo: [],
|
|
chartInfo: [],
|
|
damageHits: [],
|
|
sonarVisualPage: defaultSonarPage(),
|
|
helicopterVisualPage: "acoustic",
|
|
helicopterPlot: "lofar",
|
|
weatherFrame: null,
|
|
weatherTimer: null,
|
|
weatherLastDraw: 0,
|
|
roleMapDrag: null,
|
|
plotAnchor: null,
|
|
plotListKey: "",
|
|
sonarBroadbandDrag: null,
|
|
opzSweepFrame: null,
|
|
opzSweepSample: null,
|
|
fireConfirmation: null,
|
|
fireConfirmationTimer: null,
|
|
sonarAudioGeneration: 0,
|
|
// World session/epoch the live audio last saw; a change resumes the stream.
|
|
sonarAudioWorld: null,
|
|
// Pointer position over the weather profile (CSS px), or null.
|
|
weatherCursor: null,
|
|
webHostAvailable: false,
|
|
};
|