Combine Basic bidding and movement commitments
Verify and publish checkpoint container / container (push) Successful in 10m49s
Verify and publish checkpoint container / container (push) Successful in 10m49s
This commit is contained in:
1 parent
b03efd2371
commit
235696263a
9 files changed
+404
-17
No files matched your search
+66
-16
@@ -6122,6 +6122,12 @@ function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||
function preflightPublicDealSettlement(g: Game, deal: PublicDeal, initiator: string): void {
|
||||
requireRule(!bribeTimingBlock(g), 'Finish the current decision or response before paying a deal.');
|
||||
const legs = publicDealImmediateLegs(deal);
|
||||
// Existing unrelated obligations may already lack a funded route after an
|
||||
// external loss. Preserve witnessed routes without making those unrelated
|
||||
// shortfalls a veto over this agreement.
|
||||
const protectedPayers = g.players.filter(player =>
|
||||
pendingPublicDealPayments(g.deals ?? [],player.id,g.turn).length > 0 && publicDealCompletion(g,player))
|
||||
.map(player => player.id);
|
||||
const visit = (trial: Game, index: number): void => {
|
||||
if (index === legs.length) return;
|
||||
const leg = legs[index];
|
||||
@@ -6132,8 +6138,8 @@ function preflightPublicDealSettlement(g: Game, deal: PublicDeal, initiator: str
|
||||
const candidates = pending ? [false,true].map(redirect => applyActionWithInitiator(next,pending.owner,
|
||||
{type:'decision',event:pending.source.event,redirect},pending.owner,{publicDealSettlement:deal.id})) : [next];
|
||||
for (const candidate of candidates) {
|
||||
for (const player of candidate.players) if (pendingPublicDealPayments(candidate.deals ?? [],player.id,candidate.turn).length)
|
||||
requireRule(publicDealCompletion(candidate,player), 'Retain a funded completion for each due deal payment.');
|
||||
for (const id of protectedPayers)
|
||||
requireRule(publicDealCompletion(candidate,getPlayer(candidate,id)), 'Retain a funded completion for each due deal payment.');
|
||||
visit(candidate,index + 1);
|
||||
}
|
||||
};
|
||||
@@ -18553,14 +18559,15 @@ function phaseBidHonorsTurnActions(g: Game, p: Player, lot: BidOpportunity, acti
|
||||
function phaseBidFuturePlannerUnsupported(g: Game, p: Player): boolean {
|
||||
return liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
liveShipmentPromises(g.shipmentPromises ?? [],p.id,g.turn).some(row => matchesShipment(row,null) !== row.answer) ||
|
||||
hasMovementPromises(g,p.id,true) || liveRevivalPromises(g.revivalPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
hasMovementPromises(g,p.id,!!g.advanced || g.expansions.length > 0) ||
|
||||
liveRevivalPromises(g.revivalPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
(!!bidOpportunity(g) && hasBribePromises(g,p.id,true));
|
||||
}
|
||||
/** A conservative owned-cash witness for a future Basic bid followed by
|
||||
* native Revival and Shipment commitments. Other obligations keep their own
|
||||
* native Revival, Shipment and Movement commitments. Other obligations keep their own
|
||||
* guards. No pledged refund, Charity, income, ally or Karama is assumed;
|
||||
* failure to find this witness is not proof of impossibility. */
|
||||
function phaseBidRevivalShipmentWitness(g: Game, p: Player, promises: readonly PhaseBidPromise[],
|
||||
@@ -18571,8 +18578,8 @@ function phaseBidRevivalShipmentWitness(g: Game, p: Player, promises: readonly P
|
||||
const shipments = liveShipmentPromises(g.shipmentPromises ?? [],p.id,g.turn);
|
||||
if (g.advanced || g.expansions.length || g.phase >= 3 || g.auction ||
|
||||
(![...revivals,...leaders].some(row => row.answer) && !expressions.length &&
|
||||
!shipments.some(row => matchesShipment(row,null) !== row.answer)) ||
|
||||
hasMovementPromises(g,p.id) ||
|
||||
!shipments.some(row => matchesShipment(row,null) !== row.answer) && !hasMovementPromises(g,p.id)) ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],p.id,g.turn).length || hasBribePromises(g,p.id) ||
|
||||
g.charityPromises?.some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released)) return null;
|
||||
const range = phaseBidCompletionRange(promises,witness);
|
||||
@@ -18591,15 +18598,17 @@ function phaseBidRevivalShipmentWitness(g: Game, p: Player, promises: readonly P
|
||||
const completed = completeTurnActionRevivalSeed(seed,p.id);
|
||||
if (!completed || currentRevivalPromiseCompletion(completed.game,getPlayer(completed.game,p.id),
|
||||
completed.game.revivalPromises ?? [])?.type !== 'ready') continue;
|
||||
if (shipments.some(row => matchesShipment(row,null) !== row.answer)) {
|
||||
if (hasMovementPromises(g,p.id) || shipments.some(row => matchesShipment(row,null) !== row.answer)) {
|
||||
const future = completed.game;
|
||||
future.phase = 5;
|
||||
future.ready = [];
|
||||
delete future.revivalOrder;
|
||||
resetGroundMovementForecast(future,p.id);
|
||||
future.active = p.id;
|
||||
const shipment = findShipmentCompletion(future,getPlayer(future,p.id),shipments);
|
||||
if (!shipment || shipment.early?.length || shipment.actions.some(action => action.type !== 'ship')) continue;
|
||||
const completion = hasMovementPromises(g,p.id)
|
||||
? groundMovementCompletion(future,p.id) : findShipmentCompletion(future,getPlayer(future,p.id),shipments);
|
||||
if (!completion || completion.early?.length ||
|
||||
completion.actions.some(action => !['ship','guildShip','move','endMovement'].includes(action.type))) continue;
|
||||
}
|
||||
return {...witness,minimum:range.minimum,maximum:range.minimum};
|
||||
}
|
||||
@@ -24485,7 +24494,7 @@ function reconcileTravelPromises(g: Game, actor?: string, action?: Action, sourc
|
||||
g.response?.kind === 'advisorFlip' && g.response.owner === p.id ||
|
||||
g.pendingAutomaticAdvisorFlips?.some(source => source.owner === p.id ||
|
||||
source.producer === 'groundMovement' && source.mover === p.id)) continue;
|
||||
if (!voluntary && (g.response || g.decision || g.pendingAmbassador || g.pendingTerrorEntry ||
|
||||
if (!voluntary && (g.response || g.decision || g.pendingEmperorAuctionGift || g.pendingAmbassador || g.pendingTerrorEntry ||
|
||||
g.pendingArrivalOverlap || g.pendingArrivalReaction?.length || g.pendingTreacheryDiscard ||
|
||||
g.phase === 3 && !g.currentAuctionSale &&
|
||||
(g.auction?.bidder === p.ally && (g.auction?.allyPayment ?? 0) > 0 ||
|
||||
@@ -24568,8 +24577,9 @@ function projectedDealTravelStatus(g: Game): Record<string, 'scheduled' | 'pendi
|
||||
function projectedTravelGuide(g: Game, player: Player): { event: string; action: Action } | null {
|
||||
const promise = liveTravelPromises(g.travelPromises ?? [], player.id, g.turn)[0];
|
||||
const lot = promise && g.phase === 3 && !g.decision ? bidOpportunity(g) : null;
|
||||
const needsBid = !!lot && bidRequired(g.bidPromises ?? [], player.id, lot);
|
||||
const requiredBid = needsBid ? projectedBidPromiseGuide(g, player.id) : null;
|
||||
const needsBid = !!lot && (bidRequired(g.bidPromises ?? [], player.id, lot) ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [],player.id,g.turn).length > 0);
|
||||
const requiredBid = needsBid ? projectedPhaseBidGuide(g,player.id) ?? projectedBidPromiseGuide(g, player.id) : null;
|
||||
const needsRevival = !!promise && g.phase <= 4 && [
|
||||
...liveRevivalPromises(g.revivalPromises ?? [], player.id, g.turn),
|
||||
...liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [], player.id, g.turn),
|
||||
@@ -24584,6 +24594,8 @@ function projectedTravelGuide(g: Game, player: Player): { event: string; action:
|
||||
if (!prior) return null;
|
||||
const action = { ...structuredClone(prior.action) };
|
||||
delete action.bidPromiseEvent;
|
||||
delete action.phaseBidPromiseEvent;
|
||||
delete action.phaseBidPromiseLot;
|
||||
delete action.revivalExpressionPromiseEvent;
|
||||
delete action.leaderRevivalPromiseEvent;
|
||||
delete action.revivalPromiseEvent;
|
||||
@@ -24591,7 +24603,15 @@ function projectedTravelGuide(g: Game, player: Player): { event: string; action:
|
||||
}
|
||||
const policy = promise && (g.phase < 5 || g.active === player.id) ? projectedGroundMovementPolicy(g, player) : null;
|
||||
const action = policy?.[0];
|
||||
return promise && action ? { event: promise.event, action: { ...structuredClone(action), travelPromiseEvent: promise.event, travelPromisePhase: g.phase } } : null;
|
||||
if (!promise || !action) return null;
|
||||
const native = {...structuredClone(action)};
|
||||
delete native.bidPromiseEvent;
|
||||
delete native.phaseBidPromiseEvent;
|
||||
delete native.phaseBidPromiseLot;
|
||||
delete native.revivalExpressionPromiseEvent;
|
||||
delete native.leaderRevivalPromiseEvent;
|
||||
delete native.revivalPromiseEvent;
|
||||
return { event: promise.event, action: { ...native, travelPromiseEvent: promise.event, travelPromisePhase: g.phase } };
|
||||
}
|
||||
function groundMovementCompletion(source: Game, actor: string,
|
||||
promises = liveMovementPromises(source.movementPromises ?? [], actor, source.turn),
|
||||
@@ -24839,7 +24859,21 @@ function earlyGroundMovementPolicy(g: Game, player: Player): Action[] | null {
|
||||
if (lot) return !lot.outcome && lot.eligible.includes(player.id) &&
|
||||
(lot.method === 'silent' ? !Object.hasOwn(lot.sealed, player.id) : lot.active === player.id)
|
||||
? [{ type: 'richeseBid', event: lot.event, amount: lot.method === 'silent' ? 0 : null, allyPayment: 0 }] : [];
|
||||
return g.auction?.active === player.id ? [{ type: 'passBid' }] : [];
|
||||
if (g.auction?.active !== player.id) return [];
|
||||
const guide = projectedPhaseBidGuide(g,player.id)?.action ?? projectedBidPromiseGuide(g,player.id)?.action;
|
||||
const ordinaryLot = bidOpportunity(g);
|
||||
if (guide) return [guide];
|
||||
if (livePhaseBidPromises(g.phaseBidPromises ?? [],player.id,g.turn).some(row => row.answer) ||
|
||||
ordinaryLot && bidRequired(g.bidPromises ?? [],player.id,ordinaryLot)) return [];
|
||||
return [{ type: 'passBid' }];
|
||||
}
|
||||
if (g.phase === 4 && !g.decision) {
|
||||
const guide = projectedRevivalExpressionPromiseGuide(g,player.id) ?? projectedLeaderRevivalPromiseGuide(g,player.id) ??
|
||||
projectedRevivalPromiseGuide(g,player.id);
|
||||
if (guide) return [guide.action];
|
||||
if ([...liveRevivalPromises(g.revivalPromises ?? [],player.id,g.turn),
|
||||
...liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [],player.id,g.turn),
|
||||
...liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [],player.id,g.turn)].some(row => row.answer)) return [];
|
||||
}
|
||||
const completion = groundMovementCompletion(g, player.id);
|
||||
if (!completion) return null;
|
||||
@@ -24973,7 +25007,15 @@ function projectedMovementExpressionGuide(g: Game, player: Player): { phase: num
|
||||
const promise = live.find(promise => promise.answer) ?? live[0];
|
||||
if (!promise) return null;
|
||||
const action = projectedGroundMovementPolicy(g, player)?.[0];
|
||||
return action ? { phase: g.phase, action: { ...structuredClone(action), movementExpressionPromiseEvent: promise.event } } : null;
|
||||
if (!action) return null;
|
||||
const native = {...structuredClone(action)};
|
||||
delete native.bidPromiseEvent;
|
||||
delete native.phaseBidPromiseEvent;
|
||||
delete native.phaseBidPromiseLot;
|
||||
delete native.revivalExpressionPromiseEvent;
|
||||
delete native.leaderRevivalPromiseEvent;
|
||||
delete native.revivalPromiseEvent;
|
||||
return { phase: g.phase, action: { ...native, movementExpressionPromiseEvent: promise.event } };
|
||||
}
|
||||
function checkGroundMovementPromises(g: Game, p: Player, move: MovementOrder) {
|
||||
if (move.source === 'ambassador' || !hasMovementPromises(g, p.id)) return;
|
||||
@@ -25033,7 +25075,7 @@ function reconcileGroundMovementPromises(g: Game, actor?: string, action?: Actio
|
||||
(['card', 'bribe', 'charity', 'alliance', 'pledgeAid', 'emperorGift', 'bid', 'richeseGift', 'revealNoField', 'revive', 'reviveLeader', 'reviveKwisatz', 'emperorRevival', 'decision'].includes(action.type) ||
|
||||
action.type === 'richeseBid' && typeof action.amount === 'number' && action.amount > 0 ||
|
||||
action.type === 'ready' && [2, 4].includes(sourcePhase)));
|
||||
const busy = !!(g.response || g.decision || g.phaseOpening || g.pendingTreacheryDiscard ||
|
||||
const busy = !!(g.response || g.decision || g.phaseOpening || g.pendingTreacheryDiscard || g.pendingEmperorAuctionGift ||
|
||||
g.pendingAmbassador || g.pendingTerrorEntry || g.pendingArrivalOverlap || g.pendingArrivalReaction?.length ||
|
||||
g.phase === 3 && !g.currentAuctionSale &&
|
||||
(g.auction?.bidder === p.ally && (g.auction?.allyPayment ?? 0) > 0 ||
|
||||
@@ -34069,6 +34111,14 @@ function earlyRevivalCompletionSeeds(initial: Game, source: Game, owner: string)
|
||||
}
|
||||
// Native Bidding refunds its unused pledges. An ally's incoming
|
||||
// Bidding escrow is never a promised future Shipment contribution.
|
||||
// This detached seed already accounts for the revealed cache sale.
|
||||
// Its optional gift window belongs to the real table, not the later
|
||||
// Revival/Movement simulation; leave the live window untouched.
|
||||
const gift = source.pendingEmperorAuctionGift, outcome = source.richeseAuction?.outcome;
|
||||
if (gift?.source === 'richese' && !source.response && !source.decision && gift.quote &&
|
||||
outcome?.kind === 'sold' && outcome.winner === gift.quote.winner &&
|
||||
outcome.amount === gift.quote.amount && source.richeseAuction?.cardId === gift.quote.card.id)
|
||||
g.pendingEmperorAuctionGift = null;
|
||||
g.aid = {}; g.auction = null; g.currentAuctionSale = null;
|
||||
g.richeseAuction = null; g.richeseFunding = {}; g.richeseBidding = null;
|
||||
fundingSeeds.push({ game: g, actions, early });
|
||||
|
||||
Reference in new issue
Block a user