Weltpolitik: Wochenbeschlüsse ohne Überlappung mit der Gezeit, Allianzdeckel exakt, ein Weltereignis weniger während der Gezeit, Fehlertexte, Regelwerk REGELN-WELTPOLITIK.md, Entscheidungen, Unit- und Servertests

This commit is contained in:
db9979 committed 2026-11-27 22:37:34 +01:00
1 parent 407a20965f
commit cbda458196
12 files changed
+858 -23

No files matched your search

+7 -1
View File
@@ -10,6 +10,7 @@ import { tables, type DbOrTx } from "@tidefront/db";
import { balance } from "./context.ts";
import { getSettings } from "./settings.ts";
import { registerModifierSource } from "./modifiers.ts";
import { randomSeed } from "./store.ts";
const HOUR_MS = 3_600_000;
@@ -129,7 +130,12 @@ export const PROFILE_TEXT: Record<string, string> = { haendler: "Händler", fest
export async function politikEventKind<K extends string>(db: DbOrTx, ms: number, wanted: K): Promise<K> {
const eff = await balanceNow(db, ms);
if (!eff.politikNow || Object.keys(eff.politikNow.kindWeights).length === 0) return wanted;
return pickKind(crypto.getRandomValues(new Uint32Array(1))[0] / 4294967296, eff) as K;
return pickKind(randomSeed() / 4294967296, eff) as K;
}
/** Läuft gerade ein Gezeit-Fenster (Plan, nicht abgesagt, nicht „Ruhige See“)? */
export async function gezeitRunning(db: DbOrTx, ms: number): Promise<boolean> {
return (await planAt(db, ms)).windows.some((w) => w.slot === "gezeit" && w.effect !== "ruhig");
}
/** Beute eines neu entstehenden Weltereignisses: Gemeinsame Aktion × worldEventLoot (loot und lootPool). */
+3 -2
View File
@@ -26,7 +26,7 @@ import {
import { hexCenter, hexDistanceKm, neighbors, terrainAt } from "@tidefront/world";
import { tables, type Tx } from "@tidefront/db";
import { balance, type NoticeJob } from "./context.ts";
import { politikEventData, politikEventKind } from "./politik-core.ts"; // Weltpolitik: Kartellfehde, Gemeinsame Aktion
import { gezeitRunning, politikEventData, politikEventKind } from "./politik-core.ts"; // Weltpolitik: Kartellfehde, Gemeinsame Aktion
import { nOf } from "./names.ts";
import type { Handler, HandlerResult } from "./events.ts";
import { randomSeed, scheduleEvent } from "./store.ts";
@@ -275,7 +275,8 @@ export const worldEventSpawn: Handler = async (tx, ev, due) => {
const progress = seasonProgress(season.startsAt.getTime(), season.endsAt.getTime(), due);
if (due >= until) return none();
// Deckel: höchstens maxConcurrent gewöhnliche Ereignisse gleichzeitig, sonst wie „kein Ziel“ (neuer Versuch).
const full = (await openOrdinaryCount(tx)) >= (w.maxConcurrent ?? Infinity);
// Weltpolitik: während einer Gezeit ein Ereignis weniger (docs/REGELN-WELTPOLITIK.md, Abschnitt 2).
const full = (await openOrdinaryCount(tx)) >= (w.maxConcurrent ?? Infinity) - (await gezeitRunning(tx, due) ? 1 : 0);
const made = full ? null : await spawnWorldEvent(tx, due, wanted, season.id, progress);
const next = nextSpawn(due, randomSeed(), balance);
const at = made ? next.atMs : due + w.retryHours * HOUR_MS;