Files
uconsole_asw_game/tests/test_hq_intel.py
T
db9979andClaude Opus 5.5 42bc571c61 Audible sonar echoes, exact HQ threat intel, Remote Crew behind a proxy
Sonar echo:
- Every active return is audible when it arrives, after the two-way travel
  time the simulation already models (ship sonar, dipping sonar, wrecks).
  CW returns are a smeared carrier tone, LFM returns a short 100 Hz sweep;
  the pulse is the one the ping was sent with (audio-only memory, never
  saved), loudness follows the measured echo SNR and faint returns sit in
  reverberation hiss. The ping bus queues an echo behind a busy sound.
- Browser cues sonar_echo_cw/_lfm (+ _faint) with matching synthesis.

HQ intelligence:
- New start-report setting: coarse (bearing/range, as before) or exact
  (every hostile unit type with count and expected air-raid waves, analyser
  names). Patrol is exact, Double hunt and Nuclear intercept coarse, the
  free hunt chooses on its difficulty screen. Kept out of the saved
  difficulty set, so saves stay exact v14.

Remote Crew behind an HTTPS proxy:
- The local game accepts --public-origin https://... (crew and solo): the
  F9 listener then answers on its LAN URL and on exactly that proxy host
  (passed through, rewritten to the upstream, or with :443) and origin;
  cookies are Secure only on the HTTPS path. Without the option nothing
  changes; a proxy with its own host name still gets 403. F9 and the solo
  screen show both addresses. Header values may contain HTAB.
- Checked end to end with Chromium through a TLS proxy: crew and solo,
  direct and proxied, pair and reach the live station view.
- docs/web-host.de.md: local proxy section; no pause and saves v14 (the
  page still claimed a host-absence pause and v10).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 20:15:18 +02:00

66 lines
2.5 KiB
Python

"""HQ start report: coarse position only, or the deployed hostile unit types."""
import re
import pygame
from src.core import config
from src.core.game import Game
from src.core.i18n import localize
def press(game, key):
game.handle_event(pygame.event.Event(pygame.KEYDOWN, key=key))
def intel_reports(game):
return [text for _, text in game.messages
if isinstance(text, dict) and str(text.get("__u_jagd_i18n__", "")
).startswith("runtime.hq.intel")]
def test_patrol_names_the_deployed_submarine_and_other_scenarios_stay_coarse():
game = Game(seed=4711, start_menu=False, audio_enabled=False, language="en")
assert game.scenario_key == "s1_patrouille" and game.hq_intel_mode() == "exact"
[report] = intel_reports(game)
text = localize(report, game.tr)
sub = game.subs[0]
assert text.startswith("HQ: Intelligence confirms")
assert f"1x {sub.stype.profile.name}" in text
for scenario in ("s2_doppeljagd", "s3_abfang"):
game.scenario_key = scenario
game.reset(4711)
assert game.hq_intel_mode() == "coarse" and not intel_reports(game)
def test_free_hunt_menu_row_selects_exact_intel_with_counts_and_air_waves():
game = Game(seed=99, start_menu=True, audio_enabled=False, language="de")
game.main_menu = False
press(game, pygame.K_4)
press(game, pygame.K_RETURN)
assert game.menu_screen == "difficulty"
game.menu_difficulty.update(sub_count=2, warship_count=0, air_raid_count=3)
press(game, pygame.K_UP) # wraps to the HQ intel row
assert game.menu_sel == len(config.DIFFICULTY_FIELD_ORDER)
press(game, pygame.K_RIGHT)
assert game.menu_hq_intel == "exact"
game.draw()
press(game, pygame.K_RETURN)
assert not game.in_menu and game.scenario_key == "s4_zufall"
[report] = intel_reports(game)
text = localize(report, game.tr)
assert "3x Luftangriffswelle" in text
units = re.findall(r"(\d+)x ([^,.]+)", text)
assert sum(int(count) for count, name in units
if "Luftangriff" not in name) == len(game.subs) + len(game.warships)
def test_exact_report_survives_save_and_load():
game = Game(seed=4711, start_menu=False, audio_enabled=False, language="en")
before = localize(intel_reports(game)[0], game.tr)
game.save_to_slot(2)
game.scenario_key = "s2_doppeljagd"
game.reset(5)
assert game.load_from_slot(2)
assert localize(intel_reports(game)[0], game.tr) == before