Files
tidefront/packages/engine/src/intel-post-view.ts
T
db9979 59a8b4af63 Lagebild Stufe 3: Satelliten, Startrampe, Raumfahrt, Tarnnetze, Störsender (Balance v1.23)
- Startrampe (Kommandozentrale 8, Forschungsamt 5, Radarstation 6; neue Gebäude-Voraussetzung requires,
  Code building_requires), Störsender (Radarstation 5, 10 Strom je Stufe), beide mit bewegter Zeichnung
- Forschungszweig Raumfahrt (optischer Satellit, Radarsatellit), Tarnnetze im Zweig Heer
- Satelliten im Hafenzustand: Start (intel.launchSatellite), Überflug alle 6 h als Ereignis satellite_pass
  (schreibt Wissen für den Streifen, optisch nicht unter Wolken > 0,6, Radar nur Sichtung), 20 min live,
  Ende nach 7 Tagen mit Abschlussbericht, höchstens 1 (2 mit Radarsatellit)
- Gegenmittel in liveLevelAt: Tarnnetz, Störsender (fremdes Radar −25 % je Stufe in 200 km, erkennbar in
  600 km), Tarnanstrich auf reine Flugverbände, Funkdisziplin des Admirals
- Oberfläche: Meldungen → Lagebild „Satelliten“ (nächster Überflug, Start), Karte (Streifen, Uhrzeit,
  Störsender-Blitz), Berichte, E-Mails, Handbuch, Legende, „Was hilft?“
- KI: Freibeuter und Festung bauen die Rampe und starten Satelliten; Nest-Überfall prüft je Stufe einmal
- Simulation sim/satellite.ts (Wert des Wissens), ENTSCHEIDUNGEN-3.md Q, REGELN-LAGEBILD.md Stufe 3
- Tests: game-core intel-sat, engine lagebild3 und Mails, E2E 16-satellit
2026-11-27 13:07:30 +01:00

57 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Lagebild Stufe 2: Radarposten auf der Karte. Eigene und verbündete immer (mit Reichweite und Betrieb), fremde nur
// live in Sicht oder aus gespeichertem Wissen (kind "post"); mit Kartennebel aus alle.
import { tables, type DbOrTx } from "@tidefront/db";
import { hexCenterXY } from "@tidefront/world";
import { liveAt, sourceAt, type Sight } from "./intel-sight.ts";
import { knownFor, type IntelTag, type SightingInput } from "./intel-store.ts";
import { postRules } from "./intel-post.ts";
export interface MapPost {
id: number;
col: number;
row: number;
owner: string;
own: boolean;
/** Eigene und verbündete: Reichweite und Betrieb; fremde: null. */
rangeKm: number | null;
offline: boolean | null;
intel: IntelTag | null;
}
export async function postsInSight(db: DbOrTx, playerId: number, sight: Sight | null, nowMs: number, rows: SightingInput[], skipKnown = false): Promise<MapPost[]> {
const pb = postRules();
if (!pb) return [];
const posts = await db.select().from(tables.radarPost);
if (posts.length === 0 && !sight) return [];
const names = new Map((await db.select({ id: tables.player.id, name: tables.player.name }).from(tables.player)).map((p) => [p.id, p.name]));
const mates = new Set(sight?.members ?? [playerId]);
const known = sight && !skipKnown ? await knownFor(db, sight, nowMs, ["post"]) : new Map();
const out: MapPost[] = [];
const seen = new Set<number>();
for (const p of posts) {
const base = { id: p.id, col: p.col, row: p.row, owner: names.get(p.playerId) ?? "?", own: p.playerId === playerId };
if (!sight || mates.has(p.playerId)) {
out.push({ ...base, rangeKm: mates.has(p.playerId) ? pb.rangeKm : null, offline: mates.has(p.playerId) ? p.offline : null, intel: null });
seen.add(p.id);
continue;
}
const lvl = liveAt(sight, p.col, p.row, "object", { ownerId: p.playerId, kind: "post" }); // Stufe 3: Tarnnetz 2
if (!lvl) continue;
const xy = hexCenterXY(p.col, p.row);
const source = sourceAt(sight, xy.x, xy.y);
rows.push({ kind: "post", objectId: p.id, level: lvl, source, data: { col: p.col, row: p.row, owner: base.owner } });
out.push({ ...base, rangeKm: null, offline: null, intel: { age: "live", atMs: nowMs, source, level: lvl } });
seen.add(p.id);
}
if (sight) {
for (const k of known.values()) {
if (k.kind !== "post" || seen.has(k.objectId)) continue;
const d = k.data as { col: number; row: number; owner: string };
// Im Sensorbereich und nicht mehr da: abgebaut oder zerstört – das sieht man.
if (liveAt(sight, d.col, d.row)) continue;
out.push({ id: k.objectId, col: d.col, row: d.row, owner: d.owner, own: false, rangeKm: null, offline: null, intel: { age: k.age, atMs: k.seenAtMs, source: k.source, level: k.level } });
}
}
return out;
}