Fix the periscope scale import, own-ship symbol tests, German unit tests and the engine tab

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3tXxmJcADkJ8r7XDY1dq8
This commit is contained in:
Claude committed 2026-10-05 18:14:55 +00:00
1 parent 397f91f7e5
commit 4c076c160e
6 files changed
+30 -25

No files matched your search

+21 -21
View File
@@ -3,27 +3,6 @@ import { ctx } from "../views/canvases.js";
// APP-6 frame dimension of each glyph domain (as src/ui/nato_symbols.py).
const FRAME_DIMENSION = {AIR: "air", ROTARY: "air", MISSILE: "air", SUBSURFACE: "subsurface", UNDERWATER_WEAPON: "subsurface"};
// The APP-6 frame: friend circle, hostile diamond, neutral square, cut to the
// upper half (air, open below) or the lower half (subsurface, open above);
// unknown affiliation: no frame, only the domain glyph (colour marks it).
function drawFrame(context, x, y, affiliation, dimension, half, height) {
const air = dimension === "air", sub = dimension === "subsurface";
if (affiliation === "FRIEND") {
const radius = half + 2;
if (air) context.arc(x, y, radius, Math.PI, Math.PI * 2);
else if (sub) context.arc(x, y, radius, 0, Math.PI);
else context.arc(x, y, radius, 0, Math.PI * 2);
} else if (affiliation === "HOSTILE") {
if (air) { context.moveTo(x - half, y + 2); context.lineTo(x, y - height); context.lineTo(x + half, y + 2); }
else if (sub) { context.moveTo(x - half, y - 2); context.lineTo(x, y + height); context.lineTo(x + half, y - 2); }
else { context.moveTo(x, y - height); context.lineTo(x + half, y); context.lineTo(x, y + height); context.lineTo(x - half, y); context.closePath(); }
} else if (affiliation === "NEUTRAL") {
if (air) { context.moveTo(x - half, y + 3); context.lineTo(x - half, y - height); context.lineTo(x + half, y - height); context.lineTo(x + half, y + 3); }
else if (sub) { context.moveTo(x - half, y - 3); context.lineTo(x - half, y + height); context.lineTo(x + half, y + height); context.lineTo(x + half, y - 3); }
else context.rect(x - half, y - height, half * 2, height * 2);
}
}
// NATO-style symbol, same geometry as the uConsole (src/ui/nato_symbols.py):
// the frame shows the operator's affiliation in the unit's dimension, the
// glyph the domain.
@@ -58,6 +37,27 @@ export function drawNatoSymbol(context, x, y, affiliation, domain, color, size)
}
context.stroke();
}
// The APP-6 frame: friend circle, hostile diamond, neutral square, cut to the
// upper half (air, open below) or the lower half (subsurface, open above);
// unknown affiliation: no frame, only the domain glyph (colour marks it).
function drawFrame(context, x, y, affiliation, dimension, half, height) {
const air = dimension === "air", sub = dimension === "subsurface";
if (affiliation === "FRIEND") {
const radius = half + 2;
if (air) context.arc(x, y, radius, Math.PI, Math.PI * 2);
else if (sub) context.arc(x, y, radius, 0, Math.PI);
else context.arc(x, y, radius, 0, Math.PI * 2);
} else if (affiliation === "HOSTILE") {
if (air) { context.moveTo(x - half, y + 2); context.lineTo(x, y - height); context.lineTo(x + half, y + 2); }
else if (sub) { context.moveTo(x - half, y - 2); context.lineTo(x, y + height); context.lineTo(x + half, y - 2); }
else { context.moveTo(x, y - height); context.lineTo(x + half, y); context.lineTo(x, y + height); context.lineTo(x - half, y); context.closePath(); }
} else if (affiliation === "NEUTRAL") {
if (air) { context.moveTo(x - half, y + 3); context.lineTo(x - half, y - height); context.lineTo(x + half, y - height); context.lineTo(x + half, y + 3); }
else if (sub) { context.moveTo(x - half, y - 3); context.lineTo(x - half, y + height); context.lineTo(x + half, y + height); context.lineTo(x + half, y - 3); }
else context.rect(x - half, y - height, half * 2, height * 2);
}
}
export function drawSymbolOn(context, x, y, domain, color, size, affiliation = "UNKNOWN") {
drawNatoSymbol(context, x, y, affiliation, domain, color, size);
}
+2 -2
View File
@@ -7,7 +7,7 @@
import { drawInScene } from "./model-view.js";
import { DETAIL_MIN_PX, FOAM, NAV_LIGHT, PROFILES } from "./silhouette-profiles.js";
import { drawSightEvents } from "./sight-events.js";
import { palette } from "../core/palette.js";
import { palette as themePalette } from "../core/palette.js";
const SKY_NIGHT = [[3, 7, 16], [20, 44, 62]], SKY_DAY = [[34, 88, 118], [138, 176, 182]], SKY_DUSK = [[24, 30, 60], [204, 128, 78]];
const SEA_NIGHT = [[10, 44, 58], [2, 9, 15]], SEA_DAY = [[24, 78, 92], [6, 34, 46]], SEA_DUSK = [[44, 50, 66], [8, 14, 26]];
@@ -17,7 +17,7 @@ const MOON = [214, 222, 206], MOON_DARK = [26, 34, 42], SUN_DAY = [255, 244, 210
const STEEL_NIGHT = [19, 36, 46], STEEL_DAY = [44, 56, 64], RIM_NIGHT = [84, 150, 158], RIM_DAY = [170, 196, 200];
const WINDOW_LIGHT = [250, 205, 120], FRAME = [40, 96, 90], WIND_ARROW = [120, 214, 180];
// The scale and the crosshair are instrument furniture, not the scene: theme tokens.
const SCALE = () => palette().live, CROSSHAIR = () => palette().accent;
const SCALE = () => themePalette().live, CROSSHAIR = () => themePalette().accent;
const STABILIZED_RESIDUAL = .12; // src/ui/horizon.py
// Below this elevation an aircraft stands on the moving sea horizon in front of the sea (LOW_AIR_DEG).
const LOW_AIR_DEG = 1;
+1
View File
@@ -6743,6 +6743,7 @@
"top.tab.opz": "OPZ",
"top.tab.radio": "FUNK",
"top.tab.engine": "MASCHINE",
"top.tab.engine.short": "MASCH.",
"top.tab.helicopter": "HELI",
"top.tab.eloka": "ELOKA",
"top.status_short": "{scenario} · {time} · {speed} kn · {course}°",
+1
View File
@@ -6743,6 +6743,7 @@
"top.tab.opz": "CIC",
"top.tab.radio": "RADIO",
"top.tab.engine": "ENGINE",
"top.tab.engine.short": "ENG.",
"top.tab.helicopter": "HELO",
"top.tab.eloka": "EW",
"top.status_short": "{scenario} · {time} · {speed} kn · {course}°",
+4 -1
View File
@@ -87,7 +87,10 @@ def test_airborne_helo_uses_readable_friend_air_symbol_above_ship(monkeypatch):
map_view.draw_map_view(game)
center = tuple(map(int, game.map_view.world_to_screen(250.0, 250.0)))
assert calls == [((320.0, 285.0), "FRIEND", "ROTARY", 22)]
# The own frigate wears its APP-6 own-unit frame too (B5); the helicopter
# is the one rotary-wing symbol.
assert [call for call in calls if call[2] == "ROTARY"] == [((320.0, 285.0), "FRIEND", "ROTARY", 22)]
assert [call[1:] for call in calls if call[2] != "ROTARY"] == [("FRIEND", "SURFACE", 16)]
assert game.screen.get_at(center)[:3] == nato_symbols.AFFILIATION_COLORS["FRIEND"]
+1 -1
View File
@@ -39,7 +39,7 @@ def test_full_weapon_solution_and_readiness_fit(game, monkeypatch, language, lar
regions = weapons_view.weapons_regions(game)
solution = [item for item in text if regions["solution"].contains(item["bounds"])]
rendered = "\n".join(item["text"] for item in solution)
assert "6.0 NM" in rendered
assert ("6.0 sm" if language == "de" else "6.0 NM") in rendered
assert translator.t("map.source.buoy") in rendered
assert "PING" not in rendered
assert "145.0" in rendered and "7.0 kn" in rendered and "72%" in rendered