Support phase-wide bidding across all auctions
Verify and publish checkpoint container / container (push) Successful in 12m14s
Verify and publish checkpoint container / container (push) Successful in 12m14s
This commit is contained in:
1 parent
12060f3112
commit
38f1684e03
17 files changed
+1070
-18
No files matched your search
+191
-14
@@ -2504,6 +2504,8 @@ export type Game = {
|
||||
shipmentPromises?: ShipmentPromise[];
|
||||
bidPromises?: BidPromise[];
|
||||
phaseBidPromises?: PhaseBidPromise[];
|
||||
/** All-auction answers are separate from legacy ordinary-only promises. */
|
||||
phaseAnyBidPromises?: PhaseBidPromise[];
|
||||
richeseBidPromises?: RicheseBidPromise[];
|
||||
earlyRicheseBidPromises?: EarlyRicheseBidPromise[];
|
||||
/** Raw mixed question linked to one private native current-lot obligation. */
|
||||
@@ -8050,6 +8052,7 @@ function truthtranceDiscardSignature(g: Game, next: TruthDiscardContinuation) {
|
||||
...(next.record.question.kind === 'mixedRicheseBid' ? {
|
||||
mixedRicheseBidQuestions: g.mixedRicheseBidQuestions, richeseBidPromises: g.richeseBidPromises,
|
||||
} : {}),
|
||||
...(next.record.question.kind === 'phaseAnyBid' ? {phaseAnyBidPromises:g.phaseAnyBidPromises} : {}),
|
||||
...(next.record.question.kind === 'mixedRevival' ? {
|
||||
mixedRevivalQuestions: g.mixedRevivalQuestions, revivalExpressionPromises: g.revivalExpressionPromises,
|
||||
} : {}),
|
||||
@@ -9955,7 +9958,7 @@ function advancedSaphoAuctionSemuta(g: Game): boolean {
|
||||
}
|
||||
function advancedTruthAuctionSupported(g: Game, kind: TruthQuestion['kind']): boolean {
|
||||
return advancedSaphoAuctionSemuta(g) &&
|
||||
['fact','freeform','bid','mixedBid','phaseBid','richeseBid','mixedRicheseBid'].includes(kind);
|
||||
['fact','freeform','bid','mixedBid','phaseBid','phaseAnyBid','richeseBid','mixedRicheseBid'].includes(kind);
|
||||
}
|
||||
/** Bind a parked native ride to its original remaining Spice Blow sequence. */
|
||||
function wormDiscardCursor(g: Game): string {
|
||||
@@ -17104,7 +17107,7 @@ function pledgeIntegrity(g: Game) {
|
||||
* These rows are public timing facts; no opponent wallet or card is inspected. */
|
||||
function otherPledgeCommitments(g: Game): boolean {
|
||||
const rows: unknown[] = [
|
||||
...(g.shipmentPromises ?? []), ...(g.bidPromises ?? []), ...(g.phaseBidPromises ?? []),
|
||||
...(g.shipmentPromises ?? []), ...(g.bidPromises ?? []), ...(g.phaseBidPromises ?? []), ...(g.phaseAnyBidPromises ?? []),
|
||||
...(g.richeseBidPromises ?? []), ...(g.earlyRicheseBidPromises ?? []),
|
||||
...(g.revivalPromises ?? []), ...(g.leaderRevivalPromises ?? []), ...(g.revivalExpressionPromises ?? []),
|
||||
...(g.bribePromises ?? []), ...(g.bribeExpressionPromises ?? []),
|
||||
@@ -17369,7 +17372,7 @@ function coalitionFundingAvailable(g: Game, p: Player, committedBid = false): bo
|
||||
fulfilled?: boolean; released?: boolean}[] | undefined) => !!records?.some(record =>
|
||||
group.members.includes(record.player) && !record.fulfilled && !record.released &&
|
||||
(record.turn !== g.turn || record.answer));
|
||||
return committedBid || ![g.bidPromises, g.phaseBidPromises, g.turnActionPromises,
|
||||
return committedBid || ![g.bidPromises, g.phaseBidPromises, g.phaseAnyBidPromises, g.turnActionPromises,
|
||||
g.revivalPromises, g.leaderRevivalPromises, g.revivalExpressionPromises].some(groupHasUnsettled) &&
|
||||
!groupHasFundedBribe(g.bribePromises) && !groupHasFundedBribe(g.bribeExpressionPromises);
|
||||
}
|
||||
@@ -18056,6 +18059,7 @@ function basicBribeInterrupt(g: Game, p: Player): boolean {
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [], p.id, g.turn).length ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [], p.id, g.turn).length ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).length ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [], p.id, g.turn).length ||
|
||||
(g.bidPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
(g.earlyRicheseBidPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
(g.richeseBidPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
@@ -18354,7 +18358,8 @@ function phaseBidWitnesses(g: Game, p: Player): PhaseBidOpportunity[] {
|
||||
// A definite answer spends the actual held Truthtrance before Bidding.
|
||||
// Count its holder's newly freed slot only when that reserved card is
|
||||
// still in a full hand; an unknown answer retains it and binds nothing.
|
||||
const committedTruth = g.truthtrance?.question?.kind === 'phaseBid' ? g.truthtrance.queue[0] : undefined;
|
||||
const committedTruth = g.truthtrance?.question && ['phaseBid','phaseAnyBid'].includes(g.truthtrance.question.kind)
|
||||
? g.truthtrance.queue[0] : undefined;
|
||||
const holder = committedTruth && g.players.find(seat => seat.id === committedTruth.player);
|
||||
const freedSlot = !!holder && holder.hand.length === handLimit(holder) &&
|
||||
holder.hand.some(card => card.id === committedTruth!.card);
|
||||
@@ -18535,6 +18540,7 @@ function earlyRicheseBidMaximum(g: Game, p: Player): number {
|
||||
}
|
||||
function earlyRicheseBidTruthAnswers(g: Game,p: Player,claim: EarlyRicheseBidClaim): TruthAnswer[] {
|
||||
if (!earlyRicheseBidWindow(g) || claim.turn !== g.turn) return [];
|
||||
if (livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length) return ['unknown'];
|
||||
if (richeseBidOtherPromises(g,p)) return ['unknown'];
|
||||
const asker = g.truthtrance?.queue[0]?.player ?? g.players.find(row => row.id !== p.id)?.id ?? g.host;
|
||||
const answers = earlyRicheseBidRule(() => earlyRicheseBidAnswerOptions(g.earlyRicheseBidPromises ?? [],claim,p.id,asker,
|
||||
@@ -18599,7 +18605,8 @@ function richeseBidOtherPromises(g: Game, p: Player): boolean {
|
||||
liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
hasBribePromises(g,p.id,true) || liveTurnActionPromises(g.turnActionPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn).some(row => row.answer);
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn).some(row => row.answer) ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).some(row => row.answer);
|
||||
}
|
||||
/** Other financial/action answers need a joint planner before they can
|
||||
* coexist with a live Once Around Yes. Reject the unsupported combination at
|
||||
@@ -18614,6 +18621,7 @@ function richeseBidCompatibleLaterPromises(g: Game,p: Player): boolean {
|
||||
function richeseBidTruthAnswers(g: Game, p: Player, claim: RicheseBidClaim): TruthAnswer[] {
|
||||
const lot = g.richeseAuction;
|
||||
if (!richeseBidWindow(g) || !lot || claim.turn !== g.turn || claim.event !== lot.event ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length ||
|
||||
!lot.eligible.includes(p.id) || lot.acted.includes(p.id) ||
|
||||
!richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return [];
|
||||
const base = g.richeseBidPromises ?? [], opportunity = richeseBidOpportunity(g,p);
|
||||
@@ -18640,6 +18648,7 @@ function compileMixedRicheseBid(g: Game, p: Player, claim: MixedRicheseBidClaim,
|
||||
function mixedRicheseBidTruthAnswers(g: Game, p: Player, claim: MixedRicheseBidClaim): TruthAnswer[] {
|
||||
const lot = g.richeseAuction;
|
||||
if (!richeseBidWindow(g) || !lot || claim.turn !== g.turn || claim.event !== lot.event ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length ||
|
||||
!lot.eligible.includes(p.id) || lot.acted.includes(p.id) ||
|
||||
!richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return [];
|
||||
const answers: TruthAnswer[] = [];
|
||||
@@ -18852,6 +18861,7 @@ function viablePhaseBidWitnesses(g: Game, p: Player, promises: readonly PhaseBid
|
||||
* bid impossible. If the future joint planner has no witness, a definite
|
||||
* answer is withheld rather than offered and rejected after binding. */
|
||||
function phaseBidCompatibleLaterPromises(g: Game, p: Player): boolean {
|
||||
if (livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length) return false;
|
||||
if (!richeseBidCompatibleLaterPromises(g,p)) return false;
|
||||
const live = livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn);
|
||||
if (!live.some(row => row.answer)) return true;
|
||||
@@ -18869,7 +18879,8 @@ function phaseBidRule<T>(run: () => T): T {
|
||||
catch (error) { if (error instanceof PhaseBidPromiseError) throw new RuleError(error.message); throw error; }
|
||||
}
|
||||
function phaseBidTruthAnswers(g: Game, p: Player, claim: PhaseBidClaim): TruthAnswer[] {
|
||||
if (!phaseBidQuestionWindow(g) || claim.turn !== g.turn) return [];
|
||||
if (!phaseBidQuestionWindow(g) || claim.turn !== g.turn ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length) return [];
|
||||
const base = g.phaseBidPromises ?? [];
|
||||
const answers: TruthAnswer[] = [];
|
||||
for (const answer of [true, false]) {
|
||||
@@ -18900,9 +18911,11 @@ function bindPhaseBidTruth(g: Game, p: Player, claim: PhaseBidClaim, answer: boo
|
||||
}
|
||||
function phaseBidIntegrity(g: Game) {
|
||||
phaseBidRule(() => validatePhaseBidPromises(g.phaseBidPromises ?? [],g.players.map(player => player.id)));
|
||||
phaseAnyBidIntegrity(g);
|
||||
}
|
||||
function reconcilePhaseBids(g: Game, voluntary?: {actor:string;action:Action}) {
|
||||
phaseBidIntegrity(g);
|
||||
reconcilePhaseAnyBids(g,voluntary);
|
||||
if (!g.phaseBidPromises?.length || g.truthtrance || g.response || g.decision || g.phaseOpening ||
|
||||
g.pendingTreacheryDiscard || g.pendingKarama || g.pendingKull || g.pendingRicheseBetrayal) return;
|
||||
for (const player of g.players) {
|
||||
@@ -18949,6 +18962,112 @@ function projectedPhaseBidGuide(g: Game, player: string): {action:Action} | null
|
||||
}
|
||||
return {action:{...action,phaseBidPromiseEvent:live[0].event,phaseBidPromiseLot:opportunity.lot}};
|
||||
}
|
||||
/** A current special-lot witness uses only this seat's own escrow and
|
||||
* eligibility. In particular it never reads another player's sealed bid. */
|
||||
function phaseAnySpecialOpportunity(g: Game, p: Player): PhaseBidOpportunity | null {
|
||||
const lot = g.richeseAuction;
|
||||
if (!lot || g.status !== 'playing' || g.phase !== 3 || lot.outcome || g.response || g.decision ||
|
||||
g.phaseOpening || g.pendingKarama || g.pendingTreacheryDiscard || g.pendingKull ||
|
||||
!lot.eligible.includes(p.id) || !richeseBidFitsHand(lot.source,lot.owner,p.id,p.hand.length,handLimit(p))) return null;
|
||||
if (lot.method === 'silent' ? Object.hasOwn(lot.sealed,p.id) :
|
||||
lot.method === 'onceAround' ? lot.acted.includes(p.id) || p.id === lot.owner && lot.active !== p.id && !lot.bidder :
|
||||
lot.passed.includes(p.id) || lot.bidder === p.id) return null;
|
||||
if (lot.method !== 'silent' && lot.bid >= Number.MAX_SAFE_INTEGER) return null;
|
||||
const minimum = lot.method === 'silent' ? 1 : lot.bid + 1;
|
||||
const maximum = Math.min(Number.MAX_SAFE_INTEGER, uncommittedSpice(g,p) +
|
||||
richeseOwnCommitment(lot,g.richeseFunding ?? {},p.id) + (aidFor(g,p)?.amount ?? 0));
|
||||
return Number.isSafeInteger(maximum) && maximum >= minimum
|
||||
? {turn:g.turn,player:p.id,kind:'current',minimum,maximum} : null;
|
||||
}
|
||||
function phaseAnyBidWindow(g: Game): boolean {
|
||||
return g.status === 'playing' && g.phase >= 0 && g.phase <= 3 && phaseBidPromiseModeSupported(g) &&
|
||||
!g.response && !g.decision && !g.phaseOpening && !g.pendingKarama && !g.pendingTreacheryDiscard &&
|
||||
!g.pendingKull && !g.ixAuction && !g.currentAuctionSale &&
|
||||
(g.phase < 3 || !!bidOpportunity(g) || !!g.richeseAuction && !g.richeseAuction.outcome);
|
||||
}
|
||||
function phaseAnyBidConflict(g: Game, p: Player): boolean {
|
||||
return livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
(g.bidPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
(g.richeseBidPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
(g.pledgePromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
(g.charityPromises ?? []).some(row => row.player === p.id && row.turn === g.turn && !row.fulfilled && !row.released) ||
|
||||
hasBribePromises(g,p.id,true) ||
|
||||
liveEarlyRicheseBidPromises(g.earlyRicheseBidPromises ?? [],p.id,g.turn).length > 0 ||
|
||||
phaseBidFuturePlannerUnsupported(g,p);
|
||||
}
|
||||
/** A completed Black Market offer is followed by Richese's real cache lot.
|
||||
* Reserve this player's possibly winning card and its own committed funds;
|
||||
* do not speculate about any rival's Silent bid or a future refund. */
|
||||
function phaseAnyFutureCache(g: Game, p: Player): PhaseBidOpportunity | null {
|
||||
const lot = g.richeseAuction, round = g.richeseBidding;
|
||||
if (g.phase !== 3 || !lot || lot.source !== 'blackMarket' || !round || round.turn !== g.turn ||
|
||||
round.cacheCanceled || round.stage === 'complete' || !(g.richeseCache?.length)) return null;
|
||||
const ownOffer = lot.outcome?.kind === 'sold' ? lot.outcome.winner === p.id : !lot.outcome &&
|
||||
(lot.method === 'silent' ? (lot.sealed[p.id] ?? 0) > 0 : lot.bidder === p.id);
|
||||
const addedCards = ownOffer && lot.owner !== p.id ? 1 + Number(p.faction === 'harkonnen') : 0;
|
||||
if (p.hand.length + addedCards >= handLimit(p)) return null;
|
||||
const lockedAid = ownOffer ? (g.richeseFunding?.[p.id]?.allyPayment ?? 0) : 0;
|
||||
const maximum = Math.max(0,uncommittedSpice(g,p) + Math.max(0,(aidFor(g,p)?.amount ?? 0)-lockedAid));
|
||||
return Number.isSafeInteger(maximum) && maximum > 0
|
||||
? {turn:g.turn,player:p.id,kind:'future',minimum:1,maximum} : null;
|
||||
}
|
||||
function phaseAnyBidWitnesses(g: Game, p: Player, promises: readonly PhaseBidPromise[]): PhaseBidOpportunity[] {
|
||||
const special = phaseAnySpecialOpportunity(g,p);
|
||||
const futureCache = phaseAnyFutureCache(g,p);
|
||||
const ordinary = viablePhaseBidWitnesses(g,p,promises);
|
||||
return [...(special ? [special] : []),...(futureCache ? [futureCache] : []),...ordinary];
|
||||
}
|
||||
function phaseAnyBidTruthAnswers(g: Game, p: Player, claim: PhaseBidClaim): TruthAnswer[] {
|
||||
if (!phaseAnyBidWindow(g) || claim.turn !== g.turn || phaseAnyBidConflict(g,p)) return [];
|
||||
const asker = g.truthtrance?.queue[0]?.player ?? g.players.find(row => row.id !== p.id)?.id ?? g.host;
|
||||
return (['yes','no'] as const).filter(answer => {
|
||||
const all: PhaseBidPromise[] = [...(g.phaseAnyBidPromises ?? []),
|
||||
{...claim,event:'candidate',player:p.id,asker,answer:answer === 'yes'}];
|
||||
return !livePhaseBidPromises(all,p.id,g.turn).some(row => row.answer) ||
|
||||
phaseAnyBidWitnesses(g,p,all).some(witness => !!phaseBidCompletionRange(all,witness));
|
||||
});
|
||||
}
|
||||
function bindPhaseAnyBidTruth(g: Game,p: Player,claim: PhaseBidClaim,answer: boolean,asker: string): void {
|
||||
requireRule(phaseAnyBidTruthAnswers(g,p,claim).includes(answer ? 'yes' : 'no'),
|
||||
'This all-auction bid answer no longer has a legal completion.');
|
||||
(g.phaseAnyBidPromises ??= []).push({...claim,event:crypto.randomUUID(),player:p.id,asker,answer});
|
||||
}
|
||||
function phaseAnyBidIntegrity(g: Game): void {
|
||||
phaseBidRule(() => validatePhaseBidPromises(g.phaseAnyBidPromises ?? [],g.players.map(player => player.id)));
|
||||
}
|
||||
function reconcilePhaseAnyBids(g: Game,voluntary?: {actor:string;action:Action}): void {
|
||||
phaseAnyBidIntegrity(g);
|
||||
if (!g.phaseAnyBidPromises?.length || g.truthtrance || g.response || g.decision || g.phaseOpening ||
|
||||
g.pendingTreacheryDiscard || g.pendingKarama || g.pendingKull || g.pendingRicheseBetrayal) return;
|
||||
for (const p of g.players) {
|
||||
const live = livePhaseBidPromises(g.phaseAnyBidPromises,p.id,g.turn);
|
||||
if (!live.length) continue;
|
||||
const change = voluntary?.actor === p.id ? 'voluntary' : 'external';
|
||||
if (g.phase > 3) g.phaseAnyBidPromises = phaseBidRule(() => finishPhaseBidPhase(g.phaseAnyBidPromises!,p.id,g.turn,change));
|
||||
else g.phaseAnyBidPromises = phaseBidRule(() => reconcilePhaseBidPromises(g.phaseAnyBidPromises!,p.id,g.turn,
|
||||
phaseAnyBidWitnesses(g,p,g.phaseAnyBidPromises!),change));
|
||||
}
|
||||
}
|
||||
function projectedPhaseAnyBidGuide(g: Game, id: string): {action:Action} | null {
|
||||
const live = livePhaseBidPromises(g.phaseAnyBidPromises ?? [],id,g.turn), p = getPlayer(g,id);
|
||||
if (!live.length || g.truthtrance || !phaseAnyBidWindow(g)) return null;
|
||||
if (g.auction) {
|
||||
const ordinary = projectedPhaseBidGuide({...g,phaseBidPromises:live},id)?.action;
|
||||
if (!ordinary) return null;
|
||||
const action = {...ordinary}; delete action.phaseBidPromiseEvent; delete action.phaseBidPromiseLot;
|
||||
return {action:{...action,phaseAnyBidPromiseEvent:live[0].event,phaseAnyBidLot:g.auction.index + 1}};
|
||||
}
|
||||
const lot = g.richeseAuction;
|
||||
if (!lot || (lot.method === 'silent' ? Object.hasOwn(lot.sealed,id) : lot.active !== id)) return null;
|
||||
const required = live.some(row => row.answer), opportunity = phaseAnySpecialOpportunity(g,p);
|
||||
const range = opportunity && phaseBidCompletionRange(live,opportunity);
|
||||
if (required && !range) return null;
|
||||
const amount = required ? range!.minimum : lot.method === 'silent' ? 0 : null;
|
||||
const own = uncommittedSpice(g,p) + richeseOwnCommitment(lot,g.richeseFunding ?? {},id);
|
||||
return {action:{type:'richeseBid',event:lot.event,amount,
|
||||
allyPayment:amount === null ? 0 : Math.max(0,amount-own),phaseAnyBidPromiseEvent:live[0].event,
|
||||
phaseAnyBidLotEvent:lot.event}};
|
||||
}
|
||||
function bidPromiseCompletion(g: Game, p: Player, promises = g.bidPromises ?? []): Action | null {
|
||||
const opportunity = bidOpportunity(g);
|
||||
if (!opportunity) return null;
|
||||
@@ -18986,6 +19105,7 @@ function bidPromiseCompletion(g: Game, p: Player, promises = g.bidPromises ?? []
|
||||
function bidTruthAnswers(g: Game, p: Player, claim: BidClaim): ('yes' | 'no' | 'unknown')[] {
|
||||
const opportunity = bidOpportunity(g);
|
||||
if (!opportunity || !bidQuestionWindow(g) || claim.turn !== opportunity.turn || claim.lot !== opportunity.lot ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length ||
|
||||
!opportunity.eligible.includes(p.id) || opportunity.passed.includes(p.id) || opportunity.bidder === p.id) return [];
|
||||
return (['yes', 'no'] as const).filter(answer => {
|
||||
const phases = livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn);
|
||||
@@ -19027,6 +19147,7 @@ function compileMixedBid(g: Game, p: Player, claim: MixedBidClaim, answer: boole
|
||||
function mixedBidTruthAnswers(g: Game, p: Player, claim: MixedBidClaim): TruthAnswer[] {
|
||||
const opportunity = bidOpportunity(g);
|
||||
if (!opportunity || !mixedBidQuestionWindow(g) || claim.turn !== opportunity.turn || claim.lot !== opportunity.lot ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length ||
|
||||
!opportunity.eligible.includes(p.id) || opportunity.passed.includes(p.id) || opportunity.bidder === p.id) return [];
|
||||
const answers: TruthAnswer[] = [];
|
||||
for (const answer of [true, false]) {
|
||||
@@ -19112,6 +19233,18 @@ function guardPromisedBid(g: Game, p: Player, action: Action, amount?: number) {
|
||||
if (action.bidPromiseEvent !== undefined) requireRule(typeof action.bidPromiseEvent === 'string' &&
|
||||
live.some(promise => promise.event === action.bidPromiseEvent), 'This bid commitment guide is stale.');
|
||||
if (!opportunity) return;
|
||||
if (amount !== undefined && livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length)
|
||||
g.phaseAnyBidPromises = phaseBidRule(() => recordPhaseBid(g.phaseAnyBidPromises!,p.id,g.turn,amount));
|
||||
if (livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).some(row => row.answer)) {
|
||||
const trial = structuredClone(g);
|
||||
if (amount !== undefined) {
|
||||
trial.auction!.bid = amount; trial.auction!.bidder = p.id;
|
||||
trial.auction!.allyPayment = normalBidQuote(g,p,amount,action.allyPayment).allyPayment;
|
||||
} else if (!trial.auction!.passed.includes(p.id)) trial.auction!.passed.push(p.id);
|
||||
const future = phaseAnyBidWitnesses(trial,getPlayer(trial,p.id),trial.phaseAnyBidPromises ?? [])
|
||||
.find(witness => witness.kind === 'future' && !!phaseBidCompletionRange(trial.phaseAnyBidPromises ?? [],witness));
|
||||
requireRule(future, 'Keep a funded later lot or place the bid required by your Truthtrance Yes.');
|
||||
}
|
||||
const phaseLive = livePhaseBidPromises(g.phaseBidPromises ?? [],p.id,g.turn);
|
||||
if (amount !== undefined && phaseLive.length)
|
||||
g.phaseBidPromises = phaseBidRule(() => recordPhaseBid(g.phaseBidPromises!,p.id,g.turn,amount));
|
||||
@@ -19254,9 +19387,10 @@ export function advanceAuctionClock(source: Game, now: number, controlEpoch: str
|
||||
if (!(error instanceof RuleError)) throw error;
|
||||
if (lot) {
|
||||
const context = {turn:game.turn,event:lot.event,player:actor};
|
||||
const required = richeseBidRequired(game.richeseBidPromises ?? [], context);
|
||||
const required = richeseBidRequired(game.richeseBidPromises ?? [], context) ||
|
||||
livePhaseBidPromises(game.phaseAnyBidPromises ?? [],actor,game.turn).some(row => row.answer);
|
||||
if (!required) throw error;
|
||||
const completion = projectedRicheseBidGuide(game, actor)?.action;
|
||||
const completion = projectedPhaseAnyBidGuide(game, actor)?.action ?? projectedRicheseBidGuide(game, actor)?.action;
|
||||
requireRule(completion?.type === 'richeseBid',
|
||||
'The expired Richese bid needs a legal completion of its binding Truthtrance answer.');
|
||||
next = applyAction(game, actor, completion);
|
||||
@@ -19266,7 +19400,7 @@ export function advanceAuctionClock(source: Game, now: number, controlEpoch: str
|
||||
? turnActionCompletion(game, actor)?.bid : undefined;
|
||||
const opportunity = bidOpportunity(game);
|
||||
const required = opportunity && bidRequired(game.bidPromises ?? [], actor, opportunity);
|
||||
const phaseGuide = projectedPhaseBidGuide(game, actor)?.action;
|
||||
const phaseGuide = projectedPhaseAnyBidGuide(game,actor)?.action ?? projectedPhaseBidGuide(game, actor)?.action;
|
||||
if (!whole && !required && phaseGuide?.type !== 'bid') throw error;
|
||||
const completion = phaseGuide?.type === 'bid' ? phaseGuide : minimumCompelledAuctionBid(game, actor);
|
||||
requireRule(completion, 'The expired ordinary bid needs a legal completion of its binding Truthtrance answer.');
|
||||
@@ -19423,7 +19557,8 @@ function emperorAuctionGiftMaximum(g: Game, p: Player): number {
|
||||
liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [], p.id, g.turn).length ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer)) return 0;
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [], p.id, g.turn).some(row => row.answer)) return 0;
|
||||
const maximum = Math.max(0, uncommittedSpice(g, p));
|
||||
if (!livePledgePromises(g.pledgePromises ?? [], p.id, g.turn, g.phase).some(row => row.answer)) return maximum;
|
||||
// The owner can fulfill the native update within this opportunity, before
|
||||
@@ -21532,7 +21667,7 @@ function choamMarketSkipCommitments(g: Game): boolean {
|
||||
!!rows?.some(row => row.turn === g.turn);
|
||||
return !!g.truthHistory?.some(row => row.turn === g.turn) ||
|
||||
recorded(g.travelPromises) || recorded(g.turnActionPromises) || recorded(g.shipmentPromises) ||
|
||||
recorded(g.bidPromises) || recorded(g.phaseBidPromises) || recorded(g.revivalPromises) ||
|
||||
recorded(g.bidPromises) || recorded(g.phaseBidPromises) || recorded(g.phaseAnyBidPromises) || recorded(g.revivalPromises) ||
|
||||
recorded(g.leaderRevivalPromises) || recorded(g.revivalExpressionPromises) || recorded(g.bribePromises) ||
|
||||
recorded(g.bribeExpressionPromises) || recorded(g.pledgePromises) || recorded(g.alliancePromises) ||
|
||||
recorded(g.allianceExpressionPromises) || recorded(g.movementPromises) || recorded(g.movementExpressionPromises) ||
|
||||
@@ -24227,6 +24362,7 @@ function turnActionTruthAnswers(g: Game, p: Player, claim: TurnActionClaim): Tru
|
||||
try { promise = turnActionPromise(g, p, claim, answer, 'candidate', g.players.find(other => other.id !== p.id)!.id); }
|
||||
catch (error) { if (error instanceof RuleError) continue; throw error; }
|
||||
if (promise.compiled.kind === 'constant' && promise.compiled.value !== answer) continue;
|
||||
if (promise.compiled.kind !== 'constant' && livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length) continue;
|
||||
const trial = { ...turnActionAnswerSource(g, p.id, !!promise.alliance, !!promise.windowCards, { claim, answer }),
|
||||
turnActionPromises: [...(g.turnActionPromises ?? []), promise], travelPromiseOrder: undefined };
|
||||
if (!richeseBidCompatibleLaterPromises(trial,p) && promise.compiled.kind !== 'constant') continue;
|
||||
@@ -30944,7 +31080,8 @@ function emperorGuildTimingGiftQuote(g: Game, p: Player): {recipient: string; ma
|
||||
liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [], p.id, g.turn).length ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer)) return null;
|
||||
(livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [], p.id, g.turn).some(row => row.answer))) return null;
|
||||
const maximum = Math.max(0, uncommittedSpice(g, p));
|
||||
return maximum > 0 ? { recipient: p.ally, maximum } : null;
|
||||
}
|
||||
@@ -31043,7 +31180,8 @@ function emperorPhaseOpeningGiftQuote(g: Game, p: Player): {recipient: string; m
|
||||
liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
liveTurnActionPromises(g.turnActionPromises ?? [], p.id, g.turn).length ||
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer)) return null;
|
||||
livePhaseBidPromises(g.phaseBidPromises ?? [], p.id, g.turn).some(row => row.answer) ||
|
||||
livePhaseBidPromises(g.phaseAnyBidPromises ?? [], p.id, g.turn).some(row => row.answer)) return null;
|
||||
const maximum = Math.max(0, uncommittedSpice(g, p));
|
||||
return maximum > 0 ? {recipient: p.ally, maximum} : null;
|
||||
}
|
||||
@@ -34906,7 +35044,7 @@ function futureBattleLeaderTruthAnswers(g: Game, p: Player, q: FutureBattleLeade
|
||||
...(g.travelPromises ?? []), ...(g.shipmentPromises ?? []), ...(g.movementPromises ?? []),
|
||||
...(g.movementExpressionPromises ?? []), ...(g.bribePromises ?? []), ...(g.bribeExpressionPromises ?? []),
|
||||
...(g.revivalPromises ?? []), ...(g.leaderRevivalPromises ?? []), ...(g.revivalExpressionPromises ?? []),
|
||||
...(g.bidPromises ?? []), ...(g.phaseBidPromises ?? []), ...(g.richeseBidPromises ?? []),
|
||||
...(g.bidPromises ?? []), ...(g.phaseBidPromises ?? []), ...(g.phaseAnyBidPromises ?? []), ...(g.richeseBidPromises ?? []),
|
||||
...(g.earlyRicheseBidPromises ?? []), ...(g.alliancePromises ?? []), ...(g.allianceExpressionPromises ?? []),
|
||||
];
|
||||
if (q.turn !== g.turn || q.target !== p.id || !futureBattleLeaderTiming(g) ||
|
||||
@@ -44460,6 +44598,12 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
Object.keys(guide.action).every(key => action[key] === guide.action[key]),
|
||||
'This phase bid guide is stale or belongs to another auction lot.');
|
||||
}
|
||||
if (action.phaseAnyBidPromiseEvent !== undefined || action.phaseAnyBidLot !== undefined || action.phaseAnyBidLotEvent !== undefined) {
|
||||
const guide = projectedPhaseAnyBidGuide(state,id);
|
||||
requireRule(guide && Object.keys(action).sort().join(',') === Object.keys(guide.action).sort().join(',') &&
|
||||
Object.keys(guide.action).every(key => action[key] === guide.action[key]),
|
||||
'This all-auction bid guide is stale or belongs to another lot.');
|
||||
}
|
||||
if (action.charityPromiseEvent !== undefined || action.charityPromiseTurn !== undefined) {
|
||||
const guide = projectedCharityTruthGuide(state,id);
|
||||
requireRule(guide && Object.keys(action).sort().join(',') === Object.keys(guide.action).sort().join(',') &&
|
||||
@@ -44488,6 +44632,18 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
// turn that forced debit into the passer's voluntary payment or expenditure.
|
||||
const voluntary = forcedThumperDraw || action.type === 'passResponse' ? undefined : { actor: id, action };
|
||||
const pledgeVoluntary = initiator === id ? voluntary : undefined;
|
||||
// A paid Box can leave a private selection open after spending spice. Quote
|
||||
// both its cost and later selection before that pending decision can hide
|
||||
// the loss of this player's last all-auction bid witness.
|
||||
if (voluntary && livePhaseBidPromises(state.phaseAnyBidPromises ?? [],id,state.turn).some(row => row.answer) &&
|
||||
(state.pendingNullentropy?.player === id || g.pendingNullentropy?.player === id)) {
|
||||
const trial = structuredClone(g), owner = getPlayer(trial,id);
|
||||
trial.truthtrance = null; trial.response = null; trial.decision = null;
|
||||
trial.phaseOpening = null; trial.pendingTreacheryDiscard = null; trial.pendingKarama = null;
|
||||
requireRule(phaseAnyBidWitnesses(trial,owner,trial.phaseAnyBidPromises ?? [])
|
||||
.some(witness => !!phaseBidCompletionRange(trial.phaseAnyBidPromises ?? [],witness)),
|
||||
'Keep a funded bid available while completing the paid Box search.');
|
||||
}
|
||||
// Voluntary actions may create a response owned by somebody else before the
|
||||
// regular reconciler can run. Quote the already-completed action on a
|
||||
// detached state before that response can hide loss of the last witness.
|
||||
@@ -45476,6 +45632,8 @@ function applyActionInner(
|
||||
bindEarlyRicheseBid: bindEarlyRicheseBidTruth,
|
||||
phaseBidAnswers: phaseBidTruthAnswers,
|
||||
bindPhaseBid: bindPhaseBidTruth,
|
||||
phaseAnyBidAnswers: phaseAnyBidTruthAnswers,
|
||||
bindPhaseAnyBid: bindPhaseAnyBidTruth,
|
||||
turnActionAnswers: turnActionTruthAnswers,
|
||||
bindTurnAction: bindTurnActionTruth,
|
||||
travelAnswers: travelTruthAnswers,
|
||||
@@ -48310,6 +48468,8 @@ function applyActionInner(
|
||||
if ((lot.method === 'onceAround' || lot.method === 'silent') && g.richeseBidPromises?.length)
|
||||
g.richeseBidPromises = richeseBidRule(() => recordRicheseBid(g.richeseBidPromises!,
|
||||
{turn:g.turn,event:lot.event,player:p.id},lot.method === 'silent' && amount === 0 ? null : amount));
|
||||
if (amount !== null && amount > 0 && livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).length)
|
||||
g.phaseAnyBidPromises = phaseBidRule(() => recordPhaseBid(g.phaseAnyBidPromises!,p.id,g.turn,amount));
|
||||
g.richeseAuction = submitRicheseBid(
|
||||
lot,
|
||||
{ event: stringField(action.event), actor: p.id, amount },
|
||||
@@ -48321,6 +48481,11 @@ function applyActionInner(
|
||||
allyPayment,
|
||||
donor: allyPayment ? p.ally : null,
|
||||
};
|
||||
if (livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).some(row => row.answer)) {
|
||||
const future = phaseAnyBidWitnesses(g,p,g.phaseAnyBidPromises ?? [])
|
||||
.some(witness => witness.kind === 'future' && !!phaseBidCompletionRange(g.phaseAnyBidPromises ?? [],witness));
|
||||
requireRule(future, 'Keep a funded later lot or place the bid required by your Truthtrance Yes.');
|
||||
}
|
||||
g.active = g.richeseAuction.active;
|
||||
log(
|
||||
g,
|
||||
@@ -48410,6 +48575,13 @@ function applyActionInner(
|
||||
maximum,
|
||||
t === 'emperorGift' ? 'Spice' : 'Forces',
|
||||
);
|
||||
if (t === 'emperorGift' && livePhaseBidPromises(g.phaseAnyBidPromises ?? [],p.id,g.turn).some(row => row.answer)) {
|
||||
const trial = structuredClone(g), owner = getPlayer(trial,p.id);
|
||||
owner.spice -= amount;
|
||||
requireRule(phaseAnyBidWitnesses(trial,owner,trial.phaseAnyBidPromises ?? [])
|
||||
.some(witness => !!phaseBidCompletionRange(trial.phaseAnyBidPromises ?? [],witness)),
|
||||
'Keep enough spice for your Truthtrance bid answer.');
|
||||
}
|
||||
const elite =
|
||||
t === 'emperorRevival'
|
||||
? eliteChoice(
|
||||
@@ -49970,6 +50142,11 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
g.truthtrance.question.kind === 'phaseBid' ? phaseBidTruthAnswers(g,me,g.truthtrance.question) : null,
|
||||
phaseBidPromises: projectedPhaseBidPromises(g,id),
|
||||
phaseBidPromiseGuide: projectedPhaseBidGuide(g,id),
|
||||
truthPhaseAnyBidTargets: phaseAnyBidWindow(g) ? g.players.map(player => player.id) : [],
|
||||
truthPhaseAnyBidAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
g.truthtrance.question.kind === 'phaseAnyBid' ? phaseAnyBidTruthAnswers(g,me,g.truthtrance.question) : null,
|
||||
phaseAnyBidPromises: (g.phaseAnyBidPromises ?? []).filter(row => row.player === id).map(row => ({...row})),
|
||||
phaseAnyBidGuide: projectedPhaseAnyBidGuide(g,id),
|
||||
alliancePromiseNexus: (() => { const nexus = allianceOpportunity(g); return nexus ? { turn: nexus.turn } : null; })(),
|
||||
truthAllianceTargets: allianceQuestionWindow(g) ? g.players.map(player => player.id) : [],
|
||||
truthAllianceAnswers: g.truthtrance?.stage === 'answer' && g.truthtrance.question?.target === id &&
|
||||
|
||||
Reference in new issue
Block a user