Connect revived arrivals to native Terror continuations

This commit is contained in:
Quintine committed 2026-10-25 22:04:33 +11:00
1 parent ab69f97cfa
commit 724d9dce1e
20 files changed
+1527 -55

No files matched your search

+8 -4
View File
@@ -2,6 +2,7 @@ import type { Game } from './engine';
import { TERRITORIES, validLocation } from './board';
import { HomeworldCustodyError } from './homeworld-custody';
import { TERROR_STRONGHOLDS } from './moritani-terror';
import { revivalEntryParentTuple, validRevivalEntryParent } from './revival-terror-entry';
type TerrorEntry = NonNullable<Game['pendingTerrorEntry']>;
@@ -21,6 +22,7 @@ export function terrorEntrySignature(entry: TerrorEntry): string {
entry.resume,
entry.ambassadorEvent ?? null,
...(entry.nexusPlacements ? [entry.nexusPlacements] : []),
...(entry.revivalArrival === undefined ? [] : [revivalEntryParentTuple(entry.revivalArrival)]),
]);
}
@@ -28,13 +30,14 @@ export function terrorSelectionSignature(entry: TerrorEntry): string {
return JSON.stringify(['terrorSelection', entry.candidates, entry.token, entry.entrant,
entry.territory, entry.sector, entry.amount, entry.elite, entry.cause,
entry.turn, entry.phase, entry.resume, entry.ambassadorEvent ?? null,
...(entry.nexusPlacements ? [entry.nexusPlacements] : [])]);
...(entry.nexusPlacements ? [entry.nexusPlacements] : []),
...(entry.revivalArrival === undefined ? [] : [revivalEntryParentTuple(entry.revivalArrival)])]);
}
/** Older saves without a receipt remain explicit legacy state. Never invent
* their original entry count from the destination's present occupants. */
export function validateTerrorEntrySignature(entry: TerrorEntry): void {
if (entry.entrySignature === undefined && entry.candidates === undefined && entry.selectionSignature === undefined && entry.nexusPlacements === undefined && entry.stage !== 'select') return;
if (entry.entrySignature === undefined && entry.candidates === undefined && entry.selectionSignature === undefined && entry.nexusPlacements === undefined && entry.revivalArrival === undefined && entry.stage !== 'select') return;
if (
typeof entry.entrySignature !== 'string' ||
typeof entry.token !== 'string' ||
@@ -68,14 +71,15 @@ export function validateTerrorEntrySignature(entry: TerrorEntry): void {
!Number.isSafeInteger(entry.phase) ||
entry.phase < 0 ||
entry.phase > 8 ||
![
(entry.revivalArrival !== undefined && !validRevivalEntryParent(entry.revivalArrival)) ||
(![
'shipment',
'movement',
'guildTransport',
'advisor',
'wormRide',
'ambassador',
].includes(entry.cause) ||
].includes(entry.cause) && !(entry.cause === 'homeworldRevival' && entry.revivalArrival !== undefined)) ||
!['none', 'wormRide', 'ambassador'].includes(entry.resume) ||
(entry.ambassadorEvent !== undefined &&
(typeof entry.ambassadorEvent !== 'string' || !entry.ambassadorEvent)) ||