mirror of
https://github.com/db9979/tidefront.git
synced 2026-12-05 12:24:13 +01:00
Ruhige Karte, Nachtrag: Regenschraffur blass auf den Feldern ohne Windfahne, Namensschilder weichen Hafenzeichen aus (eigener Hafen bleibt sichtbar), Stapel-Chip weicht Nachbarzeichen und Schildern aus
This commit is contained in:
1 parent
ad7ebb2cb5
commit
44c8a4a1d0
11 files changed
+218
-46
No files matched your search
@@ -120,7 +120,22 @@ test.describe("Bildschirmfotos 390 px", () => {
|
||||
await page.waitForTimeout(1500);
|
||||
await page.screenshot({ path: `${DIR}/${SHOTS}-${theme}-auswahl.png` });
|
||||
}
|
||||
// Hafen direkt neben einem Handelshafen: Namensschilder weichen aus, Chip verdeckt den Hafen nicht.
|
||||
const taken = await busy(seed.sql);
|
||||
let spot: Hex | null = null;
|
||||
for (let dr = -1; dr <= 1 && !spot; dr++) for (let dc = -1; dc <= 1 && !spot; dc++) {
|
||||
const h = { col: port.col + dc, row: port.row + dr };
|
||||
if ((dc || dr) && terrainAt(h.col, h.row) === "coast" && !taken.has(`${h.col},${h.row}`) && !isTradePortHex(h.col, h.row)) spot = h;
|
||||
}
|
||||
if (spot) {
|
||||
await seed.sql`update base set col = ${spot.col}, row = ${spot.row} where id = ${player.baseId}`;
|
||||
await page.goto("/?tab=karte");
|
||||
await view(page, spot, 0.8);
|
||||
await view(page, spot, 0.8); // nach dem Zentrieren der Karte auf den Hafen erneut
|
||||
await page.screenshot({ path: `${DIR}/${SHOTS}-${theme}-handelshafen.png` });
|
||||
}
|
||||
} finally {
|
||||
await seed.sql`update base set col = ${player.col}, row = ${player.row} where id = ${player.baseId}`;
|
||||
await cleanup(seed.sql, player, s);
|
||||
}
|
||||
});
|
||||
@@ -217,3 +232,43 @@ test("Ruhige Karte: Schalter „Alle Reichweiten“ standardmäßig aus", async
|
||||
const sw = page.getByRole("switch", { name: "Alle Reichweiten (sonst nur Auswahl)" });
|
||||
if (await sw.count()) await expect(sw).toHaveAttribute("aria-checked", "false");
|
||||
});
|
||||
|
||||
test("Ruhige Karte: Hafen neben einem Handelshafen – Namensschilder überlappen nicht, eigenes bleibt sichtbar", async ({ page, player, seed }) => {
|
||||
const port = nearestTradePortBySea(player);
|
||||
const taken = await busy(seed.sql);
|
||||
let spot: Hex | null = null;
|
||||
for (let dr = -1; dr <= 1 && !spot; dr++) for (let dc = -1; dc <= 1 && !spot; dc++) {
|
||||
const h = { col: port.col + dc, row: port.row + dr };
|
||||
if ((dc || dr) && terrainAt(h.col, h.row) === "coast" && !taken.has(`${h.col},${h.row}`) && !isTradePortHex(h.col, h.row)) spot = h;
|
||||
}
|
||||
test.skip(!spot, "kein freies Küstenfeld neben dem Handelshafen");
|
||||
const [b] = await seed.sql`select name from base where id = ${player.baseId}`;
|
||||
await seed.sql`update base set col = ${spot!.col}, row = ${spot!.row} where id = ${player.baseId}`;
|
||||
try {
|
||||
await page.goto("/?tab=karte");
|
||||
for (const scale of [0.6, 0.9, 1.3]) {
|
||||
await view(page, spot!, scale);
|
||||
const tags = await page.evaluate((own) => {
|
||||
type Node = { children?: Node[]; text?: string; parent: Node; visible: boolean; alpha: number; getBounds: () => { x: number; y: number; width: number; height: number } };
|
||||
const app = (window as unknown as { __tfMapApp: { stage: Node } }).__tfMapApp;
|
||||
const out: { text: string; x0: number; y0: number; x1: number; y1: number }[] = [];
|
||||
const shown = (n: Node | null): boolean => !n || (n.visible && n.alpha > 0.05 && shown(n.parent));
|
||||
const walk = (n: Node) => {
|
||||
if (typeof n.text === "string" && /^[A-ZÄÖÜ0-9 ]{4,}$/.test(n.text) && n.parent && shown(n.parent)) {
|
||||
const r = n.parent.getBounds();
|
||||
if (r.width > 0 && r.width < 400) out.push({ text: n.text, x0: r.x, y0: r.y, x1: r.x + r.width, y1: r.y + r.height });
|
||||
}
|
||||
for (const c of n.children ?? []) walk(c);
|
||||
};
|
||||
walk(app.stage);
|
||||
return { own: out.find((t) => t.text === own.toUpperCase()) ?? null, all: out };
|
||||
}, b.name as string);
|
||||
expect(tags.own, `eigenes Namensschild sichtbar (${scale})`).toBeTruthy();
|
||||
const o = tags.own!;
|
||||
const hit = tags.all.filter((t) => t !== o && t.text !== o.text && t.x0 < o.x1 - 1 && t.x1 > o.x0 + 1 && t.y0 < o.y1 - 1 && t.y1 > o.y0 + 1);
|
||||
expect(hit.map((t) => t.text), `kein Schild über dem eigenen (${scale})`).toEqual([]);
|
||||
}
|
||||
} finally {
|
||||
await seed.sql`update base set col = ${player.col}, row = ${player.row} where id = ${player.baseId}`;
|
||||
}
|
||||
});
|
||||
@@ -81,7 +81,7 @@ const GROUPS: { title: string; items: Item[] }[] = [
|
||||
{ icon: <VaneIcon pennant={false} />, text: "Windfahne (auf jedem zweiten Feld, weit herausgezoomt aus): Pfeil zeigt, wohin der Wind weht; je Strich stärker, zwei Striche ab 6 Bft (Schiffe langsamer, dann rot)" },
|
||||
{ icon: <VaneIcon pennant />, text: "Wimpel an der Windfahne: Sturm ab 9 Bft" },
|
||||
{ icon: <StormFlag />, text: "Sturmwimpel: Schiffe langsamer, Flugzeuge schwächer, am eigenen Hafen bleiben sie am Boden; rötlicher Ton: Schiffe gebremst" },
|
||||
{ icon: <Hatch d="M2 14 L14 2 M7 16 L16 7 M0 9 L9 0" color="var(--tf-art-luft)" />, text: "Wolken, Striche darunter: Regen; Wolken schwächen den Luftschlag" },
|
||||
{ icon: <Hatch d="M2 14 L14 2 M7 16 L16 7 M0 9 L9 0" color="var(--tf-art-luft)" />, text: "Wolken, blasse Striche darunter (auf den Feldern ohne Windfahne): Regen; Wolken schwächen den Luftschlag" },
|
||||
{ icon: <Hatch d="M1 6 H4 M7 6 H10 M13 6 H16 M1 11 H4 M7 11 H10 M13 11 H16" color="var(--tf-art-see)" />, text: "Nebel: Aufklärung ungenau, Radar am eigenen Hafen kürzer" },
|
||||
],
|
||||
},
|
||||
|
||||
+12
-4
@@ -32,6 +32,8 @@ export interface Pinned {
|
||||
box?: Bounds;
|
||||
/** Ruhige Karte: Einheit (stack-layer.ts); `hidden` = hinter einem anderen Zeichen gestapelt. */
|
||||
ent?: { hidden?: boolean };
|
||||
/** Belegt Platz, ohne selbst ausgeblendet zu werden (Hafenzeichen): Schilder weichen aus. */
|
||||
solid?: boolean;
|
||||
}
|
||||
|
||||
/** Gegenskalierung: Symbole bleiben etwa gleich groß, wachsen beim Hineinzoomen nur leicht. */
|
||||
@@ -67,6 +69,7 @@ const PAD = 3;
|
||||
export function layout(lists: Pinned[][], scale: number): void {
|
||||
const k = pinScale(scale);
|
||||
const cand: { p: Pinned; x0: number; y0: number; x1: number; y1: number }[] = [];
|
||||
const solids: typeof cand = [];
|
||||
for (const list of lists) {
|
||||
for (const p of list) {
|
||||
if (p.base === undefined) p.base = p.obj.alpha;
|
||||
@@ -74,17 +77,22 @@ export function layout(lists: Pinned[][], scale: number): void {
|
||||
p.obj.scale.set(s);
|
||||
const a = p.ent?.hidden ? 0 : zoomAlpha(p, scale); // gestapelt: ausblenden
|
||||
p.target = a;
|
||||
if (p.prio === undefined || a < 0.05) continue;
|
||||
if ((p.prio === undefined && !p.solid) || a < 0.05) continue;
|
||||
if (!p.box) p.box = p.obj.getLocalBounds().clone();
|
||||
const f = s * scale;
|
||||
const cx = p.obj.x * scale;
|
||||
const cy = p.obj.y * scale;
|
||||
cand.push({ p, x0: cx + p.box.minX * f - PAD, y0: cy + p.box.minY * f - PAD, x1: cx + p.box.maxX * f + PAD, y1: cy + p.box.maxY * f + PAD });
|
||||
const box = { p, x0: cx + p.box.minX * f - PAD, y0: cy + p.box.minY * f - PAD, x1: cx + p.box.maxX * f + PAD, y1: cy + p.box.maxY * f + PAD };
|
||||
if (p.prio === undefined) solids.push(box);
|
||||
else cand.push(box);
|
||||
}
|
||||
}
|
||||
cand.sort((a, b) => a.p.prio! - b.p.prio!);
|
||||
const taken: typeof cand = [];
|
||||
const hits = (c: { x0: number; y0: number; x1: number; y1: number }) => taken.some((t) => c.x0 < t.x1 && c.x1 > t.x0 && c.y0 < t.y1 && c.y1 > t.y0);
|
||||
// Ruhige Karte: Hafenzeichen (solid) belegen zuerst Platz – Namensschilder weichen ihnen aus.
|
||||
const taken: typeof cand = [...solids];
|
||||
// Schild und Zeichen an derselben Stelle (ein Hafen) stören sich nicht.
|
||||
const same = (a: Pinned, b: Pinned) => a.obj.x === b.obj.x && a.obj.y === b.obj.y;
|
||||
const hits = (c: { p: Pinned; x0: number; y0: number; x1: number; y1: number }) => taken.some((t) => c.x0 < t.x1 && c.x1 > t.x0 && c.y0 < t.y1 && c.y1 > t.y0 && !(t.p.solid && same(t.p, c.p)));
|
||||
for (const c of cand) {
|
||||
c.p.obj.pivot.y = 0;
|
||||
if (!hits(c)) { taken.push(c); continue; }
|
||||
|
||||
@@ -58,8 +58,8 @@ export function buildMarkers(s: Scene, data: MapData): StackEntity[] {
|
||||
}
|
||||
const e = unit(`hafen:${b.id}`, STACK_PRIO.base, `Hafen ${b.name} · ${b.owner}`, b.col, b.row);
|
||||
// Übersicht: Punkt in der Farbe des Verhältnisses; Kriegsgegner etwas größer.
|
||||
add(dotSymbol(RELATION_COLOR[rel], rel === "krieg" ? 3.6 : 3, 0.95), b.col, b.row, { max: LOD_OVERVIEW, fixed: true }, e);
|
||||
add(otherBaseSymbol(b.protection !== null, rel), b.col, b.row, { min: LOD_OVERVIEW }, e);
|
||||
add(dotSymbol(RELATION_COLOR[rel], rel === "krieg" ? 3.6 : 3, 0.95), b.col, b.row, { max: LOD_OVERVIEW, fixed: true, solid: true }, e);
|
||||
add(otherBaseSymbol(b.protection !== null, rel), b.col, b.row, { min: LOD_OVERVIEW, solid: true }, e); // Schilder weichen aus
|
||||
if ((b as { jammer?: boolean }).jammer) add(jammerMark(), b.col, b.row, { min: LOD_OVERVIEW }, e); // Stufe 3: Störsender erkannt
|
||||
add(tag, b.col, b.row, { min: LOD_NAMES, fixed: true, prio: PRIO.base }, e);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Container, Graphics, Text } from "pixi.js";
|
||||
import { TEXT_RESOLUTION } from "./density.ts";
|
||||
import { INK, PAPER } from "./symbols.ts";
|
||||
import { pinScale, zoomAlpha, type Pinned } from "./lod.ts";
|
||||
import { stackChipText, stackGroups } from "./stack.ts";
|
||||
import { CHIP_SIDES, chipSide, stackChipText, stackGroups, type Rect } from "./stack.ts";
|
||||
|
||||
type Hex = { col: number; row: number };
|
||||
|
||||
@@ -54,22 +54,55 @@ export function attachPin<P extends { obj: Container }>(ent: StackEntity | undef
|
||||
return p;
|
||||
}
|
||||
|
||||
interface Group { lead: string; keys: string[]; entries: StackEntry[]; badge: Container }
|
||||
interface Group { lead: string; keys: string[]; entries: StackEntry[]; badge: Container; inner: Container; hw: number; side: readonly [number, number] }
|
||||
|
||||
/** Chip: Papierplakette mit Tintenrand und Zahl, rechts oben am Zeichen (Bildschirm-Pixel). */
|
||||
function chip(text: string): Container {
|
||||
const c = new Container();
|
||||
/** Chip: Papierplakette mit Tintenrand und Zahl um (0, 0) (Bildschirm-Pixel); die Seite setzt compute(). */
|
||||
function chip(text: string): { badge: Container; inner: Container; hw: number } {
|
||||
const badge = new Container();
|
||||
const inner = new Container();
|
||||
const t = new Text({ text, style: { fontFamily: "'IBM Plex Mono', monospace", fontSize: 10, fontWeight: "700", fill: PAPER } });
|
||||
t.resolution = TEXT_RESOLUTION;
|
||||
t.anchor.set(0.5);
|
||||
const w = Math.max(16, t.width + 8);
|
||||
const g = new Graphics()
|
||||
.roundRect(12 - w / 2 + 2.5, -15 + 2.5, w, 16, 8).fill({ color: INK, alpha: 0.25 }) // Andeutung des Stapels
|
||||
.roundRect(12 - w / 2, -15, w, 16, 8).fill({ color: INK }).stroke({ color: PAPER, width: 1.5 });
|
||||
t.position.set(12, -7);
|
||||
c.addChild(g, t);
|
||||
c.label = "stapel";
|
||||
return c;
|
||||
.roundRect(-w / 2 + 2.5, -8 + 2.5, w, 16, 8).fill({ color: INK, alpha: 0.25 }) // Andeutung des Stapels
|
||||
.roundRect(-w / 2, -8, w, 16, 8).fill({ color: INK }).stroke({ color: PAPER, width: 1.5 });
|
||||
inner.addChild(g, t);
|
||||
badge.addChild(inner);
|
||||
badge.label = "stapel";
|
||||
return { badge, inner, hw: w / 2 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildschirm-Rechtecke der sichtbaren Nachbarzeichen und -schilder um den Anführer (Pixel, relativ), für chipSide.
|
||||
* Eigener Hafen samt Namensschild zählt immer.
|
||||
*/
|
||||
function obstaclesAround(lead: StackEntity, ents: Iterable<StackEntity>, statics: readonly Pinned[], scale: number): Rect[] {
|
||||
const out: Rect[] = [];
|
||||
const lx = lead.obj!.x, ly = lead.obj!.y;
|
||||
const near = 90 / scale;
|
||||
const pin = (p: Pinned) => {
|
||||
if (p.obj.destroyed || (p.target ?? zoomAlpha(p, scale)) < 0.3) return;
|
||||
if (Math.abs(p.obj.x - lx) > near || Math.abs(p.obj.y - ly) > near) return;
|
||||
const b = p.box ?? p.obj.getLocalBounds();
|
||||
const f = p.obj.scale.x * scale;
|
||||
const cx = (p.obj.x - lx) * scale, cy = (p.obj.y - ly) * scale - p.obj.pivot.y * f;
|
||||
out.push({ x0: cx + b.minX * f, y0: cy + b.minY * f, x1: cx + b.maxX * f, y1: cy + b.maxY * f });
|
||||
};
|
||||
for (const e of ents) {
|
||||
if (e.hidden || !e.obj || e.obj.destroyed) continue;
|
||||
if (e === lead) { for (const p of e.pins) if (p.fixed && p.prio !== undefined) pin(p); continue; } // eigenes Namensschild
|
||||
if (e.pins.length === 0) {
|
||||
if (Math.abs(e.obj.x - lx) > near || Math.abs(e.obj.y - ly) > near) continue;
|
||||
const r = 11 * e.obj.scale.x * scale;
|
||||
const cx = (e.obj.x - lx) * scale, cy = (e.obj.y - ly) * scale;
|
||||
out.push({ x0: cx - r, y0: cy - r, x1: cx + r, y1: cy + r });
|
||||
continue;
|
||||
}
|
||||
for (const p of e.pins) pin(p);
|
||||
}
|
||||
for (const p of statics) if (p.solid) pin(p); // Handelshäfen
|
||||
return out;
|
||||
}
|
||||
|
||||
export class Stacks {
|
||||
@@ -80,31 +113,41 @@ export class Stacks {
|
||||
private sig = "";
|
||||
|
||||
/** Gruppen neu bilden; Rückgabe: Stapel haben sich geändert (dann neu layouten). */
|
||||
compute(ents: readonly StackEntity[], scale: number): boolean {
|
||||
compute(ents: readonly StackEntity[], scale: number, statics: readonly Pinned[] = []): boolean {
|
||||
this.byKey = new Map(ents.map((e) => [e.key, e]));
|
||||
const shown = ents.filter((e) => e.obj && !e.obj.destroyed && (e.pins.length === 0 || e.pins.some((p) => zoomAlpha(p, scale) > 0.3)));
|
||||
const groups = stackGroups(shown.map((e) => ({ key: e.key, x: e.obj!.x, y: e.obj!.y, prio: e.prio, keep: e.keep })), scale);
|
||||
for (const e of ents) e.hidden = false;
|
||||
const multi: Omit<Group, "badge">[] = [];
|
||||
const multi: Pick<Group, "lead" | "keys" | "entries">[] = [];
|
||||
for (const g of groups) {
|
||||
for (const k of g.keys.slice(1)) this.byKey.get(k)!.hidden = true;
|
||||
const entries = g.keys.flatMap((k) => this.byKey.get(k)!.entries);
|
||||
if (entries.length > 1) multi.push({ lead: g.lead, keys: g.keys, entries });
|
||||
}
|
||||
const sig = multi.map((g) => `${g.keys.join("+")}=${g.entries.length}`).join("|");
|
||||
if (sig === this.sig) {
|
||||
const same = sig === this.sig;
|
||||
if (same) {
|
||||
// Gleiche Gruppen: nur die Einträge (Texte, neue Einheiten nach Neubau) übernehmen.
|
||||
multi.forEach((g, i) => { this.groups[i].entries = g.entries; });
|
||||
return false;
|
||||
} else {
|
||||
this.sig = sig;
|
||||
for (const c of this.layer.removeChildren()) c.destroy({ children: true });
|
||||
this.groups = multi.map((g) => {
|
||||
const c = chip(stackChipText(g.entries.length, g.entries.every((e) => e.convoy)));
|
||||
this.layer.addChild(c.badge);
|
||||
return { ...g, ...c, side: CHIP_SIDES[0] };
|
||||
});
|
||||
}
|
||||
this.sig = sig;
|
||||
for (const c of this.layer.removeChildren()) c.destroy({ children: true });
|
||||
this.groups = multi.map((g) => {
|
||||
const badge = chip(stackChipText(g.entries.length, g.entries.every((e) => e.convoy)));
|
||||
this.layer.addChild(badge);
|
||||
return { ...g, badge };
|
||||
});
|
||||
return true;
|
||||
// Chip weicht seitlich aus, wenn er ein Nachbarzeichen oder Namensschild (eigener Hafen) verdecken würde.
|
||||
// Nur hier (Zoom-/Datenänderung, höchstens einmal je Sekunde), nicht in jedem Takt.
|
||||
const k = pinScale(scale) * scale;
|
||||
for (const g of this.groups) {
|
||||
const lead = this.byKey.get(g.lead);
|
||||
if (!lead?.obj || lead.obj.destroyed) continue;
|
||||
g.side = chipSide(obstaclesAround(lead, this.byKey.values(), statics, scale).map((r) => ({ x0: r.x0 / k, y0: r.y0 / k, x1: r.x1 / k, y1: r.y1 / k })), g.hw, 8);
|
||||
g.inner.position.set(g.side[0], g.side[1]);
|
||||
}
|
||||
return !same;
|
||||
}
|
||||
|
||||
/** Chips an die (ggf. bewegten) Anführer setzen; nur Sichtbare. */
|
||||
@@ -126,11 +169,11 @@ export class Stacks {
|
||||
/** Stapel unter dem Tippen (Weltkoordinaten): nächster sichtbarer Anführer oder Chip im Radius. */
|
||||
hit(x: number, y: number, radius: number, scale: number): { entries: StackEntry[]; d: number; at: { x: number; y: number } } | null {
|
||||
let best: { entries: StackEntry[]; d: number; at: { x: number; y: number } } | null = null;
|
||||
const off = 12 * pinScale(scale);
|
||||
const k = pinScale(scale);
|
||||
for (const g of this.groups) {
|
||||
const lead = this.byKey.get(g.lead)?.obj;
|
||||
if (!g.badge.visible || !lead) continue;
|
||||
const d = Math.min(Math.hypot(lead.x - x, lead.y - y), Math.hypot(lead.x + off - x, lead.y - off - y));
|
||||
const d = Math.min(Math.hypot(lead.x - x, lead.y - y), Math.hypot(lead.x + g.side[0] * k - x, lead.y + g.side[1] * k - y));
|
||||
if (d <= radius && (!best || d < best.d)) best = { entries: g.entries, d, at: { x: lead.x, y: lead.y } };
|
||||
}
|
||||
if (!best) return null;
|
||||
|
||||
@@ -118,6 +118,31 @@ export function convoyBundles(list: readonly BundleConvoy[], now: number): Convo
|
||||
});
|
||||
}
|
||||
|
||||
/** Rechteck am Bildschirm (Pixel, relativ zum Anführer). */
|
||||
export interface Rect { x0: number; y0: number; x1: number; y1: number }
|
||||
|
||||
/** Lagen des Stapel-Chips (Mitte, Pixel relativ zum Zeichen): rechts oben zuerst, dann links oben, unten, seitlich. */
|
||||
export const CHIP_SIDES: readonly (readonly [number, number])[] = [[12, -11], [-12, -11], [12, 11], [-12, 11], [20, 0], [-20, 0]];
|
||||
|
||||
/**
|
||||
* Lage des Chips: die erste Seite, deren Rechteck (halbe Breite `hw`, halbe Höhe `hh`) kein Nachbarzeichen bzw.
|
||||
* Namensschild (`obstacles`) überdeckt; sonst die mit der kleinsten Überdeckung.
|
||||
*/
|
||||
export function chipSide(obstacles: readonly Rect[], hw: number, hh: number): readonly [number, number] {
|
||||
let best: { s: readonly [number, number]; a: number } | null = null;
|
||||
for (const s of CHIP_SIDES) {
|
||||
let a = 0;
|
||||
for (const o of obstacles) {
|
||||
const w = Math.min(s[0] + hw, o.x1) - Math.max(s[0] - hw, o.x0);
|
||||
const h = Math.min(s[1] + hh, o.y1) - Math.max(s[1] - hh, o.y0);
|
||||
if (w > 0 && h > 0) a += w * h;
|
||||
}
|
||||
if (a === 0) return s;
|
||||
if (!best || a < best.a) best = { s, a };
|
||||
}
|
||||
return best!.s;
|
||||
}
|
||||
|
||||
/** Text des Chips: Bündel gleicher Konvois „×n“, gemischter Stapel nur die Zahl. */
|
||||
export function stackChipText(count: number, onlyConvoys: boolean): string {
|
||||
return onlyConvoys ? `×${count}` : String(count);
|
||||
|
||||
@@ -116,6 +116,11 @@ export function vaneOnField(col: number, row: number): boolean {
|
||||
return (col + row) % 2 === 0;
|
||||
}
|
||||
|
||||
/** Regenschraffur auf den übrigen Feldern (versetzt zum Windraster): Wind und Regen nie auf demselben Feld. */
|
||||
export function rainOnField(col: number, row: number): boolean {
|
||||
return !vaneOnField(col, row);
|
||||
}
|
||||
|
||||
export function barbsOf(wind: number, wb: WeatherBalance): { half: number; full: number; pennant: number } {
|
||||
if (wind >= wb.stormFrom) return { half: 0, full: wind >= wb.stormFrom + 0.1 ? 1 : 0, pennant: 1 };
|
||||
if (wind >= (wb.shipSlowFrom + wb.stormFrom) / 2) return { half: 0, full: 3, pennant: 0 };
|
||||
|
||||
@@ -12,7 +12,7 @@ import { stormShare, weatherAt, weatherFrontsAt, weatherSystemsAt, type Weather,
|
||||
import { COLS, HEX_SIZE_KM, ROWS, hexCenter, hexCenterXY, terrainAt } from "@tidefront/world";
|
||||
import { LOD_OVERVIEW, weatherAlpha } from "./lod.ts";
|
||||
import { INK, PAPER, SEE, SIEGEL } from "./symbols.ts";
|
||||
import { barbsOf, drawStormFlag, drawVane, isobars, toXY, vaneOnField, windDir, type MapSystem } from "./weather-geo.ts";
|
||||
import { barbsOf, drawStormFlag, drawVane, isobars, rainOnField, toXY, vaneOnField, windDir, type MapSystem } from "./weather-geo.ts";
|
||||
import { FRONT_COLOR, drawFront } from "./weather-fronts.ts"; // Kalt-, Warmfront, Okklusion
|
||||
|
||||
/** Abtastung der Übersicht: jedes STEP-te Feld in beide Richtungen. */
|
||||
@@ -34,6 +34,8 @@ const VANE_FROM = LOD_OVERVIEW + 0.07;
|
||||
/** Ruhige Karte: gewöhnliche Windfahnen dünn und blass, starker Wind (Schiffe gebremst) und Sturm kräftig in Siegelrot. */
|
||||
const VANE_CALM = { alpha: 0.4, width: 1 } as const;
|
||||
const VANE_STRONG = { alpha: 0.9, width: 1.7 } as const;
|
||||
/** Ruhige Karte: Regenschraffur „///“ blass wie gewöhnlicher Wind (Sturm bleibt mit Wimpel und roter Fläche deutlich). */
|
||||
const RAIN = { alpha: 0.35, width: 1 } as const;
|
||||
|
||||
/** Nutzer wünscht weniger Bewegung: Überblendungen als harte Stufen. */
|
||||
function reducedMotion(): boolean {
|
||||
@@ -193,15 +195,15 @@ export function buildWeatherLayer(wb: WeatherBalance): WeatherLayer {
|
||||
}
|
||||
lines.stroke({ color: INK, alpha: 0.3, ...HAIR });
|
||||
|
||||
// Regen unter dichten Wolken.
|
||||
for (const { c, w } of samples) {
|
||||
if (w.clouds < 0.72 || w.storm) continue;
|
||||
// Regen unter dichten Wolken: blass, nur in den Zellen ohne Windfahne (Windfahnen: gerade Zellen).
|
||||
samples.forEach(({ c, w }, i) => {
|
||||
if (w.clouds < 0.72 || w.storm || i % 2 === 0) return;
|
||||
for (let k = -1; k <= 1; k++) {
|
||||
const x0 = c.x + k * half * 0.4;
|
||||
lines.moveTo(x0, c.y + half * 0.15).lineTo(x0 - half * 0.15, c.y + half * 0.55);
|
||||
}
|
||||
}
|
||||
lines.stroke({ color: SEE, alpha: 0.6, ...HAIR });
|
||||
});
|
||||
lines.stroke({ color: SEE, alpha: RAIN.alpha, ...HAIR });
|
||||
|
||||
// Windfahnen nur über See (jede zweite Zelle, damit es ruhig bleibt; Anker ggf. aufs nächste Seefeld versetzt);
|
||||
// gewöhnlicher Wind blass, starker Wind und Sturm kräftig (eigener Strich).
|
||||
@@ -268,11 +270,12 @@ export function buildWeatherLayer(wb: WeatherBalance): WeatherLayer {
|
||||
fieldLines.stroke({ color: strong ? SIEGEL : INK, width: st.width * px, alpha: st.alpha });
|
||||
fieldFill.fill({ color: strong ? SIEGEL : INK, alpha: st.alpha });
|
||||
}
|
||||
// Ruhige Karte: Regenschraffur blass und nur auf den Feldern ohne Windfahne (versetztes Raster, kein Häufen).
|
||||
for (const f of list) {
|
||||
if (f.w.clouds < 0.72 || f.w.storm) continue;
|
||||
if (f.w.clouds < 0.72 || f.w.storm || !rainOnField(f.col, f.row)) continue;
|
||||
for (let k = -1; k <= 1; k++) fieldLines.moveTo(f.x + k * R * 0.3 + R * 0.08, f.y + R * 0.3).lineTo(f.x + k * R * 0.3 - R * 0.04, f.y + R * 0.6);
|
||||
}
|
||||
fieldLines.stroke({ color: SEE, width: 1.5 * px, alpha: 0.8 });
|
||||
fieldLines.stroke({ color: SEE, width: RAIN.width * px, alpha: RAIN.alpha });
|
||||
for (const f of list) {
|
||||
if (f.w.fog < wb.fogScoutFrom) continue;
|
||||
const rows = f.w.fog >= wb.fogScoutHeavy ? [-0.35, 0.05, 0.45] : [-0.35, 0.45];
|
||||
|
||||
@@ -108,7 +108,7 @@ export interface Scene {
|
||||
/** Sichtbarkeit und Größe aller Zeichen bei Zoom- oder Datenänderung neu bestimmen (zuerst die Stapel). */
|
||||
function relayout(s: Scene): void {
|
||||
const sc = s.world.scale.x;
|
||||
s.stacks.compute([...s.ents.markers, ...s.ents.events, ...s.ents.ships], sc);
|
||||
s.stacks.compute([...s.ents.markers, ...s.ents.events, ...s.ents.ships], sc, s.pinnedStatic);
|
||||
layout([s.pinnedStatic, s.pinnedMarkers], sc);
|
||||
s.stacks.place(sc);
|
||||
}
|
||||
@@ -209,8 +209,8 @@ export function HexMap(props: HexMapProps) {
|
||||
pinnedStatic.push({ obj, ...pin });
|
||||
};
|
||||
// Übersicht: kleiner Ring; danach Ankerzeichen, Name erst näher und nur ohne Überlappung
|
||||
at(dotSymbol(INK, 2.6, 0.8, true), { max: LOD_OVERVIEW, fixed: true });
|
||||
at(portSymbol(), { min: LOD_OVERVIEW });
|
||||
at(dotSymbol(INK, 2.6, 0.8, true), { max: LOD_OVERVIEW, fixed: true, solid: true }); // solid: Schilder weichen aus
|
||||
at(portSymbol(), { min: LOD_OVERVIEW, solid: true });
|
||||
at(nameTag(name, INK, 11), { min: LOD_NAMES, fixed: true, prio: PRIO.port });
|
||||
}
|
||||
app.stage.addChild(graticule.labels);
|
||||
@@ -277,7 +277,7 @@ export function HexMap(props: HexMapProps) {
|
||||
// Ruhige Karte: Stapel höchstens einmal je Sekunde neu (bewegte Verbände); nur bei Änderung neu layouten.
|
||||
lastStack = now;
|
||||
s.ents.ships = shipEntities(s, live.current.missions, live.current.focus);
|
||||
if (s.stacks.compute([...s.ents.markers, ...s.ents.events, ...s.ents.ships], sc)) {
|
||||
if (s.stacks.compute([...s.ents.markers, ...s.ents.events, ...s.ents.ships], sc, s.pinnedStatic)) {
|
||||
layout([s.pinnedStatic, s.pinnedMarkers], sc);
|
||||
fading = true;
|
||||
}
|
||||
|
||||
@@ -148,3 +148,21 @@ Liste → Infoblatt, nah wieder einzeln, Schalter aus; mit `TF_RUHE_SHOTS` Bilds
|
||||
|
||||
Bewusst nicht: Auffächern der Zeichen auf der Karte (stattdessen Auswahlliste, barrierearm und testbar); Bündel über
|
||||
verschiedene Strecken; Linien von Weltereignissen und Feldzonen unverändert.
|
||||
|
||||
### Nachtrag: Regen, Hafennamen, Chip-Lage (Nutzerentscheid nach Durchsicht der Fotos)
|
||||
|
||||
- Bestätigt: Schalter „Alle Reichweiten“ für alle anfangs aus; Satellitenstreifen immer sichtbar; Stapel-Tipp als Liste.
|
||||
- **Regenschraffur „///“ dezent** (`weather.ts`, `weather-geo.ts rainOnField`): blass wie gewöhnlicher Wind (1 px,
|
||||
Deckkraft 0,35) und nur auf den Feldern ohne Windfahne (`rainOnField` = nicht `vaneOnField`, versetztes Raster: Wind
|
||||
und Regen nie auf demselben Feld); in der Übersicht nur in den Zellen ohne Windfahne. Sturm bleibt deutlich (Wimpel,
|
||||
rote Fläche und Rand).
|
||||
- **Hafennamen weichen aus** (`lod.ts`, Feld `solid`): Hafenzeichen (Handelshäfen, fremde Häfen, auch ihre
|
||||
Übersichtspunkte) belegen in der Kollisionsprüfung zuerst Platz, ohne selbst ausgeblendet zu werden. Namensschilder,
|
||||
die ein fremdes Hafenzeichen überdecken, spiegeln nach oben oder werden ausgeblendet; das eigene Namensschild
|
||||
(immer sichtbar) spiegelt nach oben, wenn dort frei ist. Schild und Zeichen desselben Hafens stören sich nicht.
|
||||
- **Stapel-Chip weicht aus** (`stack.ts chipSide`, `stack-layer.ts`): Der Chip sitzt rechts oben; überdeckt er dort ein
|
||||
sichtbares Nachbarzeichen, ein Namensschild (auch das eigene Hafenschild) oder ein Handelshafenzeichen, nimmt er die
|
||||
erste freie Seite (links oben, unten rechts/links, seitlich), sonst die mit der kleinsten Überdeckung. Gerechnet in
|
||||
`compute()` (Zoom-/Datenänderung, höchstens einmal je Sekunde), nicht je Takt.
|
||||
- Tests: `karte-stapel.test.ts` (Regenraster, chipSide), E2E `35-karte-ruhe` „Hafen neben einem Handelshafen –
|
||||
Namensschilder überlappen nicht“ (Bildschirmrechtecke der sichtbaren Schilder bei drei Zoomstufen).
|
||||
@@ -2,8 +2,8 @@
|
||||
// derselben Strecke.
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { vaneOnField } from "../../../apps/web/src/map/weather-geo.ts";
|
||||
import { STACK_UNTIL, convoyBundles, stackChipText, stackGroups, stackThresholdPx, type BundleConvoy, type StackPoint } from "../../../apps/web/src/map/stack.ts";
|
||||
import { rainOnField, vaneOnField } from "../../../apps/web/src/map/weather-geo.ts";
|
||||
import { CHIP_SIDES, STACK_UNTIL, chipSide, convoyBundles, stackChipText, stackGroups, stackThresholdPx, type BundleConvoy, type StackPoint } from "../../../apps/web/src/map/stack.ts";
|
||||
|
||||
const pt = (key: string, x: number, y: number, prio = 5, keep = false): StackPoint => ({ key, x, y, prio, keep });
|
||||
|
||||
@@ -98,3 +98,18 @@ test("Windfahnen: jedes zweite Feld, festes Raster ohne Nachbarn in derselben Re
|
||||
}
|
||||
assert.equal(on, 200);
|
||||
});
|
||||
|
||||
test("Regen: auf den Feldern ohne Windfahne (versetztes Raster)", () => {
|
||||
for (let row = 0; row < 10; row++) for (let col = 0; col < 10; col++) assert.notEqual(rainOnField(col, row), vaneOnField(col, row));
|
||||
});
|
||||
|
||||
test("Chip weicht aus: frei rechts oben, sonst die nächste freie Seite", () => {
|
||||
assert.deepEqual(chipSide([], 8, 8), CHIP_SIDES[0]);
|
||||
// Eigener Hafen rechts oben neben dem Zeichen: Chip nach links oben.
|
||||
assert.deepEqual(chipSide([{ x0: 2, y0: -30, x1: 40, y1: 0 }], 8, 8), [-12, -11]);
|
||||
// Oben alles belegt (Namensschild darüber): unten rechts.
|
||||
assert.deepEqual(chipSide([{ x0: -60, y0: -40, x1: 60, y1: -1 }], 8, 8), [12, 11]);
|
||||
// Ringsum belegt: kleinste Überdeckung.
|
||||
const s = chipSide([{ x0: -100, y0: -100, x1: 100, y1: 100 }], 8, 8);
|
||||
assert.ok(CHIP_SIDES.includes(s));
|
||||
});
|
||||
Reference in new issue
Block a user