Guard Duke grants using public capture uncertainty
Verify and publish checkpoint container / container (push) Successful in 11m21s
Verify and publish checkpoint container / container (push) Successful in 11m21s
This commit is contained in:
1 parent
5f4eeee4f1
commit
57e7611468
15 files changed
+500
-19
No files matched your search
@@ -3,6 +3,7 @@ import type { FactionId } from './catalog';
|
||||
import { acquireDuke, DUKE_VIDAL_ID, type DukeState } from './duke-vidal';
|
||||
import { independentDiscoveryProfile, nexusCoreProfile, type FactionModuleProfile } from './faction-module-profile';
|
||||
import { mixedE3NexusProfile, pairedE3NexusProfile, standaloneE3NexusProfile } from './nexus-module-profile';
|
||||
import { dukeCaptureUncertaintyBlock, plainAdvancedEcazDukeProfile } from './ecaz-duke-capture-policy';
|
||||
|
||||
export type EcazDukeContext = Omit<Partial<FactionModuleProfile>, 'players'> & {
|
||||
status: Game['status'];
|
||||
@@ -10,8 +11,9 @@ export type EcazDukeContext = Omit<Partial<FactionModuleProfile>, 'players'> & {
|
||||
advanced: boolean;
|
||||
players: readonly { id: string; faction: FactionId; ally?: string | null }[];
|
||||
dukeVidal?: DukeState;
|
||||
dukeCaptureUncertain?: boolean;
|
||||
};
|
||||
type Failure = 'context' | 'custody' | 'table' | 'alreadyControlled' | 'sameHolderTable';
|
||||
type Failure = 'context' | 'custody' | 'table' | 'captureUncertain' | 'alreadyControlled' | 'sameHolderTable';
|
||||
export class EcazDukeAcquisitionError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
@@ -69,9 +71,11 @@ export function quoteEcazDukeAcquisition(
|
||||
'Choose Ecaz or its current reciprocal ally for this acquisition.',
|
||||
'context',
|
||||
);
|
||||
const captureBlock = dukeCaptureUncertaintyBlock(g);
|
||||
requireDuke(!captureBlock, captureBlock ?? 'Duke capture history is unavailable.', 'captureUncertain');
|
||||
requireDuke(
|
||||
!(g.advanced && g.players.some((p) => p.faction === 'harkonnen')) ||
|
||||
(!!g.expansions && (independentDiscoveryProfile(g as FactionModuleProfile) || nexusCoreProfile(g as FactionModuleProfile) || standaloneE3NexusProfile(g as FactionModuleProfile) ||
|
||||
(plainAdvancedEcazDukeProfile(g) || !!g.expansions && (independentDiscoveryProfile(g as FactionModuleProfile) || nexusCoreProfile(g as FactionModuleProfile) || standaloneE3NexusProfile(g as FactionModuleProfile) ||
|
||||
pairedE3NexusProfile(g as FactionModuleProfile) || mixedE3NexusProfile(g as FactionModuleProfile))),
|
||||
tableBlock,
|
||||
'table',
|
||||
@@ -138,6 +142,7 @@ export function ecazDukeAcquisitionBlock(
|
||||
return null;
|
||||
} catch (error) {
|
||||
if (error instanceof EcazDukeAcquisitionError) {
|
||||
if (error.reason === 'captureUncertain') return dukeCaptureUncertaintyBlock(g);
|
||||
if (error.reason === 'table') return tableBlock;
|
||||
if (error.reason === 'sameHolderTable') return sameHolderTableBlock;
|
||||
if (error.reason === 'alreadyControlled')
|
||||
|
||||
Reference in new issue
Block a user