Support multiple travel terms in public deals
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
13c337a24a
commit
d7d0f89625
13 files changed
+790
-51
No files matched your search
+55
-28
@@ -11,8 +11,9 @@ import { createFactionSwap, validateFactionSwap, answerFactionSwap, cancelFactio
|
||||
FactionSwapError, type FactionSwap } from './faction-swap';
|
||||
import { createPublicDeal, createMultipartyPublicDeal, validatePublicDeals, respondPublicDeal, withdrawPublicDeal,
|
||||
releasePublicDeal, markPublicDealPaid, voidPublicDealPayment, setPublicDealTravel, setPublicDealAdditionalPayments,
|
||||
setPublicDealAdditionalImmediatePayments, publicDealDeferredTerms, publicDealTravelActor, publicDealTravelDueTurn,
|
||||
PublicDealError, type PublicDeal, type PublicDealPayment, type PublicDealImmediatePayment } from './public-deals';
|
||||
setPublicDealAdditionalImmediatePayments, setPublicDealAdditionalTravel, publicDealTravelTerms,
|
||||
publicDealDeferredTerms, publicDealTravelActor,
|
||||
PublicDealError, type PublicDeal, type PublicDealTravel, type PublicDealPayment, type PublicDealImmediatePayment } from './public-deals';
|
||||
import { outstandingPublicDealPayments, pendingPublicDealPayments, publicDealPaymentTotal, publicDealPaymentOptionKey, PublicDealObligationError, type PendingPublicDealPayment } from './public-deal-obligations';
|
||||
import { CharityPromiseError, liveCharityPromises, charityPromiseAnswers, bindCharityPromise, guardCharityClaim, guardCharityReady, reconcileCharityPromises, type CharityPromise } from './charity-promises';
|
||||
import { victoryFinalTurn, continueVictoryCalendar, VictoryCalendarError } from './victory-calendar';
|
||||
@@ -6062,15 +6063,16 @@ function publicDealImmediateLegs(deal: PublicDeal): PublicDealImmediatePayment[]
|
||||
/** Bind receipts to immutable terms, not release votes or later deferred status. */
|
||||
function publicDealImmediateSignature(deal: PublicDeal): string {
|
||||
return JSON.stringify([deal.id,deal.turn,deal.from,deal.to,deal.participants,deal.terms,
|
||||
deal.payment,deal.additionalImmediatePayments,deal.additionalPayments?.map(term => term.payment),deal.travel]);
|
||||
deal.payment,deal.additionalImmediatePayments,deal.additionalPayments?.map(term => term.payment),deal.travel,
|
||||
...(deal.additionalTravel ? [deal.additionalTravel] : [])]);
|
||||
}
|
||||
function publicDealSettlementSignature(deal: PublicDeal, frame: NonNullable<Game['pendingPublicDealSettlement']>): string {
|
||||
return JSON.stringify([publicDealImmediateSignature(deal),frame.next,frame.initiator,frame.turn,frame.phase]);
|
||||
}
|
||||
/** Travel ledgers need another participant as the originating party. Older
|
||||
* recipient-travel deals continue to identify their original proposer. */
|
||||
function publicDealTravelAsker(deal: PublicDeal): string {
|
||||
return publicDealTravelActor(deal) === deal.from ? deal.to : deal.from;
|
||||
function publicDealTravelAsker(deal: PublicDeal, actor = publicDealTravelActor(deal)): string {
|
||||
return actor === deal.from ? deal.to : deal.from;
|
||||
}
|
||||
function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||
if (g.deals !== undefined) publicDealRule(() => validatePublicDeals(g.deals, g.players));
|
||||
@@ -6106,19 +6108,22 @@ function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||
const linked = (g.travelPromises ?? []).filter(row => row.sourceDeal !== undefined);
|
||||
for (const row of linked) {
|
||||
const deal = g.deals?.find(entry => entry.id === row.sourceDeal);
|
||||
const term = deal?.travel;
|
||||
const term = row.sourceDealIndex === undefined ? deal?.travel : deal?.additionalTravel?.[row.sourceDealIndex];
|
||||
const actor = term?.actor ?? deal?.to ?? '';
|
||||
requireRule(deal && term && ['active', 'released'].includes(deal.status) &&
|
||||
row.player === publicDealTravelActor(deal) && row.asker === publicDealTravelAsker(deal) && row.turn === publicDealTravelDueTurn(deal) &&
|
||||
row.player === actor && row.asker === publicDealTravelAsker(deal,actor) && row.turn === (term.dueTurn ?? deal.turn) &&
|
||||
row.answer === term.answer && row.mixed.kind === 'action' &&
|
||||
row.mixed.action.kind === term.kind && row.mixed.action.territory === term.territory &&
|
||||
row.mixed.action.minimum === term.minimum && row.mixed.action.sector === undefined &&
|
||||
(deal.status !== 'released' || row.fulfilled || row.released) &&
|
||||
(!row.releasedByDeal || deal.status === 'released') &&
|
||||
linked.filter(other => other.sourceDeal === deal.id).length === 1,
|
||||
linked.filter(other => other.sourceDeal === deal.id && other.sourceDealIndex === row.sourceDealIndex).length === 1,
|
||||
'The public travel deal lost its original accepted commitment.');
|
||||
}
|
||||
for (const deal of g.deals ?? []) if (deal.travel && ['active', 'released'].includes(deal.status))
|
||||
requireRule(linked.some(row => row.sourceDeal === deal.id), 'The accepted public travel deal is missing its commitment.');
|
||||
for (const {index} of publicDealTravelTerms(deal))
|
||||
requireRule(linked.some(row => row.sourceDeal === deal.id && row.sourceDealIndex === index),
|
||||
'The accepted public travel deal is missing its commitment.');
|
||||
}
|
||||
/** Exercise the actual native payments on detached states before consent.
|
||||
* Passing Bureaucrat can leave a later payment eligible, so prove both native
|
||||
@@ -24350,7 +24355,7 @@ function travelTargetAvailable(g: Game, actor: string): boolean {
|
||||
/** A later-turn deal has no resource witness when it is first accepted. */
|
||||
function isFutureDealTravel(g: Game, promise: TravelPromise): boolean {
|
||||
const deal = promise.sourceDeal ? g.deals?.find(entry => entry.id === promise.sourceDeal) : undefined;
|
||||
return !!deal?.travel && publicDealTravelDueTurn(deal) > deal.turn;
|
||||
return !!deal?.travel && promise.turn > deal.turn;
|
||||
}
|
||||
function appendTravelOrder(g: Game, kind: NonNullable<Game['travelPromiseOrder']>[number]['kind'], index: number) {
|
||||
g.travelPromiseOrder?.push({ kind, index });
|
||||
@@ -24440,9 +24445,9 @@ function bindTravelTruth(g: Game, p: Player, claim: TravelClaim, answer: boolean
|
||||
}
|
||||
/** A deal is a separately consented public source for the same physical
|
||||
* travel constraint, not a Truthtrance question or a fabricated card play. */
|
||||
function bindPublicDealTravel(g: Game, deal: PublicDeal) {
|
||||
const term = deal.travel, player = getPlayer(g, publicDealTravelActor(deal));
|
||||
const due = publicDealTravelDueTurn(deal);
|
||||
function bindPublicDealTravel(g: Game, deal: PublicDeal, term: PublicDealTravel, index?: number) {
|
||||
const player = getPlayer(g, term.actor ?? deal.to);
|
||||
const due = term.dueTurn ?? deal.turn;
|
||||
requireRule(term && due >= g.turn && !g.advanced && g.expansions.length === 0 && nativePromiseScopeSupported(g),
|
||||
'This travel agreement needs a supported Basic table and an unexpired turn.');
|
||||
const action = { kind: term.kind, territory: term.territory, minimum: term.minimum };
|
||||
@@ -24472,7 +24477,8 @@ function bindPublicDealTravel(g: Game, deal: PublicDeal) {
|
||||
}
|
||||
initializeTravelOrder(g);
|
||||
(g.travelPromises ??= []).push({ ...claim, event: crypto.randomUUID(), sourceDeal: deal.id,
|
||||
player: player.id, asker: publicDealTravelAsker(deal), answer: term.answer, compiled: { kind: 'action', action },
|
||||
...(index === undefined ? {} : {sourceDealIndex:index}),
|
||||
player: player.id, asker: publicDealTravelAsker(deal,player.id), answer: term.answer, compiled: { kind: 'action', action },
|
||||
shipment: { pending: due > g.turn || g.phase < 5 || shipmentAvailable(g, player), event: null },
|
||||
progress: [], movementClosed: false, fulfilled: false, released: false });
|
||||
appendTravelOrder(g, 'travel', g.travelPromises.length - 1);
|
||||
@@ -24566,19 +24572,35 @@ function projectedTravelPromises(g: Game, actor: string) {
|
||||
event: promise.event, player: promise.player, asker: promise.asker, turn: promise.turn, mixed: structuredClone(promise.mixed),
|
||||
answer: promise.answer, fulfilled: promise.fulfilled, released: promise.released,
|
||||
...(promise.sourceDeal ? {sourceDeal: promise.sourceDeal} : {}),
|
||||
...(promise.sourceDealIndex === undefined ? {} : {sourceDealIndex:promise.sourceDealIndex}),
|
||||
}));
|
||||
}
|
||||
function projectedDealTravelStatus(g: Game): Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> {
|
||||
const status: Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> = {};
|
||||
for (const deal of g.deals ?? []) {
|
||||
if (!deal.travel || !['active', 'released'].includes(deal.status)) continue;
|
||||
const receipt = g.travelPromises?.find(row => row.sourceDeal === deal.id);
|
||||
const receipt = g.travelPromises?.find(row => row.sourceDeal === deal.id && row.sourceDealIndex === undefined);
|
||||
if (!receipt) continue; // Integrity validation reports malformed saved records.
|
||||
status[deal.id] = receipt.fulfilled ? 'fulfilled' : receipt.releasedByDeal ? 'released'
|
||||
: receipt.released ? 'void' : receipt.turn > g.turn ? 'scheduled' : 'pending';
|
||||
}
|
||||
return status;
|
||||
}
|
||||
function projectedAdditionalDealTravelStatus(g: Game) {
|
||||
type Status = 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released';
|
||||
const status: Record<string, Status[]> = {};
|
||||
for (const deal of g.deals ?? []) {
|
||||
if (!deal.additionalTravel || !['active','released'].includes(deal.status)) continue;
|
||||
status[deal.id] = deal.additionalTravel.map((_term,index) => {
|
||||
const row = g.travelPromises?.find(promise => promise.sourceDeal === deal.id && promise.sourceDealIndex === index);
|
||||
// Integrity validation reports a missing receipt before this projection.
|
||||
if (!row) throw new RuleError('The accepted public travel deal is missing its commitment.');
|
||||
return row.fulfilled ? 'fulfilled' : row.releasedByDeal ? 'released' : row.released ? 'void'
|
||||
: row.turn > g.turn ? 'scheduled' : 'pending';
|
||||
});
|
||||
}
|
||||
return status;
|
||||
}
|
||||
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;
|
||||
@@ -43843,7 +43865,7 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
const deals = g.deals ?? [];
|
||||
if (action.type === 'dealOffer') {
|
||||
const keys = Object.keys(action);
|
||||
const supportedKeys = keys.every(key => ['type','terms','target','targets','payment','additionalPayments','additionalImmediatePayments','travel'].includes(key));
|
||||
const supportedKeys = keys.every(key => ['type','terms','target','targets','payment','additionalPayments','additionalImmediatePayments','travel','additionalTravel'].includes(key));
|
||||
const single = supportedKeys && !Object.hasOwn(action,'targets') && typeof action.target === 'string';
|
||||
const multiple = supportedKeys && !Object.hasOwn(action,'target') && Array.isArray(action.targets) &&
|
||||
action.targets.every(target => typeof target === 'string');
|
||||
@@ -43870,6 +43892,8 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
'Choose a travel agreement in a supported Basic table.');
|
||||
offer = publicDealRule(() => setPublicDealTravel(offer, action.travel, seats));
|
||||
}
|
||||
if (Object.hasOwn(action, 'additionalTravel'))
|
||||
offer = publicDealRule(() => setPublicDealAdditionalTravel(offer, action.additionalTravel, seats));
|
||||
requireRule(!deals.some(deal => deal.id === offer.id), 'This deal identifier is already in use.');
|
||||
g.deals = [...deals, offer];
|
||||
} else {
|
||||
@@ -43883,7 +43907,7 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
let next: PublicDeal;
|
||||
if (action.type === 'dealRespond') {
|
||||
requireRule(typeof action.accept === 'boolean', 'Choose whether to accept or decline.');
|
||||
requireRule(!action.accept || !current.travel || publicDealTravelDueTurn(current) >= g.turn,
|
||||
requireRule(!action.accept || publicDealTravelTerms(current).every(({travel}) => (travel.dueTurn ?? current.turn) >= g.turn),
|
||||
'The travel agreement’s due turn has passed; decline or withdraw it.');
|
||||
requireRule(!action.accept || publicDealDeferredTerms(current).every(term => term.payment.dueTurn >= g.turn),
|
||||
'The deferred payment deadline has passed; decline or withdraw this offer.');
|
||||
@@ -43893,23 +43917,25 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
next = publicDealRule(() => releasePublicDeal(current, g.players, id, action.agree as boolean));
|
||||
} else next = publicDealRule(() => withdrawPublicDeal(current, g.players, id));
|
||||
if (current.status === 'offered' && next.status === 'active' && next.travel) {
|
||||
requireRule(publicDealTravelActor(next) === next.from || id === publicDealTravelActor(next),
|
||||
requireRule(!!next.additionalTravel || publicDealTravelActor(next) === next.from || id === publicDealTravelActor(next),
|
||||
'The traveler must give the final consent.');
|
||||
bindPublicDealTravel(g, next);
|
||||
for (const {travel,index} of publicDealTravelTerms(next)) bindPublicDealTravel(g, next, travel, index);
|
||||
}
|
||||
if (current.status === 'active' && next.status === 'released' && next.travel) {
|
||||
const receipt = g.travelPromises?.find(row => row.sourceDeal === next.id);
|
||||
requireRule(receipt, 'The public travel deal lost its accepted commitment.');
|
||||
if (!receipt.fulfilled && !receipt.released) {
|
||||
receipt.released = true;
|
||||
receipt.releasedByDeal = true;
|
||||
for (const {index} of publicDealTravelTerms(next)) {
|
||||
const receipt = g.travelPromises?.find(row => row.sourceDeal === next.id && row.sourceDealIndex === index);
|
||||
requireRule(receipt, 'The public travel deal lost its accepted commitment.');
|
||||
if (!receipt.fulfilled && !receipt.released) {
|
||||
receipt.released = true;
|
||||
receipt.releasedByDeal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
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),
|
||||
if (current.status === 'offered' && next.status === 'active' && next.travel) {
|
||||
const actors = new Set(publicDealTravelTerms(next).filter(({travel}) => (travel.dueTurn ?? next.turn) === g.turn)
|
||||
.map(({travel}) => travel.actor ?? next.to));
|
||||
for (const actor of actors) requireRule(publicDealCompletion(g,getPlayer(g,actor)),
|
||||
'The traveler needs a funded completion for the travel and their payments due this turn.');
|
||||
}
|
||||
if (current.status === 'offered' && next.status === 'active') for (const term of publicDealDeferredTerms(next)) {
|
||||
@@ -49675,6 +49701,7 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
status: g.status,
|
||||
deals: g.deals ?? [],
|
||||
dealTravelStatus: projectedDealTravelStatus(g),
|
||||
dealAdditionalTravelStatus: projectedAdditionalDealTravelStatus(g),
|
||||
deferredDealPaymentOptions: projectedDeferredDealPaymentOptions(g,id),
|
||||
factionDraft: g.factionDraft ?? null,
|
||||
factionSwap: g.factionSwap ?? null,
|
||||
|
||||
+54
-3
@@ -24,6 +24,7 @@ export type PublicDealAdditionalPayment = {
|
||||
};
|
||||
export const MAX_ADDITIONAL_DEAL_PAYMENTS = 12;
|
||||
export const MAX_ADDITIONAL_IMMEDIATE_DEAL_PAYMENTS = 12;
|
||||
export const MAX_ADDITIONAL_DEAL_TRAVEL = 12;
|
||||
/** One participant commits to one native action (or its absence).
|
||||
* Old two-party records identify the recipient through `to`. */
|
||||
export type PublicDealTravel = {
|
||||
@@ -56,6 +57,9 @@ export type PublicDeal = {
|
||||
/** Immutable additional transfers, executed under final acceptance. */
|
||||
additionalImmediatePayments?: PublicDealImmediatePayment[];
|
||||
travel?: PublicDealTravel;
|
||||
/** Immutable additional actions; each actor is explicit and the array index
|
||||
* is its stable identity within the offer. */
|
||||
additionalTravel?: PublicDealTravel[];
|
||||
};
|
||||
|
||||
export type PublicDealSeat = { id: string; bot?: unknown; ally?: string | null; allies?: readonly string[] };
|
||||
@@ -123,6 +127,11 @@ export function publicDealTravelActor(deal: PublicDeal): string {
|
||||
export function publicDealTravelDueTurn(deal: PublicDeal): number {
|
||||
return deal.travel?.dueTurn ?? deal.turn;
|
||||
}
|
||||
/** Enumerate the original and indexed travel terms without rewriting saves. */
|
||||
export function publicDealTravelTerms(deal: PublicDeal): Array<{travel: PublicDealTravel; index?: number}> {
|
||||
return [...(deal.travel ? [{travel: deal.travel}] : []),
|
||||
...(deal.additionalTravel ?? []).map((travel,index) => ({travel,index}))];
|
||||
}
|
||||
function orderedSubset(votes: readonly string[], parties: readonly string[]): boolean {
|
||||
return new Set(votes).size === votes.length &&
|
||||
votes.every(vote => parties.includes(vote)) &&
|
||||
@@ -178,7 +187,7 @@ export function validatePublicDeals(value: unknown, players: readonly PublicDeal
|
||||
requireDeal(Array.isArray(value), 'The public deal ledger is malformed.');
|
||||
const ids = new Set<string>();
|
||||
for (const deal of value) {
|
||||
const keys = object(deal) ? Object.keys(deal).filter(key => key !== 'payment' && key !== 'paymentStatus' && key !== 'travel' && key !== 'additionalPayments' && key !== 'additionalImmediatePayments').sort().join(',') : '';
|
||||
const keys = object(deal) ? Object.keys(deal).filter(key => key !== 'payment' && key !== 'paymentStatus' && key !== 'travel' && key !== 'additionalTravel' && key !== 'additionalPayments' && key !== 'additionalImmediatePayments').sort().join(',') : '';
|
||||
const multi = keys === 'acceptVotes,from,id,participants,releaseVotes,status,terms,to,turn';
|
||||
requireDeal(object(deal) && (multi || keys === 'from,id,releaseVotes,status,terms,to,turn') &&
|
||||
id(deal.id) && id(deal.from) && id(deal.to) && deal.from !== deal.to &&
|
||||
@@ -218,10 +227,29 @@ export function validatePublicDeals(value: unknown, players: readonly PublicDeal
|
||||
'Choose a deal participant as traveler and an optional bribe between participants.');
|
||||
// An invited actor's final acceptance is checked privately. The proposer
|
||||
// has already consented by making the offer and remains in its votes.
|
||||
if (multi && travel.actor !== deal.from && deal.status !== 'active' && deal.status !== 'released')
|
||||
if (multi && !Object.hasOwn(deal, 'additionalTravel') && travel.actor !== deal.from && deal.status !== 'active' && deal.status !== 'released')
|
||||
requireDeal(!(deal.acceptVotes as string[]).includes(travel.actor!),
|
||||
'The committed traveler accepts after all other invited participants.');
|
||||
}
|
||||
if (Object.hasOwn(deal, 'additionalTravel')) {
|
||||
requireDeal(Object.hasOwn(deal, 'travel') && Array.isArray(deal.additionalTravel) &&
|
||||
deal.additionalTravel.length >= 1 && deal.additionalTravel.length <= MAX_ADDITIONAL_DEAL_TRAVEL,
|
||||
'Choose one original and between one and twelve additional travel terms.');
|
||||
const travelTerms = deal.additionalTravel.map(value => parsePublicDealTravel(value));
|
||||
requireDeal(travelTerms.every(term => !!term.actor && parties.includes(term.actor) &&
|
||||
(term.dueTurn === undefined || term.dueTurn >= (deal.turn as number))),
|
||||
'Choose a participant and unexpired turn for each additional travel term.');
|
||||
if (multi) {
|
||||
const original = parsePublicDealTravel(deal.travel);
|
||||
const travelers = new Set([original.actor!, ...travelTerms.map(term => term.actor!)]);
|
||||
const accepts = deal.acceptVotes as string[];
|
||||
// The proposer consented by offering. If another traveler has voted,
|
||||
// all invited non-travelers must already have consented.
|
||||
requireDeal(!accepts.some(seat => seat !== deal.from && travelers.has(seat)) ||
|
||||
parties.every(seat => seat === deal.from || travelers.has(seat) || accepts.includes(seat)),
|
||||
'Invited non-travelers must accept before committed travelers.');
|
||||
}
|
||||
}
|
||||
if (payment?.kind === 'deferredBribe') {
|
||||
const status = deal.paymentStatus;
|
||||
requireDeal(deal.status === 'active' ? status === 'pending' || status === 'paid' || status === 'void' :
|
||||
@@ -356,6 +384,24 @@ export function setPublicDealTravel(deal: PublicDeal, value: unknown, players: r
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Attach further explicit-actor travel terms to a fresh original offer. */
|
||||
export function setPublicDealAdditionalTravel(deal: PublicDeal, value: unknown, players: readonly PublicDealSeat[]): PublicDeal {
|
||||
validatePublicDeals([deal], players);
|
||||
requireDeal(deal.status === 'offered' && !!deal.travel && !Object.hasOwn(deal, 'additionalTravel') &&
|
||||
!Object.hasOwn(deal, 'paymentStatus') && (deal.participants
|
||||
? !!deal.acceptVotes && deal.acceptVotes.length === 1 && deal.acceptVotes[0] === deal.from
|
||||
: !Object.hasOwn(deal, 'acceptVotes')),
|
||||
'Only a fresh offer with an original travel term may add travel terms.');
|
||||
requireDeal(Array.isArray(value) && value.length >= 1 && value.length <= MAX_ADDITIONAL_DEAL_TRAVEL,
|
||||
'Choose between one and twelve additional travel terms.');
|
||||
const parties = publicDealParticipants(deal);
|
||||
notAllied(participants(players, parties));
|
||||
const additionalTravel = value.map(value => parsePublicDealTravel(value));
|
||||
const result = {...deal, additionalTravel};
|
||||
validatePublicDeals([result], players);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function respondPublicDeal(deal: PublicDeal, players: readonly PublicDealSeat[], actor: string, accept: boolean): PublicDeal {
|
||||
validatePublicDeals([deal], players);
|
||||
const parties = publicDealParticipants(deal);
|
||||
@@ -368,7 +414,12 @@ export function respondPublicDeal(deal: PublicDeal, players: readonly PublicDeal
|
||||
...(deal.payment?.kind === 'deferredBribe' ? { paymentStatus: 'pending' as const } : {}) };
|
||||
const alreadyAccepted = publicDealAcceptVotes(deal);
|
||||
requireDeal(!alreadyAccepted.includes(actor), 'This participant already accepted the offer.');
|
||||
if (deal.travel && actor === publicDealTravelActor(deal))
|
||||
if (deal.travel && deal.additionalTravel) {
|
||||
const travelers = new Set(publicDealTravelTerms(deal).map(({travel}) => travel.actor ?? deal.to));
|
||||
if (travelers.has(actor))
|
||||
requireDeal(parties.every(seat => seat === deal.from || travelers.has(seat) || alreadyAccepted.includes(seat)),
|
||||
'Invited non-travelers must accept before committed travelers.');
|
||||
} else if (deal.travel && actor === publicDealTravelActor(deal))
|
||||
requireDeal(parties.every(seat => seat === actor || alreadyAccepted.includes(seat)),
|
||||
'The committed traveler accepts after all other invited participants.');
|
||||
const accepts = parties.filter(seat => seat === actor || alreadyAccepted.includes(seat));
|
||||
|
||||
+2
-2
@@ -303,8 +303,8 @@ export const RULE_TOPICS: RuleTopic[] = [
|
||||
'In Public deals, propose written terms to one or more human seats. Every pair of participants must be nonallied when the offer is made and accepted, a provisional interpretation. Every recipient must accept; any recipient can decline, and the proposer can withdraw the outstanding offer. Any party may request release; all must agree. The record remains active until mutually released, even when players consider it fulfilled.',
|
||||
'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 also specify multiple exact deferred payments due this turn or later. After everyone accepts, each payer can use the matching Pay button early or by its deadline. Future payments do not reserve current funds; obligations due now must still be respected. Each term requires its own payment, even when the amounts match. A compatible Truthtrance bribe answer can be satisfied by the same payment. Mutual release cancels unpaid terms; paid amounts are 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 immediate and deferred payments between participants. All parties accept, including the payers, and the traveler accepts last. Immediate payments settle in order after final consent; a Bureaucrat decision can pause the sequence. Each 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.',
|
||||
'In a supported Basic classic table, two to six people can agree that participants will make or avoid reserve shipments or ground moves of at least a selected number of physical forces to named territories in the current or a later turn. The proposer consents by making the offer. In a group offer with one travel term, an invited traveler accepts last; with multiple terms, invitees without travel terms accept before the invited travelers, who may then accept in any order. Every invitee must accept before a term binds. Current-turn terms are checked on acceptance; later-turn terms are scheduled without reserving present forces or spice. Actual actions fulfill required terms; forbidden actions 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 immediate and deferred payments between participants. All parties accept, including the payers; the proposer consents when making the offer. Immediate payments settle in order after final consent; a Bureaucrat decision can pause the sequence. Each 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.',
|
||||
'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.',
|
||||
],
|
||||
|
||||
@@ -21,6 +21,8 @@ export type TravelPromise = TravelClaim & {
|
||||
event: string;
|
||||
/** Public-deal provenance; absent on original Truthtrance answers. */
|
||||
sourceDeal?: string;
|
||||
/** Zero-based additional term; absent for the original deal travel term. */
|
||||
sourceDealIndex?: number;
|
||||
/** A mutual deal release, distinct from an externally impossible term. */
|
||||
releasedByDeal?: true;
|
||||
player: string;
|
||||
@@ -378,6 +380,8 @@ export function validateTravelPromises(promises: readonly TravelPromise[], playe
|
||||
const satisfied = evaluate(compiled, promise);
|
||||
check(identifier(promise.event) && !events.has(promise.event) &&
|
||||
(promise.sourceDeal === undefined || identifier(promise.sourceDeal)) &&
|
||||
(promise.sourceDealIndex === undefined || !!promise.sourceDeal &&
|
||||
Number.isSafeInteger(promise.sourceDealIndex) && promise.sourceDealIndex >= 0 && promise.sourceDealIndex < 12) &&
|
||||
(promise.releasedByDeal === undefined || promise.releasedByDeal === true && !!promise.sourceDeal && promise.released) &&
|
||||
identifier(promise.player) && identifier(promise.asker) &&
|
||||
players.includes(promise.player) && players.includes(promise.asker) && promise.player !== promise.asker &&
|
||||
|
||||
Reference in new issue
Block a user