Files
Dune/game/duke-capture-uncertainty.ts
T
Quintine 59cb336c80
Verify and publish checkpoint container / container (push) Canceled after 0s
Resolve Duke uncertainty on public events
2026-10-29 19:30:00 +11:00

34 lines
1.7 KiB
TypeScript

import { DUKE_VIDAL_ID } from './duke-vidal';
/** Only facts already public when an uncanceled capture is completed. `null`
* means a known absent controller or leader; `undefined` means unknown. */
export type DukeCapturePublicSource = {
publicController: string | null | undefined;
loser: string | undefined;
revealedLeader: string | null | undefined;
publicPlanKnown: boolean;
};
/** Called for every completed Harkonnen capture, regardless of its concealed
* selection. Once the public cannot rule out Duke, keep the uncertainty until
* a separate public resolution explicitly clears it. An unstamped legacy game remains unstamped:
* its past capture history cannot be reconstructed from current state. */
export function nextDukeCaptureUncertainty(
marker: boolean | undefined,
source: DukeCapturePublicSource,
): boolean | undefined {
if (marker === undefined || marker === true) return marker;
if (marker !== false || !source || source.publicPlanKnown !== true ||
typeof source.loser !== 'string' || !source.loser.trim() ||
source.publicController === undefined ||
(source.publicController !== null &&
(typeof source.publicController !== 'string' || !source.publicController.trim())) ||
source.revealedLeader === undefined ||
(source.revealedLeader !== null &&
(typeof source.revealedLeader !== 'string' || !source.revealedLeader.trim()))) return true;
// An unused Duke in the loser's control or the Duke just released after
// that revealed battle is part of the possible public capture pool. No
// choice, private candidate list, or actual capture identity is consulted.
return source.publicController === source.loser || source.revealedLeader === DUKE_VIDAL_ID;
}