Files
History/server/abilities/index.ts
T
kamilkrzywda c77e81c45b
CI / build + unit + e2e (pull_request) Successful in 2m33s
feat: #65 sea control — 11th ability (v0.43.0)
Adds the sea ability: a fixed set of 12 named sea zones with sole-control
semantics, contest-by-higher-military, and a deterministic per-turn
+1 military/+1 economy bonus for each claimed zone. Durable (owns
GameState.seaZones), additive migration, stub-inert (e2e unaffected).

Fixes #65

Design note: Gitea #65 sketched a free-form 'naval' layer; the implemented
approved design is this richer 'sea' layer with a fixed zone set.
2026-10-16 12:50:22 +00:00

176 lines
6.5 KiB
TypeScript

// The ordered LLM-ability registry.
//
// `ABILITIES` is the single source of truth for the 11 per-feature LLM abilities.
// The engine iterates it in this order:
// takeovers → wars → hybrid → economy → industry → nuclear → leaders → ideology → disasters → migration → sea
// for (a) the system-prompt schema lines + constraint bullets, (b) the per-ability
// validate calls inside validateTurnResult, (c) the payload fields in buildUserPrompt,
// (d) the ordered apply block inside applyTurnResult, (e) the isMeaningful check,
// (f) the runTurn unclear-fallback defaults, (g) the stub's deterministic fields, and
// (h) the db.ts state-field migrations.
//
// Each ability file defines its own `Ability<K>` const (the schema line, constraint
// bullet, validator, applier, meaningfulness predicate, stub default, and user-payload
// field). This module assembles them into the ordered `ABILITIES` array and re-exports
// every public name the engine (and its tests) need.
import { takeovers } from './takeovers';
import { wars } from './wars';
import { hybrid } from './hybrid';
import { economy } from './economy';
import { industry } from './industry';
import { nuclear } from './nuclear';
import { leaders } from './leaders';
import { ideology } from './ideology';
import { disasters } from './disasters';
import { migration } from './migration';
import { sea } from './sea';
import type { Ability, AbilityField } from './types';
/**
* The 11 per-feature LLM abilities in their canonical apply order.
* The order matters: it determines the order of the schema lines in the
* system prompt, the order of the validate calls, the order of the apply
* steps, and the order of the payload fields in the user prompt. New
* abilities are APPENDED last — never reorder existing entries (their order
* is pinned by the goldens and the stub's byte-identical output).
*/
export const ABILITIES: readonly Ability<AbilityField>[] = [
takeovers,
wars,
hybrid,
economy,
industry,
nuclear,
leaders,
ideology,
disasters,
migration,
sea,
];
// ── type re-exports ────────────────────────────────────────────────────────────
export type {
Ability,
AbilityCtx,
UserPromptCtx,
AbilityField,
} from './types';
// ── shared helpers ─────────────────────────────────────────────────────────────
export {
resolveNationRef,
resolveRegionKey,
freshNationId,
freshWarId,
NEW_NATION_STATS,
} from './shared';
// ── war helpers ────────────────────────────────────────────────────────────────
export {
activeWarPairs,
atWar,
syncWarRelations,
} from './apply-helpers';
// ── takeovers ──────────────────────────────────────────────────────────────────
export {
validateTakeovers,
applyTakeover,
} from './takeovers';
// ── wars ───────────────────────────────────────────────────────────────────────
export {
validateWarOps,
applyWars,
} from './wars';
// ── hybrid ─────────────────────────────────────────────────────────────────────
export {
validateHybridOps,
isHybridOpType,
HYBRID_STAT_EFFECT,
shiftRelationTowardHostile,
applyHybridOp,
} from './hybrid';
// ── economy ────────────────────────────────────────────────────────────────────
export {
validateEconomyOps,
applyEconomyEffects,
} from './economy';
// ── industry ───────────────────────────────────────────────────────────────────
export {
validateIndustryOps,
isIndustryType,
applyIndustryEffects,
} from './industry';
// ── nuclear ────────────────────────────────────────────────────────────────────
export {
validateNuclearOps,
applyNuclearOps,
} from './nuclear';
// ── leaders ────────────────────────────────────────────────────────────────────
export {
validateLeaderOps,
} from './leaders';
// ── ideology ───────────────────────────────────────────────────────────────────
export {
validateIdeologyOps,
} from './ideology';
// ── disasters ────────────────────────────────────────────────────────────────
export {
validateDisasterEvents,
applyDisasterEvent,
isDisasterType,
isDisasterSeverity,
DISASTER_TYPES,
DISASTER_SEVERITIES,
DISASTER_EFFECTS,
} from './disasters';
// ── migration ────────────────────────────────────────────────────────────────
export {
validateMigrationOps,
applyMigrationOp,
shiftRelationTowardPositive,
isMigrationKind,
isMigrationScale,
MIGRATION_KINDS,
MIGRATION_SCALES,
MIGRATION_SOURCE_EFFECTS,
MIGRATION_DESTINATION_EFFECTS,
LARGE_INFLUX_STABILITY_DIP,
} from './migration';
// ── sea ──────────────────────────────────────────────────────────────────────
export {
validateSeaOps,
applySeaControl,
applySeaZoneBonuses,
SEA_ZONE_BONUS,
SEA_ZONES,
SEA_ZONE_IDS,
isSeaZoneId,
seaZoneName,
} from './sea';