Support current battle choice promises and persistent notices
Verify and publish checkpoint container / container (push) Successful in 11m42s
Verify and publish checkpoint container / container (push) Successful in 11m42s
This commit is contained in:
1 parent
77d02b3231
commit
bd8377d87b
16 files changed
+684
-32
No files matched your search
+48
-1
@@ -55,6 +55,7 @@ import { TurnActionError, liveTurnActionPromises, turnActionBranches, recordTurn
|
||||
closeTurnActionRevival, settleTurnActionAlliance, recordTurnActionPlan, recordTurnActionTraitor, closeTurnActionCombat,
|
||||
recordTurnActionBattlePower, closeTurnActionBattlePower,
|
||||
recordTurnActionWindowCardPlay, closeTurnActionWindowCardPlay,
|
||||
recordTurnActionBattleChoice, closeTurnActionBattleChoice,
|
||||
recordTurnActionStormDial, closeTurnActionStormDial, turnActionStormDialChoices,
|
||||
turnActionPromiseModeSupported, type TurnActionPlanValue, type TurnActionCombat, type TurnActionClaim, type TurnActionPromise, type TurnActionBranchLeaf, type TurnActionPreparation, type TurnActionWindowCards } from './turn-action-promises';
|
||||
import { TravelPromiseError, liveTravelPromises, travelBranches, recordTravelShipment, recordTravelMovement,
|
||||
@@ -24302,6 +24303,16 @@ function turnActionTargetAvailable(g: Game, actor: string): boolean {
|
||||
!bribeTimingBlock({ ...context, truthtrance: null, response: battleCancel ? null : context.response,
|
||||
inflation: context.inflation?.side === 'double' ? null : context.inflation });
|
||||
}
|
||||
/** The current chooser's real unresolved pairs; independent of the private
|
||||
* Truthtrance window, which may temporarily suspend this public opportunity. */
|
||||
function turnActionBattleChoiceOpportunity(g: Game, actor: string) {
|
||||
if (g.status !== 'playing' || g.phase !== 6 || g.battle || g.active !== actor) return null;
|
||||
const source = battleChooserEvent(g.turn, battleOrderAfterBattle(g), g.battleOrder?.uses.length ?? 0);
|
||||
const choices = battleOrderQuote(g).choices.filter(choice => choice.chooser === actor).map(choice => ({
|
||||
territory:choice.territory,target:choice.attacker === actor ? choice.defender : choice.attacker,
|
||||
}));
|
||||
return choices.length ? {source,choices} : null;
|
||||
}
|
||||
/** Whole native commitments retain the existing Semuta discard continuation.
|
||||
* This does not expand the separate legacy bribe or Kull/module envelopes. */
|
||||
function turnActionPromiseTurn(g: Game): boolean {
|
||||
@@ -24542,7 +24553,7 @@ function turnActionAllianceCanClose(g: Game, player: Player): boolean {
|
||||
return !!turnActionCompletion(source, player.id);
|
||||
} catch (error) { if (error instanceof RuleError) return false; throw error; }
|
||||
}
|
||||
type TurnActionCompletion = MovementCompletion & { stormDial?: Action; payments: Action[]; paymentsAfterPreparations?: boolean; bid?: Action; revival?: RevivalPromisePlan; alliance?: Action[]; battlePlan?: BattleCompletion; traitor?: Action; cardPreparations?: Action[]; battlePower?: Action; freshDiscard?: Action };
|
||||
type TurnActionCompletion = MovementCompletion & { stormDial?: Action; payments: Action[]; paymentsAfterPreparations?: boolean; bid?: Action; revival?: RevivalPromisePlan; alliance?: Action[]; battleChoice?: Action; battlePlan?: BattleCompletion; traitor?: Action; cardPreparations?: Action[]; battlePower?: Action; freshDiscard?: Action };
|
||||
/** Forecast deterministic opening work only. Auction/deck draws and foreign
|
||||
* choices stay at the real table; fixed Mentat receipts arrive after Amal. */
|
||||
function projectTurnActionOpeningEnd(g: Game) {
|
||||
@@ -24708,6 +24719,7 @@ function turnActionCompletionAfterFreshDiscard(source: Game, actor: string, unkn
|
||||
return null;
|
||||
}
|
||||
const dialLeaves = leaves.filter((leaf): leaf is Extract<TurnActionBranchLeaf, { kind: 'stormDial' }> => leaf.kind === 'stormDial');
|
||||
const choiceLeaves = leaves.filter((leaf): leaf is Extract<TurnActionBranchLeaf, { kind: 'battleChoice' }> => leaf.kind === 'battleChoice');
|
||||
const dialOpportunity = dialLeaves.length ? nativeStormDialOpportunity(source, actor) : null;
|
||||
if (dialLeaves.length && (!dialOpportunity || dialLeaves.some(leaf => leaf.source !== dialOpportunity.source))) return null;
|
||||
const dialValues = dialOpportunity ? turnActionStormDialChoices(dialLeaves, dialOpportunity.source) : [];
|
||||
@@ -24840,6 +24852,11 @@ function turnActionCompletionAfterFreshDiscard(source: Game, actor: string, unkn
|
||||
source.phaseOpening ? windowRequirements.filter(required => required.effect !== 'amal') : windowRequirements, prepareAlliance)) {
|
||||
const funded = cardSeed.game, payer = getPlayer(funded, actor);
|
||||
try {
|
||||
const opportunity = choiceLeaves.length ? turnActionBattleChoiceOpportunity(funded,actor) : null;
|
||||
if (choiceLeaves.length && (!opportunity || choiceLeaves.some(leaf => leaf.source !== opportunity.source))) continue;
|
||||
const choice = opportunity?.choices.find(candidate => choiceLeaves.every(leaf =>
|
||||
(candidate.territory === leaf.territory && candidate.target === leaf.target) === leaf.answer));
|
||||
if (choiceLeaves.length && !choice) continue;
|
||||
reconcileBattlePromises(funded, voluntary);
|
||||
const battle = funded.battle;
|
||||
const needsPlan = !!battle && !battle.revealed && [battle.attacker, battle.defender].includes(actor) &&
|
||||
@@ -24885,6 +24902,7 @@ function turnActionCompletionAfterFreshDiscard(source: Game, actor: string, unkn
|
||||
return { ...completion, ...(dialOpportunity ? { stormDial: { type: 'stormDial', amount: dialValues[0] } } : {}),
|
||||
...(cardPreparations.length ? { cardPreparations } : {}),
|
||||
...(cardSeed.cardsFirst ? { paymentsAfterPreparations: true } : {}), ...(bid ? { bid } : {}), ...(revival ? { revival } : {}),
|
||||
...(choice ? { battleChoice: {type:'chooseBattle',...choice} } : {}),
|
||||
...(battlePlan ? { battlePlan } : {}), ...(traitor ? { traitor } : {}),
|
||||
...(power.action ? { battlePower: power.action } : {}),
|
||||
...(alliancePlan ? { alliance: alliancePlan.steps.map(step => step.kind === 'groupLeave'
|
||||
@@ -24911,6 +24929,7 @@ function turnActionPromise(g: Game, p: Player, claim: TurnActionClaim, answer: b
|
||||
const powers = new Set<NativeBattlePower>();
|
||||
const windowCards: TurnActionWindowCards = {};
|
||||
let stormDialSource: string | undefined;
|
||||
let battleChoiceSource: string | undefined;
|
||||
const visit = (node: TurnActionClaim['mixed']): void => {
|
||||
if (node.kind === 'action') {
|
||||
if (node.action.kind === 'bid') bid = true;
|
||||
@@ -24919,6 +24938,14 @@ function turnActionPromise(g: Game, p: Player, claim: TurnActionClaim, answer: b
|
||||
stormDialSource = node.action.source;
|
||||
}
|
||||
if (node.action.kind === 'alliance') alliance = true;
|
||||
if (node.action.kind === 'battleChoice') {
|
||||
const opportunity = turnActionBattleChoiceOpportunity(g,p.id), selection = node.action;
|
||||
requireRule(opportunity && selection.source === opportunity.source &&
|
||||
(!battleChoiceSource || battleChoiceSource === selection.source) &&
|
||||
opportunity.choices.some(choice => choice.territory === selection.territory && choice.target === selection.target),
|
||||
'Retain the current chooser and an actual available battle.');
|
||||
battleChoiceSource = selection.source;
|
||||
}
|
||||
if (node.action.kind === 'battlePlan') plan = true;
|
||||
if (node.action.kind === 'traitorCall') traitor = true;
|
||||
if (node.action.kind === 'battlePower') powers.add(battlePowerOf(node.action.claim));
|
||||
@@ -24958,6 +24985,7 @@ function turnActionPromise(g: Game, p: Player, claim: TurnActionClaim, answer: b
|
||||
traitor: context ? { beneficiary: context.beneficiary, target: context.target, leader: context.leader,
|
||||
closed: false, call: null } : null } : undefined;
|
||||
let promise: TurnActionPromise = { turn: claim.turn, mixed: structuredClone(claim.mixed), event, player: p.id, asker, answer, compiled,
|
||||
...(battleChoiceSource ? { battleChoice: {source:battleChoiceSource,closed:false,selected:null} } : {}),
|
||||
...(Object.keys(windowCards).length ? { windowCards } : {}),
|
||||
...(dial ? { stormDial: { source: dial.source, closed: false, actual: null } } : {}),
|
||||
...(printedCards.size ? { cardPlays: { hajr: printedCards.has('hajr') ? { played: false, closed: !open } : null,
|
||||
@@ -25058,6 +25086,18 @@ function reconcileTurnActionPromises(g: Game, actor?: string, action?: Action, s
|
||||
if (g.pendingKull || suspendedKull) return;
|
||||
reconcileTurnActionCombat(g);
|
||||
reconcileTurnActionWindowCards(g);
|
||||
for (const row of g.turnActionPromises ?? []) {
|
||||
if (!row.battleChoice || row.battleChoice.closed || row.fulfilled || row.released ||
|
||||
turnActionBattleChoiceOpportunity(g,row.player)?.source === row.battleChoice.source) continue;
|
||||
g.turnActionPromises = turnActionRule(() => closeTurnActionBattleChoice(g.turnActionPromises!,
|
||||
row.player,row.turn,row.battleChoice!.source));
|
||||
const closed = g.turnActionPromises.find(promise => promise.event === row.event);
|
||||
if (closed && !closed.fulfilled && !closed.released && turnActionRule(() => turnActionBranches(closed).next().done)) {
|
||||
requireRule(actor !== closed.player, 'You cannot voluntarily close your required battle-choice answer.');
|
||||
closed.released = true;
|
||||
log(g, `${getPlayer(g,closed.player).name} can no longer fulfill an accepted Truthtrance commitment; that answer is no longer binding.`);
|
||||
}
|
||||
}
|
||||
for (const row of g.turnActionPromises ?? []) {
|
||||
if (!row.stormDial || row.stormDial.closed || row.fulfilled || row.released ||
|
||||
nativeStormDialOpportunity(g, row.player, row.stormDial.source)) continue;
|
||||
@@ -25268,6 +25308,8 @@ function projectedTurnActionGuide(g: Game, player: Player): { event: string; act
|
||||
} else if (!action && g.phase === 5 && g.active === player.id && !promise.transportClosed)
|
||||
action = completion.actions[0] ?? { type: 'endMovement' };
|
||||
}
|
||||
if (!action && g.phase === 6 && !g.battle && g.active === player.id && completion.battleChoice)
|
||||
action = completion.battleChoice;
|
||||
if (!action && g.phase === 6 && g.battle) {
|
||||
const battle = g.battle;
|
||||
if (completion.battlePower) action = completion.battlePower;
|
||||
@@ -50056,6 +50098,11 @@ function applyActionInner(
|
||||
(b.attacker === id ? b.defender : b.attacker) === action.target,
|
||||
);
|
||||
requireRule(choice, 'Choose one of your unresolved battles.');
|
||||
if (g.turnActionPromises) {
|
||||
const source = battleChooserEvent(g.turn,battleOrderAfterBattle(g),g.battleOrder?.uses.length ?? 0);
|
||||
g.turnActionPromises = turnActionRule(() => recordTurnActionBattleChoice(g.turnActionPromises!,id,g.turn,source,
|
||||
{territory:choice.territory,target:choice.attacker === id ? choice.defender : choice.attacker}));
|
||||
}
|
||||
g.auditorInsight = null;
|
||||
retireNexusChoamInsight(g);
|
||||
const ecaz = byFaction(g, 'ecaz');
|
||||
|
||||
Reference in new issue
Block a user