Zuverlässige Tests: steuerbare Uhr (feste Etc/GMT-Zone), festes Testwetter, fester Seed, reservierte Testplätze, tapHex über Kartenhaken

Server-Tests und E2E hängen nicht mehr an Tageszeit, echtem Wetter, Zufall oder paralleler Last:
- game-core/test-clock.ts: Testuhr über eine feste Etc/GMT-Zeitzone (Vorgabe 12 Uhr; TF_TEST_CLOCK / E2E_CLOCK)
- weather.fixed (nur Testumgebung, reist über meta in den Browser); engine/test-mode.ts mit Schutz vor Produktion
- engine/test/setup.ts als Preload von test:server (Uhr, ruhiges Wetter, Seed 1)
- E2E: Heimathafen atomar reserviert (Abstand zu laufenden Tests, Nest/Gründungsfeld), tapHex ohne Ziehen und Raten
- Bauschlange: Abbrechen erst mit geladener Balance (Rückfrage aus vollständigen Daten)
- alliance.test: Kartell-Abfangwurf der Handelslieferung ausdrücklich aus (Ursache der zufälligen Fehlschläge)
This commit is contained in:
db9979 committed 2026-11-29 08:55:28 +01:00
1 parent f2df74ab98
commit 00a47c71bf
30 files changed
+516 -95

No files matched your search

+15 -2
View File
@@ -2,13 +2,17 @@
// der Kartendarstellung (apps/web/e2e/32-karte-darstellung.spec.ts). Im gebauten Spiel nicht vorhanden.
import type { Application, Container } from "pixi.js";
import { clampView, zoomAround } from "./gestures.ts";
import { hexCenterXY } from "@tidefront/world";
import { xyOf } from "./terrain.ts";
type ViewFn = (lon: number, lat: number, scale: number) => { scale: number; resolution: number };
/** Feld (col/row) an den Bruchteil (fx, fy) der Kartenfläche schieben (Maßstab bleibt); liefert die Bildschirmposition
* der Feldmitte relativ zur Kartenfläche (nach dem Begrenzen am Kartenrand). E2E: tapHex trifft so ohne Ziehen und Raten. */
type AimFn = (col: number, row: number, fx: number, fy: number) => { x: number; y: number };
export function installViewHook(app: Application, world: Container): () => void {
if (!import.meta.env.DEV) return () => {};
const w = window as unknown as { __tfMapView?: ViewFn; __tfMapApp?: Application };
const w = window as unknown as { __tfMapView?: ViewFn; __tfMapAim?: AimFn; __tfMapApp?: Application };
w.__tfMapApp = app; // Leistungsmessung (E2E)
w.__tfMapView = (lon, lat, scale) => {
const { width, height } = app.screen;
@@ -19,5 +23,14 @@ export function installViewHook(app: Application, world: Container): () => void
clampView(world, width, height);
return { scale: world.scale.x, resolution: app.renderer.resolution };
};
return () => { delete w.__tfMapView; delete w.__tfMapApp; };
w.__tfMapAim = (col, row, fx, fy) => {
const { width, height } = app.screen;
const p = hexCenterXY(col, row);
const s = world.scale.x;
world.position.set(width * fx - p.x * s, height * fy - p.y * s);
clampView(world, width, height);
app.render();
return { x: world.position.x + p.x * s, y: world.position.y + p.y * s };
};
return () => { delete w.__tfMapView; delete w.__tfMapAim; delete w.__tfMapApp; };
}
+6 -4
View File
@@ -168,13 +168,15 @@ function BuildYard({ base, now, onResearch }: { base: BaseData; now: number; onR
</div>
<Button
kind="secondary"
disabled={cancel.busy || o.finishesAt <= now}
// Rückfrage nur aus vollständigen Daten: ohne Balance (meta) fehlten Verlust und mitgestrichene Aufträge.
disabled={cancel.busy || o.finishesAt <= now || !meta.data}
onClick={() => {
const cost = meta.data ? levelCost(meta.data.balance, o.buildingId, o.targetLevel - 1) : {};
if (!meta.data) return;
const cost = levelCost(meta.data.balance, o.buildingId, o.targetLevel - 1);
const loss = cancelLoss(cost, o.startedAt, o.finishesAt, Date.now());
// Wie der Server: spätere Stufen und Aufträge über dem Deckel der Kommandozentrale fallen mit weg.
const b = meta.data?.balance.building;
const also = b ? cancelAlsoRemoves(queue, i, Object.fromEntries(base.buildings.map((x) => [x.id, x.level])), b) : [];
const b = meta.data.balance.building;
const also = cancelAlsoRemoves(queue, i, Object.fromEntries(base.buildings.map((x) => [x.id, x.level])), b);
const q = cancelQuestion(`Ausbau ${label(o.buildingId)} auf Stufe ${o.targetLevel}`, loss)
+ (also.length ? ` Mit weg fallen (voll erstattet): ${also.map((x) => `${label(x.buildingId)} Stufe ${x.targetLevel}`).join(", ")}.` : "");
if (confirm(q)) void cancel.run({ buildingId: o.buildingId, targetLevel: o.targetLevel });