Support deferred payments with travel deals
Verify and publish checkpoint container / container (push) Successful in 11m29s

This commit is contained in:
Quintine committed 2026-11-16 14:17:48 +11:00
1 parent 9536c77062
commit 5e294215be
16 files changed
+603 -100

No files matched your search

+11 -14
View File
@@ -6127,6 +6127,7 @@ function publicDealCompletion(g: Game, payer: Player): boolean {
!turnActionCompletion(trial,payer.id)) return false;
const voluntary = {actor:payer.id,action:{type:'bribe'}};
reconcileBattlePromises(trial,voluntary);
reconcileTravelPromises(trial,payer.id,voluntary.action,g.phase);
reconcileShipmentPromises(trial,voluntary);
reconcileGroundMovementPromises(trial,payer.id,voluntary.action,g.phase);
reconcileBidPromises(trial,voluntary);
@@ -24323,9 +24324,6 @@ function bindPublicDealTravel(g: Game, deal: PublicDeal) {
const action = { kind: term.kind, territory: term.territory, minimum: term.minimum };
const claim: TravelClaim = { turn: due, mixed: { kind: 'action', action } };
if (due > g.turn) {
requireRule(!g.deals?.some(other => other.payment?.kind === 'deferredBribe' &&
other.paymentStatus === 'pending' && other.payment.payer === player.id && other.payment.dueTurn === due),
'This traveler already has a payment due in the same turn.');
// These are public, physical contradictions, not a forecast of future
// funds: there is one shipment, and a required action cannot also be
// forbidden at an equal or lower threshold in that same territory.
@@ -24342,8 +24340,7 @@ function bindPublicDealTravel(g: Game, deal: PublicDeal) {
requireRule(!conflicts, 'This future travel term conflicts with an already accepted public travel agreement.');
}
if (due === g.turn) {
requireRule(travelTargetAvailable(g, player.id) && !g.truthtrance && !hasBribePromises(g, player.id) &&
!g.deals?.some(other => other.payment?.kind === 'deferredBribe' && other.paymentStatus === 'pending'),
requireRule(travelTargetAvailable(g, player.id) && !g.truthtrance && !hasBribePromises(g, player.id),
'This travel agreement needs a supported quiet Basic opportunity in its due turn.');
requireRule(travelTruthAnswers(g, player, claim).includes(term.answer ? 'yes' : 'no'),
'This travel agreement cannot be accepted at the current opportunity.');
@@ -38349,7 +38346,7 @@ function projectedTypedRevivalPromiseGuide(g: Game, player: string, kind: 'force
// The separate bid guide owns a jointly binding Yes declaration. Passing
// cannot evade it merely because Revival comes later in this turn.
const lot = g.phase === 3 && !ownPayment && !g.richeseAuction && !g.ixAuction ? bidOpportunity(g) : null;
if (lot && bidRequired(g.bidPromises ?? [], player, lot)) return null;
if (lot && (bidRequired(g.bidPromises ?? [], player, lot) || projectedPhaseBidGuide(g,player))) return null;
const grouped = liveRevivalExpressionPromises(g.revivalExpressionPromises ?? [], player, g.turn);
const named = liveLeaderRevivalPromises(g.leaderRevivalPromises ?? [], player, g.turn);
const promise = kind === 'expression' ? grouped[0] : grouped.length ? null : kind === 'leader' ? named[0]
@@ -43732,16 +43729,16 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
}
}
g.deals = deals.map((deal, position) => position === index ? next : deal);
if (current.status === 'offered' && next.status === 'active' && next.travel &&
publicDealTravelDueTurn(next) === g.turn) {
const traveler = getPlayer(g,publicDealTravelActor(next));
requireRule(publicDealCompletion(g,traveler),
'The traveler needs a funded completion for the travel and their payments due this turn.');
}
if (current.status === 'offered' && next.status === 'active' && next.payment?.kind === 'deferredBribe') {
const payer = getPlayer(g,next.payment.payer), dueTurn = next.payment.dueTurn;
requireRule(!(g.travelPromises ?? []).some(row => row.sourceDeal && row.player === payer.id &&
row.turn === dueTurn && !row.fulfilled && !row.released),
'The payer already has a public travel commitment in the payment’s due turn.');
requireRule(next.payment.dueTurn !== g.turn ||
!liveTravelPromises(g.travelPromises ?? [], payer.id, g.turn).some(row => !!row.sourceDeal),
'Finish the current public travel commitment before accepting a payment due this turn.');
requireRule(next.payment.dueTurn >= g.turn &&
(next.payment.dueTurn > g.turn || publicDealCompletion(g,payer)),
requireRule(dueTurn >= g.turn &&
(dueTurn > g.turn || publicDealCompletion(g,payer)),
'The agreed payment needs an unexpired deadline and, when due now, a legal funded completion.');
if (next.payment.dueTurn === g.turn &&
(g.phase === 2 && !g.charityOrder || g.phase === 8 || g.phase === 7 && bribesCloseBeforeNextMentat(g)) &&
+6 -8
View File
@@ -189,10 +189,10 @@ export function validatePublicDeals(value: unknown, players: readonly PublicDeal
const travel = parsePublicDealTravel(deal.travel);
requireDeal(travel.dueTurn === undefined || travel.dueTurn >= (deal.turn as number),
'Choose a travel turn no earlier than the offer turn.');
requireDeal(!Object.hasOwn(deal, 'paymentStatus') && (multi
? !!travel.actor && travel.actor !== deal.from && parties.includes(travel.actor) && (!payment || payment.kind === 'immediateBribe')
: !Object.hasOwn(travel, 'actor') && (!payment || payment.kind === 'immediateBribe')),
'Choose an invited traveler and an optional immediate bribe between participants.');
requireDeal(multi
? !!travel.actor && travel.actor !== deal.from && parties.includes(travel.actor)
: !Object.hasOwn(travel, 'actor'),
'Choose an invited traveler and an optional bribe between participants.');
// The actor's final acceptance is checked privately. An unfinished offer
// cannot already contain that vote, even after a decline or withdrawal.
if (multi && deal.status !== 'active' && deal.status !== 'released')
@@ -253,10 +253,8 @@ export function setPublicDealTravel(deal: PublicDeal, value: unknown, players: r
validatePublicDeals([deal], players);
requireDeal(deal.status === 'offered' && !Object.hasOwn(deal, 'travel') &&
!Object.hasOwn(deal, 'paymentStatus') && (deal.participants
? !!deal.acceptVotes && deal.acceptVotes.length === 1 && deal.acceptVotes[0] === deal.from &&
(!deal.payment || deal.payment.kind === 'immediateBribe')
: !Object.hasOwn(deal, 'acceptVotes') && (!deal.payment ||
deal.payment.kind === 'immediateBribe')),
? !!deal.acceptVotes && deal.acceptVotes.length === 1 && deal.acceptVotes[0] === deal.from
: !Object.hasOwn(deal, 'acceptVotes')),
'Only a fresh offer may add a travel term with a supported payment.');
notAllied(participants(players, publicDealParticipants(deal)));
const result = { ...deal, travel: parsePublicDealTravel(value) };
+1 -1
View File
@@ -304,7 +304,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'A deal may include one immediate spice payment between two participants. The last acceptance invokes the normal bribe action: the payer loses the gross amount immediately, Bureaucrat may divert two, and the recipient collects the remaining share at the next Mentat opening. Nothing is reserved before acceptance, and an unavailable payment leaves the offer open.',
'A deal may instead specify one exact payment due this turn or a later turn. After everyone accepts, the payer can use that deal’s Pay button early or by the deadline. Future payments do not reserve current funds; obligations due now must still be respected. Separate deals require separate payments. A compatible Truthtrance bribe answer can be satisfied by the same payment. Mutual release cancels an unpaid term; a paid amount is not refunded.',
'In a supported Basic classic table, two to six people can agree that one invited recipient will make or avoid one reserve shipment or ground move of at least a selected number of physical forces to a named territory in the current or a later turn. In a group offer the other recipients accept first and the named traveler accepts last. A current-turn term is checked on acceptance; a later-turn term is scheduled without reserving present forces or spice. The actual action fulfills a required term; a forbidden action cannot be taken. Compatible travel terms can share one action. A bounded due-turn search protects witnessed completions; when the travel turn closes without a witness, the game provisionally voids that term. Unsupported combinations remain in development.',
'Two-party or group travel can include one immediate payment between two participants. All parties accept, including the payer, and the traveler accepts last; only then does the payment settle. Final consent and payment are atomic, and current-turn travel must remain feasible after the payer spends. Deferred and multiple-payment travel remain unfinished.',
'Two-party or group travel can include one immediate or deferred payment between two participants. All parties accept, including the payer, and the traveler accepts last. An immediate payment settles with final consent; a deferred payment can be paid by its chosen deadline. When payment and travel are due this turn, acceptance checks that the payer can complete both with the available resources. Multiple-payment travel remains unfinished.',
'Players must honor legal deal terms; an impossible part is void. The game does not interpret or enforce free-text promises or determine impossibility. Free text alone pays no spice. Deals must not transfer cards, leaders, forces or faction advantages or contradict the rules.',
'Minimal AI follows supported Truthtrance ordinary-payment answers and their legal guides. AI deal negotiation and automatic enforcement of prose remain unfinished.',
],