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
+786
-47
No files matched your search
+113
-15
@@ -14,8 +14,11 @@ type DeferredBribe = { kind: 'deferredBribe'; payer: string; recipient: string;
|
|||||||
type DealPayment = ImmediateBribe | DeferredBribe;
|
type DealPayment = ImmediateBribe | DeferredBribe;
|
||||||
type DealTravel = { kind: 'ship' | 'move'; territory: string; minimum: number; answer: boolean; actor?: string; dueTurn?: number };
|
type DealTravel = { kind: 'ship' | 'move'; territory: string; minimum: number; answer: boolean; actor?: string; dueTurn?: number };
|
||||||
type DealTravelStatus = 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released';
|
type DealTravelStatus = 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released';
|
||||||
type TravelDeal = Deal & { travel?: DealTravel };
|
type TravelDeal = Deal & { travel?: DealTravel; additionalTravel?: DealTravel[] };
|
||||||
type TravelProjection = GameView & { dealTravelStatus?: Record<string, DealTravelStatus> };
|
type TravelProjection = GameView & { dealTravelStatus?: Record<string, DealTravelStatus>;
|
||||||
|
dealAdditionalTravelStatus?: Record<string, DealTravelStatus[]> };
|
||||||
|
type AdditionalTravelDraft = {key:number; actor:string; kind:'ship'|'move'; territory:string;
|
||||||
|
minimum:string; answer:boolean; dueTurn:string};
|
||||||
type DeferredPaymentStatus = 'pending' | 'paid' | 'void' | 'released';
|
type DeferredPaymentStatus = 'pending' | 'paid' | 'void' | 'released';
|
||||||
type AdditionalPayment = { payment: DeferredBribe; paymentStatus?: DeferredPaymentStatus };
|
type AdditionalPayment = { payment: DeferredBribe; paymentStatus?: DeferredPaymentStatus };
|
||||||
type AdditionalPaymentDraft = { key: number; payer: string; recipient: string; amount: string; dueTurn: string };
|
type AdditionalPaymentDraft = { key: number; payer: string; recipient: string; amount: string; dueTurn: string };
|
||||||
@@ -31,6 +34,18 @@ function allied(game: GameView, a: GameView['players'][number], b: GameView['pla
|
|||||||
!!game.coalitionState && areCoalitionAllies(game.players, game.coalitionState, a.id, b.id);
|
!!game.coalitionState && areCoalitionAllies(game.players, game.coalitionState, a.id, b.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Additional travelers consent after non-traveling invitees, without making
|
||||||
|
* multiple travelers wait on each other. Single-term offers retain their
|
||||||
|
* existing final-traveler rule. */
|
||||||
|
function travelVoteWaiting(deal: Deal, actor: string, parties: string[], accepted: string[]): boolean {
|
||||||
|
const {travel,additionalTravel = []} = deal as TravelDeal;
|
||||||
|
if (!travel || parties.length <= 2 || actor === deal.from) return false;
|
||||||
|
if (!additionalTravel.length) return publicDealTravelActor(deal) === actor &&
|
||||||
|
parties.some(id => id !== actor && !accepted.includes(id));
|
||||||
|
const travelers = new Set([publicDealTravelActor(deal), ...additionalTravel.map(term => term.actor)]);
|
||||||
|
return travelers.has(actor) && parties.some(id => id !== deal.from && !travelers.has(id) && !accepted.includes(id));
|
||||||
|
}
|
||||||
|
|
||||||
/** Requests are local to the active seat; an owed payment is as important to
|
/** Requests are local to the active seat; an owed payment is as important to
|
||||||
* surface as a pending invitation or a request to release an agreement. */
|
* surface as a pending invitation or a request to release an agreement. */
|
||||||
export function publicDealRequests(game: GameView): string[][] {
|
export function publicDealRequests(game: GameView): string[][] {
|
||||||
@@ -40,10 +55,11 @@ export function publicDealRequests(game: GameView): string[][] {
|
|||||||
const parties = publicDealParticipants(deal), accepted = publicDealAcceptVotes(deal);
|
const parties = publicDealParticipants(deal), accepted = publicDealAcceptVotes(deal);
|
||||||
const participant = parties.includes(game.me);
|
const participant = parties.includes(game.me);
|
||||||
const travel = (deal as TravelDeal).travel;
|
const travel = (deal as TravelDeal).travel;
|
||||||
const waitingForOtherVotes = !!travel && parties.length > 2 && publicDealTravelActor(deal) === game.me &&
|
const extraTravel = (deal as TravelDeal).additionalTravel ?? [];
|
||||||
parties.some(id => id !== game.me && !accepted.includes(id));
|
const waitingForOtherVotes = travelVoteWaiting(deal,game.me,parties,accepted);
|
||||||
if (deal.status === 'offered' && participant && deal.from !== game.me && !accepted.includes(game.me)) {
|
if (deal.status === 'offered' && participant && deal.from !== game.me && !accepted.includes(game.me)) {
|
||||||
const groupTraveler = !!travel && parties.length > 2 && publicDealTravelActor(deal) === game.me;
|
const groupTraveler = !!travel && parties.length > 2 &&
|
||||||
|
(publicDealTravelActor(deal) === game.me || extraTravel.some(term => term.actor === game.me));
|
||||||
requests.push(groupTraveler ? ['offer', deal.id, waitingForOtherVotes ? 'waiting' : 'ready'] : ['offer', deal.id]);
|
requests.push(groupTraveler ? ['offer', deal.id, waitingForOtherVotes ? 'waiting' : 'ready'] : ['offer', deal.id]);
|
||||||
}
|
}
|
||||||
if (deal.status === 'active' && participant && !deal.releaseVotes.includes(game.me) && deal.releaseVotes.length > 0)
|
if (deal.status === 'active' && participant && !deal.releaseVotes.includes(game.me) && deal.releaseVotes.length > 0)
|
||||||
@@ -60,12 +76,16 @@ export function publicDealRequests(game: GameView): string[][] {
|
|||||||
if (deal.status === 'active' && travel && publicDealTravelActor(deal) === game.me &&
|
if (deal.status === 'active' && travel && publicDealTravelActor(deal) === game.me &&
|
||||||
(game as TravelProjection).dealTravelStatus?.[deal.id] === 'pending')
|
(game as TravelProjection).dealTravelStatus?.[deal.id] === 'pending')
|
||||||
requests.push(['travel', deal.id]);
|
requests.push(['travel', deal.id]);
|
||||||
|
if (deal.status === 'active') extraTravel.forEach((term,index) => {
|
||||||
|
if (term.actor === game.me && (game as TravelProjection).dealAdditionalTravelStatus?.[deal.id]?.[index] === 'pending')
|
||||||
|
requests.push(['travel',deal.id,String(index)]);
|
||||||
|
});
|
||||||
return requests;
|
return requests;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Keep the legacy single-recipient wire packet when only one seat is chosen. */
|
/** Keep the legacy single-recipient wire packet when only one seat is chosen. */
|
||||||
export function publicDealOfferAction(targets: readonly string[], terms: string, payment?: DealPayment, proposer?: string, currentTurn?: number, travel?: DealTravel, additionalPayments?: readonly DeferredBribe[], additionalImmediatePayments?: readonly ImmediateBribe[]): Action | null {
|
export function publicDealOfferAction(targets: readonly string[], terms: string, payment?: DealPayment, proposer?: string, currentTurn?: number, travel?: DealTravel, additionalPayments?: readonly DeferredBribe[], additionalImmediatePayments?: readonly ImmediateBribe[], additionalTravel?: readonly DealTravel[]): Action | null {
|
||||||
const text = terms.trim();
|
const text = terms.trim();
|
||||||
if (!targets.length || targets.length > 5 || new Set(targets).size !== targets.length || !text || text.length > 500) return null;
|
if (!targets.length || targets.length > 5 || new Set(targets).size !== targets.length || !text || text.length > 500) return null;
|
||||||
if (payment && (!proposer || (payment.kind !== 'immediateBribe' && payment.kind !== 'deferredBribe') || payment.payer === payment.recipient ||
|
if (payment && (!proposer || (payment.kind !== 'immediateBribe' && payment.kind !== 'deferredBribe') || payment.payer === payment.recipient ||
|
||||||
@@ -95,6 +115,14 @@ export function publicDealOfferAction(targets: readonly string[], terms: string,
|
|||||||
!['ship', 'move'].includes(travel.kind) || !TERRITORIES.some(territory => territory.id === travel.territory) ||
|
!['ship', 'move'].includes(travel.kind) || !TERRITORIES.some(territory => territory.id === travel.territory) ||
|
||||||
!Number.isSafeInteger(travel.minimum) || travel.minimum < 1 || travel.minimum > 20 ||
|
!Number.isSafeInteger(travel.minimum) || travel.minimum < 1 || travel.minimum > 20 ||
|
||||||
typeof travel.answer !== 'boolean')) return null;
|
typeof travel.answer !== 'boolean')) return null;
|
||||||
|
if (additionalTravel?.length && (!travel || !proposer || additionalTravel.length > 12 || additionalTravel.some(term => {
|
||||||
|
const keys = Object.keys(term).filter(key => key !== 'dueTurn').sort().join(',');
|
||||||
|
return keys !== 'actor,answer,kind,minimum,territory' || !term.actor || ![proposer,...targets].includes(term.actor) ||
|
||||||
|
!['ship','move'].includes(term.kind) || !TERRITORIES.some(territory => territory.id === term.territory) ||
|
||||||
|
!Number.isSafeInteger(term.minimum) || term.minimum < 1 || term.minimum > 20 || typeof term.answer !== 'boolean' ||
|
||||||
|
Object.hasOwn(term,'dueTurn') && (!Number.isSafeInteger(term.dueTurn) || term.dueTurn! < 1 ||
|
||||||
|
currentTurn !== undefined && term.dueTurn! < currentTurn);
|
||||||
|
}))) return null;
|
||||||
const offeredPayment = payment ? { payment } : {};
|
const offeredPayment = payment ? { payment } : {};
|
||||||
const offeredAdditional = additionalPayments?.length
|
const offeredAdditional = additionalPayments?.length
|
||||||
? { additionalPayments: additionalPayments.map(term => ({kind:term.kind, payer:term.payer,
|
? { additionalPayments: additionalPayments.map(term => ({kind:term.kind, payer:term.payer,
|
||||||
@@ -105,9 +133,14 @@ export function publicDealOfferAction(targets: readonly string[], terms: string,
|
|||||||
const normalizedTravel = travel ? {...travel} : undefined;
|
const normalizedTravel = travel ? {...travel} : undefined;
|
||||||
if (normalizedTravel && travelDeadline === currentTurn) delete normalizedTravel.dueTurn;
|
if (normalizedTravel && travelDeadline === currentTurn) delete normalizedTravel.dueTurn;
|
||||||
const offeredTravel = normalizedTravel ? { travel: normalizedTravel } : {};
|
const offeredTravel = normalizedTravel ? { travel: normalizedTravel } : {};
|
||||||
|
const offeredExtraTravel = additionalTravel?.length ? { additionalTravel: additionalTravel.map(term => {
|
||||||
|
const result = {...term};
|
||||||
|
if (result.dueTurn === currentTurn) delete result.dueTurn;
|
||||||
|
return result;
|
||||||
|
}) } : {};
|
||||||
return targets.length === 1
|
return targets.length === 1
|
||||||
? { type: 'dealOffer', target: targets[0], terms: text, ...offeredPayment, ...offeredAdditional, ...offeredImmediate, ...offeredTravel }
|
? { type: 'dealOffer', target: targets[0], terms: text, ...offeredPayment, ...offeredAdditional, ...offeredImmediate, ...offeredTravel, ...offeredExtraTravel }
|
||||||
: { type: 'dealOffer', targets: [...targets], terms: text, ...offeredPayment, ...offeredAdditional, ...offeredImmediate, ...offeredTravel };
|
: { type: 'dealOffer', targets: [...targets], terms: text, ...offeredPayment, ...offeredAdditional, ...offeredImmediate, ...offeredTravel, ...offeredExtraTravel };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The whole table can read an offer and its history; only its parties act. */
|
/** The whole table can read an offer and its history; only its parties act. */
|
||||||
@@ -138,14 +171,15 @@ export function PublicDealList({ game, act, disabled }: {
|
|||||||
const additional = (deal as unknown as { additionalPayments?: AdditionalPayment[] }).additionalPayments ?? [];
|
const additional = (deal as unknown as { additionalPayments?: AdditionalPayment[] }).additionalPayments ?? [];
|
||||||
const additionalImmediate = (deal as unknown as { additionalImmediatePayments?: ImmediateBribe[] }).additionalImmediatePayments ?? [];
|
const additionalImmediate = (deal as unknown as { additionalImmediatePayments?: ImmediateBribe[] }).additionalImmediatePayments ?? [];
|
||||||
const travel = (deal as TravelDeal).travel;
|
const travel = (deal as TravelDeal).travel;
|
||||||
|
const extraTravel = (deal as TravelDeal).additionalTravel ?? [];
|
||||||
const travelActor = travel ? publicDealTravelActor(deal) : undefined;
|
const travelActor = travel ? publicDealTravelActor(deal) : undefined;
|
||||||
const travelStatus = (game as TravelProjection).dealTravelStatus?.[deal.id];
|
const travelStatus = (game as TravelProjection).dealTravelStatus?.[deal.id];
|
||||||
const travelTurn = travel ? publicDealTravelDueTurn(deal) : undefined;
|
const travelTurn = travel ? publicDealTravelDueTurn(deal) : undefined;
|
||||||
const travelExpired = travelTurn !== undefined && game.turn > travelTurn;
|
const travelExpired = travelTurn !== undefined && game.turn > travelTurn ||
|
||||||
|
extraTravel.some(term => game.turn > (term.dueTurn ?? deal.turn));
|
||||||
const travelDestination = travel && TERRITORIES.find(territory => territory.id === travel.territory)?.name;
|
const travelDestination = travel && TERRITORIES.find(territory => territory.id === travel.territory)?.name;
|
||||||
const finalAcceptance = recipient && !accepted.includes(game.me) && accepted.length === participants.length - 1;
|
const finalAcceptance = recipient && !accepted.includes(game.me) && accepted.length === participants.length - 1;
|
||||||
const travelActorWaiting = !!travel && participants.length > 2 && game.me === travelActor &&
|
const travelActorWaiting = travelVoteWaiting(deal,game.me,participants,accepted);
|
||||||
participants.some(participant => participant !== travelActor && !accepted.includes(participant));
|
|
||||||
const paymentBlocked = finalAcceptance && (payment?.kind === 'immediateBribe' && payment.payer === game.me ||
|
const paymentBlocked = finalAcceptance && (payment?.kind === 'immediateBribe' && payment.payer === game.me ||
|
||||||
additionalImmediate.some(term => term.payer === game.me)) ? game.bribeOptions?.blocked : null;
|
additionalImmediate.some(term => term.payer === game.me)) ? game.bribeOptions?.blocked : null;
|
||||||
const paymentExpired = payment?.kind === 'deferredBribe' && game.turn > payment.dueTurn ||
|
const paymentExpired = payment?.kind === 'deferredBribe' && game.turn > payment.dueTurn ||
|
||||||
@@ -175,7 +209,15 @@ export function PublicDealList({ game, act, disabled }: {
|
|||||||
})}
|
})}
|
||||||
{travel && <p><strong>{travelTurn === deal.turn ? 'Current-turn travel term:' : 'Travel term:'}</strong> {name(travelActor!)} {deal.status === 'offered' || deal.status === 'declined' || deal.status === 'withdrawn' ? 'would' : 'agrees to'} {travel.answer ? 'make' : 'avoid'} {travel.kind === 'ship' ? 'a reserve shipment' : 'a ground movement'} of at least {travel.minimum} physical forces in one action to {travelDestination ?? travel.territory} during turn {travelTurn}. {travelStatus ? `Travel status: ${travelStatus}.` : deal.status === 'offered' ? 'The term becomes binding on final acceptance.' : deal.status === 'declined' || deal.status === 'withdrawn' ? 'The term did not become binding.' : 'Travel status is unavailable.'}</p>}
|
{travel && <p><strong>{travelTurn === deal.turn ? 'Current-turn travel term:' : 'Travel term:'}</strong> {name(travelActor!)} {deal.status === 'offered' || deal.status === 'declined' || deal.status === 'withdrawn' ? 'would' : 'agrees to'} {travel.answer ? 'make' : 'avoid'} {travel.kind === 'ship' ? 'a reserve shipment' : 'a ground movement'} of at least {travel.minimum} physical forces in one action to {travelDestination ?? travel.territory} during turn {travelTurn}. {travelStatus ? `Travel status: ${travelStatus}.` : deal.status === 'offered' ? 'The term becomes binding on final acceptance.' : deal.status === 'declined' || deal.status === 'withdrawn' ? 'The term did not become binding.' : 'Travel status is unavailable.'}</p>}
|
||||||
{travel && travelTurn !== undefined && travelTurn > deal.turn && <p>Before turn {travelTurn}, this term reserves no forces or spice. Its status and legal options update during that turn.</p>}
|
{travel && travelTurn !== undefined && travelTurn > deal.turn && <p>Before turn {travelTurn}, this term reserves no forces or spice. Its status and legal options update during that turn.</p>}
|
||||||
{travel && participants.length > 2 && deal.status === 'offered' && (travelActor === deal.from
|
{extraTravel.map((term,index) => {
|
||||||
|
const turn = term.dueTurn ?? deal.turn;
|
||||||
|
const destination = TERRITORIES.find(territory => territory.id === term.territory)?.name ?? term.territory;
|
||||||
|
const status = (game as TravelProjection).dealAdditionalTravelStatus?.[deal.id]?.[index];
|
||||||
|
return <p key={`travel-${index}`}><strong>Additional travel {index + 1}:</strong> {name(term.actor!)} {deal.status === 'offered' || deal.status === 'declined' || deal.status === 'withdrawn' ? 'would' : 'agrees to'} {term.answer ? 'make' : 'avoid'} {term.kind === 'ship' ? 'a reserve shipment' : 'a ground movement'} of at least {term.minimum} physical forces in one action to {destination} during turn {turn}. {status ? `Travel status: ${status}.` : deal.status === 'offered' ? 'The term becomes binding on final acceptance.' : deal.status === 'declined' || deal.status === 'withdrawn' ? 'The term did not become binding.' : 'Travel status is unavailable.'}{turn > deal.turn ? ` Before turn ${turn}, this term reserves no forces or spice.` : ''}</p>;
|
||||||
|
})}
|
||||||
|
{travel && extraTravel.length > 0 && participants.length > 2 && deal.status === 'offered' &&
|
||||||
|
<p>Invited participants without a travel term accept first. Invited travelers may then accept in any order. The proposer consents by making the offer; anyone invited may decline at any time.</p>}
|
||||||
|
{travel && extraTravel.length === 0 && participants.length > 2 && deal.status === 'offered' && (travelActor === deal.from
|
||||||
? <p>The proposer already consented to their own travel term by making this offer. All invited participants must accept; anyone invited may decline at any time.</p>
|
? <p>The proposer already consented to their own travel term by making this offer. All invited participants must accept; anyone invited may decline at any time.</p>
|
||||||
: <p>{name(travelActor!)} must accept last, after the other recipients. Anyone invited may decline at any time.</p>)}
|
: <p>{name(travelActor!)} must accept last, after the other recipients. Anyone invited may decline at any time.</p>)}
|
||||||
{deal.status === 'offered' && <p>
|
{deal.status === 'offered' && <p>
|
||||||
@@ -230,6 +272,8 @@ export function PublicDeals({ game, act, busy }: {
|
|||||||
const nextAdditionalKey = useRef(0);
|
const nextAdditionalKey = useRef(0);
|
||||||
const [additionalImmediateDrafts, setAdditionalImmediateDrafts] = useState<AdditionalImmediateDraft[]>([]);
|
const [additionalImmediateDrafts, setAdditionalImmediateDrafts] = useState<AdditionalImmediateDraft[]>([]);
|
||||||
const nextAdditionalImmediateKey = useRef(0);
|
const nextAdditionalImmediateKey = useRef(0);
|
||||||
|
const [additionalTravelDrafts, setAdditionalTravelDrafts] = useState<AdditionalTravelDraft[]>([]);
|
||||||
|
const nextAdditionalTravelKey = useRef(0);
|
||||||
const [deadlineDraft, setDeadlineDraft] = useState(() => ({ value: String(game.turn), turn: game.turn }));
|
const [deadlineDraft, setDeadlineDraft] = useState(() => ({ value: String(game.turn), turn: game.turn }));
|
||||||
const [travelDeadlineDraft, setTravelDeadlineDraft] = useState(() => ({ value: String(game.turn), turn: game.turn }));
|
const [travelDeadlineDraft, setTravelDeadlineDraft] = useState(() => ({ value: String(game.turn), turn: game.turn }));
|
||||||
const previousDeadline = Number(deadlineDraft.value);
|
const previousDeadline = Number(deadlineDraft.value);
|
||||||
@@ -280,8 +324,12 @@ export function PublicDeals({ game, act, busy }: {
|
|||||||
minimum:Number(travelMinimum), answer:travelAnswer,
|
minimum:Number(travelMinimum), answer:travelAnswer,
|
||||||
...(selected.length > 1 ? {actor:travelActor} : travelActor === me?.id ? {actor:travelActor} : {}),
|
...(selected.length > 1 ? {actor:travelActor} : travelActor === me?.id ? {actor:travelActor} : {}),
|
||||||
...(travelTurn > game.turn ? {dueTurn:travelTurn} : {})} : undefined;
|
...(travelTurn > game.turn ? {dueTurn:travelTurn} : {})} : undefined;
|
||||||
|
const additionalTravel: DealTravel[] = additionalTravelDrafts.map(draft => ({
|
||||||
|
actor:draft.actor, kind:draft.kind, territory:draft.territory, minimum:Number(draft.minimum),
|
||||||
|
answer:draft.answer, dueTurn:Number(draft.dueTurn),
|
||||||
|
}));
|
||||||
const offer = legalSelection && paymentValid && (!includeTravel || travelDueValid)
|
const offer = legalSelection && paymentValid && (!includeTravel || travelDueValid)
|
||||||
? publicDealOfferAction(selected, terms, payment, me?.id, game.turn, travel, additionalPayments, additionalImmediatePayments) : null;
|
? publicDealOfferAction(selected, terms, payment, me?.id, game.turn, travel, additionalPayments, additionalImmediatePayments, additionalTravel) : null;
|
||||||
const disabled = busy || !!game.roomControl?.paused || !!game.roomControl?.closed || !!me?.autopilot;
|
const disabled = busy || !!game.roomControl?.paused || !!game.roomControl?.closed || !!me?.autopilot;
|
||||||
const mayOffer = game.status === 'playing' && me && !me.bot;
|
const mayOffer = game.status === 'playing' && me && !me.bot;
|
||||||
return <details ref={panel} className="notice public-deals-panel">
|
return <details ref={panel} className="notice public-deals-panel">
|
||||||
@@ -431,13 +479,13 @@ export function PublicDeals({ game, act, busy }: {
|
|||||||
{additionalDrafts.length > 0 && <p className="fine">Each additional payment has its own deadline and pay control. The recipient collects its share at the next Mentat opening.</p>}
|
{additionalDrafts.length > 0 && <p className="fine">Each additional payment has its own deadline and pay control. The recipient collects its share at the next Mentat opening.</p>}
|
||||||
<label className="checkbox-row">
|
<label className="checkbox-row">
|
||||||
<input type="checkbox" checked={includeTravel} disabled={disabled || !includeTravel && selected.length === 0}
|
<input type="checkbox" checked={includeTravel} disabled={disabled || !includeTravel && selected.length === 0}
|
||||||
onChange={event => setIncludeTravel(event.target.checked)} />
|
onChange={event => { setIncludeTravel(event.target.checked); if (!event.target.checked) setAdditionalTravelDrafts([]); }} />
|
||||||
Include a travel term
|
Include a travel term
|
||||||
</label>
|
</label>
|
||||||
{!includeTravel && selected.length === 0 && <p className="fine">Select at least one human recipient to add a travel term.</p>}
|
{!includeTravel && selected.length === 0 && <p className="fine">Select at least one human recipient to add a travel term.</p>}
|
||||||
{includeTravel && <fieldset>
|
{includeTravel && <fieldset>
|
||||||
<legend>Travel term</legend>
|
<legend>Travel term</legend>
|
||||||
<p className="fine">This term concerns one physical action during the selected turn. Choose a participant to commit. An invited traveler accepts last after all other recipients; a proposer consents to their own travel by making the offer. Written terms remain player-managed.</p>
|
<p className="fine">This term concerns one physical action during the selected turn. Choose a participant to commit. {additionalTravelDrafts.length ? 'Invited participants without a travel term accept first, then invited travelers may accept in any order.' : 'An invited traveler accepts last after all other recipients.'} A proposer consents to their own travel by making the offer. Written terms remain player-managed.</p>
|
||||||
<p className="fine">A travel term may include an immediate payment or a payment due by the end of a selected turn. Payment and travel may have different participants and turns. The payment recipient collects their share at the next Mentat opening and can use it after collection. All invited parties must accept.</p>
|
<p className="fine">A travel term may include an immediate payment or a payment due by the end of a selected turn. Payment and travel may have different participants and turns. The payment recipient collects their share at the next Mentat opening and can use it after collection. All invited parties must accept.</p>
|
||||||
{selected.length > 1 && <label>Committed traveler
|
{selected.length > 1 && <label>Committed traveler
|
||||||
<select value={parties.some(player => player.id === travelActor) ? travelActor : ''} disabled={disabled}
|
<select value={parties.some(player => player.id === travelActor) ? travelActor : ''} disabled={disabled}
|
||||||
@@ -482,6 +530,56 @@ export function PublicDeals({ game, act, busy }: {
|
|||||||
</label>
|
</label>
|
||||||
{!travelDueValid && <p role="alert">Choose a whole travel turn no earlier than turn {game.turn}.</p>}
|
{!travelDueValid && <p role="alert">Choose a whole travel turn no earlier than turn {game.turn}.</p>}
|
||||||
</fieldset>}
|
</fieldset>}
|
||||||
|
{includeTravel && additionalTravelDrafts.map((draft,index) => {
|
||||||
|
const valid = parties.some(player => player.id === draft.actor) &&
|
||||||
|
TERRITORIES.some(territory => territory.id === draft.territory) && draft.minimum.trim() !== '' &&
|
||||||
|
Number.isSafeInteger(Number(draft.minimum)) && Number(draft.minimum) >= 1 && Number(draft.minimum) <= 20 &&
|
||||||
|
draft.dueTurn.trim() !== '' && Number.isSafeInteger(Number(draft.dueTurn)) && Number(draft.dueTurn) >= game.turn;
|
||||||
|
const update = (change:Partial<AdditionalTravelDraft>) => setAdditionalTravelDrafts(current =>
|
||||||
|
current.map(row => row.key === draft.key ? {...row,...change} : row));
|
||||||
|
return <fieldset key={draft.key}>
|
||||||
|
<legend>Additional travel {index + 1}</legend>
|
||||||
|
<label>Committed traveler
|
||||||
|
<select value={parties.some(player => player.id === draft.actor) ? draft.actor : ''} disabled={disabled}
|
||||||
|
onChange={event => update({actor:event.target.value})}>
|
||||||
|
<option value="">Choose a participant</option>
|
||||||
|
{parties.map(player => <option key={player.id} value={player.id}>{player.name} · {faction(player.faction).name}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Travel action
|
||||||
|
<select value={draft.kind} disabled={disabled} onChange={event => update({kind:event.target.value === 'move' ? 'move' : 'ship'})}>
|
||||||
|
<option value="ship">Reserve shipment</option><option value="move">Ground movement</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Commitment
|
||||||
|
<select value={draft.answer ? 'require' : 'avoid'} disabled={disabled} onChange={event => update({answer:event.target.value === 'require'})}>
|
||||||
|
<option value="require">Make this action</option><option value="avoid">Avoid this action</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Destination territory
|
||||||
|
<select value={draft.territory} disabled={disabled} onChange={event => update({territory:event.target.value})}>
|
||||||
|
<option value="">Choose a territory</option>
|
||||||
|
{TERRITORIES.map(territory => <option key={territory.id} value={territory.id}>{territory.name}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Minimum physical forces in one action
|
||||||
|
<input type="number" inputMode="numeric" min={1} max={20} step={1} value={draft.minimum} disabled={disabled}
|
||||||
|
onChange={event => update({minimum:event.target.value})} />
|
||||||
|
</label>
|
||||||
|
<label>Travel during turn
|
||||||
|
<input type="number" inputMode="numeric" min={game.turn} step={1} value={draft.dueTurn} disabled={disabled}
|
||||||
|
required aria-invalid={!valid} onChange={event => update({dueTurn:event.target.value})} />
|
||||||
|
</label>
|
||||||
|
{!valid && <p>Choose a participant, destination, force count and current or future turn.</p>}
|
||||||
|
<Button type="button" variant="outline" disabled={disabled}
|
||||||
|
onClick={() => setAdditionalTravelDrafts(current => current.filter(row => row.key !== draft.key))}>Remove additional travel {index + 1}</Button>
|
||||||
|
</fieldset>;
|
||||||
|
})}
|
||||||
|
{includeTravel && <Button type="button" variant="outline" disabled={disabled || additionalTravelDrafts.length >= 12}
|
||||||
|
onClick={() => {
|
||||||
|
const key = nextAdditionalTravelKey.current++;
|
||||||
|
setAdditionalTravelDrafts(current => [...current,{key,actor:'',kind:'ship',territory:'',minimum:'1',answer:true,dueTurn:String(game.turn)}]);
|
||||||
|
}}>Add travel term</Button>}
|
||||||
<label>Public deal terms
|
<label>Public deal terms
|
||||||
<textarea rows={3} maxLength={500} value={terms} onChange={event => setTerms(event.target.value)} disabled={disabled}
|
<textarea rows={3} maxLength={500} value={terms} onChange={event => setTerms(event.target.value)} disabled={disabled}
|
||||||
placeholder="Describe the agreement for the table" />
|
placeholder="Describe the agreement for the table" />
|
||||||
|
|||||||
@@ -108,20 +108,26 @@ export function TravelPromises(props: TravelProps) {
|
|||||||
return <section className="notice space-y-3" aria-label={own.some(promise => promise.sourceDeal)
|
return <section className="notice space-y-3" aria-label={own.some(promise => promise.sourceDeal)
|
||||||
? 'Your shipment and movement commitments' : 'Your Truthtrance shipment and movement promises'} id="travel-promise-guidance">
|
? 'Your shipment and movement commitments' : 'Your Truthtrance shipment and movement promises'} id="travel-promise-guidance">
|
||||||
<h3>Your shipment and movement promises</h3>
|
<h3>Your shipment and movement promises</h3>
|
||||||
<ul>{own.map(promise => <li key={promise.event}>
|
<ul>{own.map(promise => {
|
||||||
|
const index = (promise as typeof promise & {sourceDealIndex?:number}).sourceDealIndex;
|
||||||
|
const extraStatus = (game as typeof game & {dealAdditionalTravelStatus?:Record<string, string[]>}).dealAdditionalTravelStatus;
|
||||||
|
const dealStatus = promise.sourceDeal ? index === undefined ? game.dealTravelStatus[promise.sourceDeal]
|
||||||
|
: extraStatus?.[promise.sourceDeal]?.[index] : undefined;
|
||||||
|
return <li key={promise.event}>
|
||||||
Turn {promise.turn}: {promise.sourceDeal ? `Public deal: agreed ${promise.answer ? 'Yes' : 'No'} to` : `You answered ${promise.answer ? 'Yes' : 'No'} to`} {truthQuestionText({ kind: 'travel', target: promise.player,
|
Turn {promise.turn}: {promise.sourceDeal ? `Public deal: agreed ${promise.answer ? 'Yes' : 'No'} to` : `You answered ${promise.answer ? 'Yes' : 'No'} to`} {truthQuestionText({ kind: 'travel', target: promise.player,
|
||||||
turn: promise.turn, mixed: promise.mixed }, id => id === CHEAP_HERO_TRAITOR ? 'Cheap Hero / Heroine'
|
turn: promise.turn, mixed: promise.mixed }, id => id === CHEAP_HERO_TRAITOR ? 'Cheap Hero / Heroine'
|
||||||
: game.allLeaders.find(leader => leader.id === id)?.name ?? id,
|
: game.allLeaders.find(leader => leader.id === id)?.name ?? id,
|
||||||
id => game.combatLocations.find(location => location.id === id)?.name ?? id,
|
id => game.combatLocations.find(location => location.id === id)?.name ?? id,
|
||||||
id => game.players.find(player => player.id === id)?.name ?? id)}.
|
id => game.players.find(player => player.id === id)?.name ?? id)}.
|
||||||
{promise.released ? promise.sourceDeal
|
{promise.released ? promise.sourceDeal
|
||||||
? game.dealTravelStatus[promise.sourceDeal] === 'void'
|
? dealStatus === 'void'
|
||||||
? ' Void: this agreement is no longer possible.' : ' Released: this whole commitment is no longer binding.'
|
? ' Void: this agreement is no longer possible.' : ' Released: this whole commitment is no longer binding.'
|
||||||
: ' Released: this whole commitment is no longer possible.'
|
: ' Released: this whole commitment is no longer possible.'
|
||||||
: promise.fulfilled ? ' Fulfilled: this whole commitment is complete.'
|
: promise.fulfilled ? ' Fulfilled: this whole commitment is complete.'
|
||||||
: promise.sourceDeal ? ' This commitment is binding until your Movement turn ends this round.'
|
: promise.sourceDeal ? ' This commitment is binding until your Movement turn ends this round.'
|
||||||
: ' This whole answer is binding until your Movement turn ends this round.'}
|
: ' This whole answer is binding until your Movement turn ends this round.'}
|
||||||
</li>)}</ul>
|
</li>;
|
||||||
|
})}</ul>
|
||||||
{own.some(promise => !promise.sourceDeal) && <p>AND requires every condition; OR requires at least one. No negates the whole expression, not each condition separately.
|
{own.some(promise => !promise.sourceDeal) && <p>AND requires every condition; OR requires at least one. No negates the whole expression, not each condition separately.
|
||||||
Legal alternatives remain available; no fixed branch is selected for you.
|
Legal alternatives remain available; no fixed branch is selected for you.
|
||||||
Current facts are evaluated at the answer. They create no promise to keep cards, spice or forces afterward.
|
Current facts are evaluated at the answer. They create no promise to keep cards, spice or forces afterward.
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ open mode gates.
|
|||||||
|
|
||||||
## Current checkpoint and work
|
## Current checkpoint and work
|
||||||
|
|
||||||
|
**Multiple travel terms in a public deal — 16 November. Prototyped / Partial.**
|
||||||
|
Additional terms name participants, carry independent due turns and receive
|
||||||
|
indexed commitments, with connected controls and individual status. Current
|
||||||
|
terms and due payments use the same physical resources; existing single-travel
|
||||||
|
records, settlement signatures and consent behavior retain their meaning.
|
||||||
|
Seventeen related offline files pass 134 cases; one authenticated HTTP case,
|
||||||
|
type checking, lint and the production build pass. Advanced, expansions, full
|
||||||
|
games and deployed acceptance remain open. [Scope](PUBLIC_DEALS.md#multiple-travel-terms--16-november-2026).
|
||||||
|
|
||||||
**Proposer travel in public deals — 16 November. Prototyped / Partial.**
|
**Proposer travel in public deals — 16 November. Prototyped / Partial.**
|
||||||
The proposer may commit their own shipment or movement in a two-party or group
|
The proposer may commit their own shipment or movement in a two-party or group
|
||||||
offer; the offer itself is their consent, and all invitees must agree before
|
offer; the offer itself is their consent, and all invitees must agree before
|
||||||
|
|||||||
@@ -1,5 +1,29 @@
|
|||||||
# Public deal records
|
# Public deal records
|
||||||
|
|
||||||
|
## Multiple travel terms — 16 November 2026
|
||||||
|
|
||||||
|
**Prototyped / Partial.** A supported Basic classic deal may include up to
|
||||||
|
twelve additional shipment or ground-movement terms, each with its own named
|
||||||
|
participant, action and current or future turn. In a group offer, invited
|
||||||
|
participants without travel terms consent first; invited travelers can then
|
||||||
|
consent in any order. The proposer consents by making the offer. All parties
|
||||||
|
must agree before any term binds or immediate payment settles. Single-travel
|
||||||
|
deals keep their existing consent order and saved representation.
|
||||||
|
|
||||||
|
Current-turn terms use native travel checks and share the traveler's real
|
||||||
|
forces and spice with their due payments. Conflicting future terms are rejected;
|
||||||
|
future travel reserves no current resources. Each additional term has its own
|
||||||
|
status and commitment, and mutual release cancels every unfinished term.
|
||||||
|
The term limit and online consent order are provisional implementation choices.
|
||||||
|
|
||||||
|
[Model](../tests/public-deals-additional-travel-model.test.ts),
|
||||||
|
[gameplay](../tests/public-deals-multiple-travel.test.ts),
|
||||||
|
[receipt and status](../tests/public-deals-multiple-travel-integrity.test.ts),
|
||||||
|
[controls](../tests/public-deals-multiple-travel-controls.test.tsx) and an
|
||||||
|
[authenticated room case](../tests/public-deals-multiple-travel-http.test.ts)
|
||||||
|
cover the connected prototype. Wider rules combinations, complete games and
|
||||||
|
deployed acceptance remain open.
|
||||||
|
|
||||||
## Proposer travel — 16 November 2026
|
## Proposer travel — 16 November 2026
|
||||||
|
|
||||||
**Prototyped / Partial.** A proposer can include their own shipment or ground
|
**Prototyped / Partial.** A proposer can include their own shipment or ground
|
||||||
|
|||||||
+51
-24
@@ -11,8 +11,9 @@ import { createFactionSwap, validateFactionSwap, answerFactionSwap, cancelFactio
|
|||||||
FactionSwapError, type FactionSwap } from './faction-swap';
|
FactionSwapError, type FactionSwap } from './faction-swap';
|
||||||
import { createPublicDeal, createMultipartyPublicDeal, validatePublicDeals, respondPublicDeal, withdrawPublicDeal,
|
import { createPublicDeal, createMultipartyPublicDeal, validatePublicDeals, respondPublicDeal, withdrawPublicDeal,
|
||||||
releasePublicDeal, markPublicDealPaid, voidPublicDealPayment, setPublicDealTravel, setPublicDealAdditionalPayments,
|
releasePublicDeal, markPublicDealPaid, voidPublicDealPayment, setPublicDealTravel, setPublicDealAdditionalPayments,
|
||||||
setPublicDealAdditionalImmediatePayments, publicDealDeferredTerms, publicDealTravelActor, publicDealTravelDueTurn,
|
setPublicDealAdditionalImmediatePayments, setPublicDealAdditionalTravel, publicDealTravelTerms,
|
||||||
PublicDealError, type PublicDeal, type PublicDealPayment, type PublicDealImmediatePayment } from './public-deals';
|
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 { 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 { CharityPromiseError, liveCharityPromises, charityPromiseAnswers, bindCharityPromise, guardCharityClaim, guardCharityReady, reconcileCharityPromises, type CharityPromise } from './charity-promises';
|
||||||
import { victoryFinalTurn, continueVictoryCalendar, VictoryCalendarError } from './victory-calendar';
|
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. */
|
/** Bind receipts to immutable terms, not release votes or later deferred status. */
|
||||||
function publicDealImmediateSignature(deal: PublicDeal): string {
|
function publicDealImmediateSignature(deal: PublicDeal): string {
|
||||||
return JSON.stringify([deal.id,deal.turn,deal.from,deal.to,deal.participants,deal.terms,
|
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 {
|
function publicDealSettlementSignature(deal: PublicDeal, frame: NonNullable<Game['pendingPublicDealSettlement']>): string {
|
||||||
return JSON.stringify([publicDealImmediateSignature(deal),frame.next,frame.initiator,frame.turn,frame.phase]);
|
return JSON.stringify([publicDealImmediateSignature(deal),frame.next,frame.initiator,frame.turn,frame.phase]);
|
||||||
}
|
}
|
||||||
/** Travel ledgers need another participant as the originating party. Older
|
/** Travel ledgers need another participant as the originating party. Older
|
||||||
* recipient-travel deals continue to identify their original proposer. */
|
* recipient-travel deals continue to identify their original proposer. */
|
||||||
function publicDealTravelAsker(deal: PublicDeal): string {
|
function publicDealTravelAsker(deal: PublicDeal, actor = publicDealTravelActor(deal)): string {
|
||||||
return publicDealTravelActor(deal) === deal.from ? deal.to : deal.from;
|
return actor === deal.from ? deal.to : deal.from;
|
||||||
}
|
}
|
||||||
function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||||
if (g.deals !== undefined) publicDealRule(() => validatePublicDeals(g.deals, g.players));
|
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);
|
const linked = (g.travelPromises ?? []).filter(row => row.sourceDeal !== undefined);
|
||||||
for (const row of linked) {
|
for (const row of linked) {
|
||||||
const deal = g.deals?.find(entry => entry.id === row.sourceDeal);
|
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) &&
|
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.answer === term.answer && row.mixed.kind === 'action' &&
|
||||||
row.mixed.action.kind === term.kind && row.mixed.action.territory === term.territory &&
|
row.mixed.action.kind === term.kind && row.mixed.action.territory === term.territory &&
|
||||||
row.mixed.action.minimum === term.minimum && row.mixed.action.sector === undefined &&
|
row.mixed.action.minimum === term.minimum && row.mixed.action.sector === undefined &&
|
||||||
(deal.status !== 'released' || row.fulfilled || row.released) &&
|
(deal.status !== 'released' || row.fulfilled || row.released) &&
|
||||||
(!row.releasedByDeal || deal.status === '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.');
|
'The public travel deal lost its original accepted commitment.');
|
||||||
}
|
}
|
||||||
for (const deal of g.deals ?? []) if (deal.travel && ['active', 'released'].includes(deal.status))
|
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.
|
/** Exercise the actual native payments on detached states before consent.
|
||||||
* Passing Bureaucrat can leave a later payment eligible, so prove both native
|
* 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. */
|
/** A later-turn deal has no resource witness when it is first accepted. */
|
||||||
function isFutureDealTravel(g: Game, promise: TravelPromise): boolean {
|
function isFutureDealTravel(g: Game, promise: TravelPromise): boolean {
|
||||||
const deal = promise.sourceDeal ? g.deals?.find(entry => entry.id === promise.sourceDeal) : undefined;
|
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) {
|
function appendTravelOrder(g: Game, kind: NonNullable<Game['travelPromiseOrder']>[number]['kind'], index: number) {
|
||||||
g.travelPromiseOrder?.push({ kind, index });
|
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
|
/** A deal is a separately consented public source for the same physical
|
||||||
* travel constraint, not a Truthtrance question or a fabricated card play. */
|
* travel constraint, not a Truthtrance question or a fabricated card play. */
|
||||||
function bindPublicDealTravel(g: Game, deal: PublicDeal) {
|
function bindPublicDealTravel(g: Game, deal: PublicDeal, term: PublicDealTravel, index?: number) {
|
||||||
const term = deal.travel, player = getPlayer(g, publicDealTravelActor(deal));
|
const player = getPlayer(g, term.actor ?? deal.to);
|
||||||
const due = publicDealTravelDueTurn(deal);
|
const due = term.dueTurn ?? deal.turn;
|
||||||
requireRule(term && due >= g.turn && !g.advanced && g.expansions.length === 0 && nativePromiseScopeSupported(g),
|
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.');
|
'This travel agreement needs a supported Basic table and an unexpired turn.');
|
||||||
const action = { kind: term.kind, territory: term.territory, minimum: term.minimum };
|
const action = { kind: term.kind, territory: term.territory, minimum: term.minimum };
|
||||||
@@ -24472,7 +24477,8 @@ function bindPublicDealTravel(g: Game, deal: PublicDeal) {
|
|||||||
}
|
}
|
||||||
initializeTravelOrder(g);
|
initializeTravelOrder(g);
|
||||||
(g.travelPromises ??= []).push({ ...claim, event: crypto.randomUUID(), sourceDeal: deal.id,
|
(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 },
|
shipment: { pending: due > g.turn || g.phase < 5 || shipmentAvailable(g, player), event: null },
|
||||||
progress: [], movementClosed: false, fulfilled: false, released: false });
|
progress: [], movementClosed: false, fulfilled: false, released: false });
|
||||||
appendTravelOrder(g, 'travel', g.travelPromises.length - 1);
|
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),
|
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,
|
answer: promise.answer, fulfilled: promise.fulfilled, released: promise.released,
|
||||||
...(promise.sourceDeal ? {sourceDeal: promise.sourceDeal} : {}),
|
...(promise.sourceDeal ? {sourceDeal: promise.sourceDeal} : {}),
|
||||||
|
...(promise.sourceDealIndex === undefined ? {} : {sourceDealIndex:promise.sourceDealIndex}),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function projectedDealTravelStatus(g: Game): Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> {
|
function projectedDealTravelStatus(g: Game): Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> {
|
||||||
const status: Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> = {};
|
const status: Record<string, 'scheduled' | 'pending' | 'fulfilled' | 'void' | 'released'> = {};
|
||||||
for (const deal of g.deals ?? []) {
|
for (const deal of g.deals ?? []) {
|
||||||
if (!deal.travel || !['active', 'released'].includes(deal.status)) continue;
|
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.
|
if (!receipt) continue; // Integrity validation reports malformed saved records.
|
||||||
status[deal.id] = receipt.fulfilled ? 'fulfilled' : receipt.releasedByDeal ? 'released'
|
status[deal.id] = receipt.fulfilled ? 'fulfilled' : receipt.releasedByDeal ? 'released'
|
||||||
: receipt.released ? 'void' : receipt.turn > g.turn ? 'scheduled' : 'pending';
|
: receipt.released ? 'void' : receipt.turn > g.turn ? 'scheduled' : 'pending';
|
||||||
}
|
}
|
||||||
return status;
|
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 {
|
function projectedTravelGuide(g: Game, player: Player): { event: string; action: Action } | null {
|
||||||
const promise = liveTravelPromises(g.travelPromises ?? [], player.id, g.turn)[0];
|
const promise = liveTravelPromises(g.travelPromises ?? [], player.id, g.turn)[0];
|
||||||
const lot = promise && g.phase === 3 && !g.decision ? bidOpportunity(g) : null;
|
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 ?? [];
|
const deals = g.deals ?? [];
|
||||||
if (action.type === 'dealOffer') {
|
if (action.type === 'dealOffer') {
|
||||||
const keys = Object.keys(action);
|
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 single = supportedKeys && !Object.hasOwn(action,'targets') && typeof action.target === 'string';
|
||||||
const multiple = supportedKeys && !Object.hasOwn(action,'target') && Array.isArray(action.targets) &&
|
const multiple = supportedKeys && !Object.hasOwn(action,'target') && Array.isArray(action.targets) &&
|
||||||
action.targets.every(target => typeof target === 'string');
|
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.');
|
'Choose a travel agreement in a supported Basic table.');
|
||||||
offer = publicDealRule(() => setPublicDealTravel(offer, action.travel, seats));
|
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.');
|
requireRule(!deals.some(deal => deal.id === offer.id), 'This deal identifier is already in use.');
|
||||||
g.deals = [...deals, offer];
|
g.deals = [...deals, offer];
|
||||||
} else {
|
} else {
|
||||||
@@ -43883,7 +43907,7 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
|||||||
let next: PublicDeal;
|
let next: PublicDeal;
|
||||||
if (action.type === 'dealRespond') {
|
if (action.type === 'dealRespond') {
|
||||||
requireRule(typeof action.accept === 'boolean', 'Choose whether to accept or decline.');
|
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.');
|
'The travel agreement’s due turn has passed; decline or withdraw it.');
|
||||||
requireRule(!action.accept || publicDealDeferredTerms(current).every(term => term.payment.dueTurn >= g.turn),
|
requireRule(!action.accept || publicDealDeferredTerms(current).every(term => term.payment.dueTurn >= g.turn),
|
||||||
'The deferred payment deadline has passed; decline or withdraw this offer.');
|
'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));
|
next = publicDealRule(() => releasePublicDeal(current, g.players, id, action.agree as boolean));
|
||||||
} else next = publicDealRule(() => withdrawPublicDeal(current, g.players, id));
|
} else next = publicDealRule(() => withdrawPublicDeal(current, g.players, id));
|
||||||
if (current.status === 'offered' && next.status === 'active' && next.travel) {
|
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.');
|
'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) {
|
if (current.status === 'active' && next.status === 'released' && next.travel) {
|
||||||
const receipt = g.travelPromises?.find(row => row.sourceDeal === next.id);
|
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.');
|
requireRule(receipt, 'The public travel deal lost its accepted commitment.');
|
||||||
if (!receipt.fulfilled && !receipt.released) {
|
if (!receipt.fulfilled && !receipt.released) {
|
||||||
receipt.released = true;
|
receipt.released = true;
|
||||||
receipt.releasedByDeal = true;
|
receipt.releasedByDeal = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
g.deals = deals.map((deal, position) => position === index ? next : deal);
|
g.deals = deals.map((deal, position) => position === index ? next : deal);
|
||||||
if (current.status === 'offered' && next.status === 'active' && next.travel &&
|
if (current.status === 'offered' && next.status === 'active' && next.travel) {
|
||||||
publicDealTravelDueTurn(next) === g.turn) {
|
const actors = new Set(publicDealTravelTerms(next).filter(({travel}) => (travel.dueTurn ?? next.turn) === g.turn)
|
||||||
const traveler = getPlayer(g,publicDealTravelActor(next));
|
.map(({travel}) => travel.actor ?? next.to));
|
||||||
requireRule(publicDealCompletion(g,traveler),
|
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.');
|
'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)) {
|
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,
|
status: g.status,
|
||||||
deals: g.deals ?? [],
|
deals: g.deals ?? [],
|
||||||
dealTravelStatus: projectedDealTravelStatus(g),
|
dealTravelStatus: projectedDealTravelStatus(g),
|
||||||
|
dealAdditionalTravelStatus: projectedAdditionalDealTravelStatus(g),
|
||||||
deferredDealPaymentOptions: projectedDeferredDealPaymentOptions(g,id),
|
deferredDealPaymentOptions: projectedDeferredDealPaymentOptions(g,id),
|
||||||
factionDraft: g.factionDraft ?? null,
|
factionDraft: g.factionDraft ?? null,
|
||||||
factionSwap: g.factionSwap ?? 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_DEAL_PAYMENTS = 12;
|
||||||
export const MAX_ADDITIONAL_IMMEDIATE_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).
|
/** One participant commits to one native action (or its absence).
|
||||||
* Old two-party records identify the recipient through `to`. */
|
* Old two-party records identify the recipient through `to`. */
|
||||||
export type PublicDealTravel = {
|
export type PublicDealTravel = {
|
||||||
@@ -56,6 +57,9 @@ export type PublicDeal = {
|
|||||||
/** Immutable additional transfers, executed under final acceptance. */
|
/** Immutable additional transfers, executed under final acceptance. */
|
||||||
additionalImmediatePayments?: PublicDealImmediatePayment[];
|
additionalImmediatePayments?: PublicDealImmediatePayment[];
|
||||||
travel?: PublicDealTravel;
|
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[] };
|
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 {
|
export function publicDealTravelDueTurn(deal: PublicDeal): number {
|
||||||
return deal.travel?.dueTurn ?? deal.turn;
|
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 {
|
function orderedSubset(votes: readonly string[], parties: readonly string[]): boolean {
|
||||||
return new Set(votes).size === votes.length &&
|
return new Set(votes).size === votes.length &&
|
||||||
votes.every(vote => parties.includes(vote)) &&
|
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.');
|
requireDeal(Array.isArray(value), 'The public deal ledger is malformed.');
|
||||||
const ids = new Set<string>();
|
const ids = new Set<string>();
|
||||||
for (const deal of value) {
|
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';
|
const multi = keys === 'acceptVotes,from,id,participants,releaseVotes,status,terms,to,turn';
|
||||||
requireDeal(object(deal) && (multi || keys === 'from,id,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 &&
|
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.');
|
'Choose a deal participant as traveler and an optional bribe between participants.');
|
||||||
// An invited actor's final acceptance is checked privately. The proposer
|
// An invited actor's final acceptance is checked privately. The proposer
|
||||||
// has already consented by making the offer and remains in its votes.
|
// 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!),
|
requireDeal(!(deal.acceptVotes as string[]).includes(travel.actor!),
|
||||||
'The committed traveler accepts after all other invited participants.');
|
'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') {
|
if (payment?.kind === 'deferredBribe') {
|
||||||
const status = deal.paymentStatus;
|
const status = deal.paymentStatus;
|
||||||
requireDeal(deal.status === 'active' ? status === 'pending' || status === 'paid' || status === 'void' :
|
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;
|
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 {
|
export function respondPublicDeal(deal: PublicDeal, players: readonly PublicDealSeat[], actor: string, accept: boolean): PublicDeal {
|
||||||
validatePublicDeals([deal], players);
|
validatePublicDeals([deal], players);
|
||||||
const parties = publicDealParticipants(deal);
|
const parties = publicDealParticipants(deal);
|
||||||
@@ -368,7 +414,12 @@ export function respondPublicDeal(deal: PublicDeal, players: readonly PublicDeal
|
|||||||
...(deal.payment?.kind === 'deferredBribe' ? { paymentStatus: 'pending' as const } : {}) };
|
...(deal.payment?.kind === 'deferredBribe' ? { paymentStatus: 'pending' as const } : {}) };
|
||||||
const alreadyAccepted = publicDealAcceptVotes(deal);
|
const alreadyAccepted = publicDealAcceptVotes(deal);
|
||||||
requireDeal(!alreadyAccepted.includes(actor), 'This participant already accepted the offer.');
|
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)),
|
requireDeal(parties.every(seat => seat === actor || alreadyAccepted.includes(seat)),
|
||||||
'The committed traveler accepts after all other invited participants.');
|
'The committed traveler accepts after all other invited participants.');
|
||||||
const accepts = parties.filter(seat => seat === actor || alreadyAccepted.includes(seat));
|
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.',
|
'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 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.',
|
'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.',
|
'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, 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.',
|
'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.',
|
'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.',
|
'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;
|
event: string;
|
||||||
/** Public-deal provenance; absent on original Truthtrance answers. */
|
/** Public-deal provenance; absent on original Truthtrance answers. */
|
||||||
sourceDeal?: string;
|
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. */
|
/** A mutual deal release, distinct from an externally impossible term. */
|
||||||
releasedByDeal?: true;
|
releasedByDeal?: true;
|
||||||
player: string;
|
player: string;
|
||||||
@@ -378,6 +380,8 @@ export function validateTravelPromises(promises: readonly TravelPromise[], playe
|
|||||||
const satisfied = evaluate(compiled, promise);
|
const satisfied = evaluate(compiled, promise);
|
||||||
check(identifier(promise.event) && !events.has(promise.event) &&
|
check(identifier(promise.event) && !events.has(promise.event) &&
|
||||||
(promise.sourceDeal === undefined || identifier(promise.sourceDeal)) &&
|
(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) &&
|
(promise.releasedByDeal === undefined || promise.releasedByDeal === true && !!promise.sourceDeal && promise.released) &&
|
||||||
identifier(promise.player) && identifier(promise.asker) &&
|
identifier(promise.player) && identifier(promise.asker) &&
|
||||||
players.includes(promise.player) && players.includes(promise.asker) && promise.player !== promise.asker &&
|
players.includes(promise.player) && players.includes(promise.asker) && promise.player !== promise.asker &&
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import {
|
||||||
|
createMultipartyPublicDeal, createPublicDeal, publicDealTravelTerms, PublicDealError,
|
||||||
|
releasePublicDeal, respondPublicDeal, setPublicDealAdditionalTravel, setPublicDealTravel,
|
||||||
|
validatePublicDeals, withdrawPublicDeal, type PublicDeal, type PublicDealSeat,
|
||||||
|
} from '../game/public-deals';
|
||||||
|
|
||||||
|
const seats: PublicDealSeat[] = ['a','b','c','d'].map(id => ({id}));
|
||||||
|
const original = {kind:'ship', territory:'polar_sink', minimum:1, answer:true} as const;
|
||||||
|
const extra = {kind:'move', territory:'imperial_basin', minimum:1, answer:true, actor:'a'} as const;
|
||||||
|
const pair = () => setPublicDealTravel(createPublicDeal(seats, 'a', 'b', 'Travel together', 3, 'pair'), original, seats);
|
||||||
|
const group = () => setPublicDealTravel(createMultipartyPublicDeal(seats, 'a', ['b','c','d'], 'Travel together', 3, 'group'),
|
||||||
|
{...original, actor:'b'}, seats);
|
||||||
|
|
||||||
|
void test('legacy, explicit and repeated additional travel terms retain stable indexes through the deal lifecycle', () => {
|
||||||
|
const source = pair();
|
||||||
|
assert.deepEqual(publicDealTravelTerms(source), [{travel:original}]);
|
||||||
|
const values = [extra, {...extra}, {...original, actor:'b', dueTurn:5}];
|
||||||
|
const offered = setPublicDealAdditionalTravel(source, values, seats);
|
||||||
|
assert.equal(source.additionalTravel, undefined);
|
||||||
|
assert.deepEqual(publicDealTravelTerms(offered), [
|
||||||
|
{travel:original}, {travel:extra,index:0}, {travel:extra,index:1},
|
||||||
|
{travel:{...original,actor:'b',dueTurn:5},index:2},
|
||||||
|
]);
|
||||||
|
assert.notEqual(offered.additionalTravel![0], values[0]);
|
||||||
|
const active = respondPublicDeal(offered, seats, 'b', true);
|
||||||
|
const released = releasePublicDeal(releasePublicDeal(active, seats, 'a', true), seats, 'b', true);
|
||||||
|
for (const saved of [offered,active,released]) {
|
||||||
|
const restored = JSON.parse(JSON.stringify(saved)) as PublicDeal;
|
||||||
|
validatePublicDeals([restored], seats);
|
||||||
|
assert.deepEqual(publicDealTravelTerms(restored), publicDealTravelTerms(offered));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('additional terms require a fresh original travel term, explicit participants and valid deadlines', () => {
|
||||||
|
const source = pair();
|
||||||
|
const withoutTravel = createPublicDeal(seats, 'a', 'b', 'Travel', 3, 'without');
|
||||||
|
assert.throws(() => setPublicDealAdditionalTravel(withoutTravel, [extra], seats), PublicDealError);
|
||||||
|
for (const bad of [null, undefined, [], Array(13).fill(extra), [original],
|
||||||
|
[{...extra,actor:'c'}], [{...extra,actor:''}], [{...extra,dueTurn:2}],
|
||||||
|
[{...extra,dueTurn:undefined}], [{...extra,sector:9}]])
|
||||||
|
assert.throws(() => setPublicDealAdditionalTravel(source, bad, seats), PublicDealError);
|
||||||
|
const twelve = setPublicDealAdditionalTravel(source, Array(12).fill(extra), seats);
|
||||||
|
assert.equal(publicDealTravelTerms(twelve).length, 13);
|
||||||
|
assert.throws(() => setPublicDealAdditionalTravel(twelve, [extra], seats), PublicDealError);
|
||||||
|
assert.throws(() => setPublicDealAdditionalTravel(respondPublicDeal(source,seats,'b',true), [extra], seats), PublicDealError);
|
||||||
|
for (const malformed of [
|
||||||
|
{...source, additionalTravel:[]}, {...source, additionalTravel:[original]},
|
||||||
|
{...withoutTravel, additionalTravel:[extra]}, {...source, additionalTravel:undefined},
|
||||||
|
]) assert.throws(() => validatePublicDeals([malformed], seats), PublicDealError);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('group non-travelers accept before any invited traveler, then travelers accept in either order', () => {
|
||||||
|
const offered = setPublicDealAdditionalTravel(group(), [{...extra,actor:'c'}], seats);
|
||||||
|
for (const actor of ['b','c'])
|
||||||
|
assert.throws(() => respondPublicDeal(offered,seats,actor,true), PublicDealError);
|
||||||
|
const beforeTravelers = respondPublicDeal(offered,seats,'d',true);
|
||||||
|
for (const [first,last] of [['b','c'],['c','b']]) {
|
||||||
|
const partial = respondPublicDeal(beforeTravelers,seats,first,true);
|
||||||
|
assert.equal(partial.status,'offered');
|
||||||
|
validatePublicDeals([JSON.parse(JSON.stringify(partial))],seats);
|
||||||
|
const active = respondPublicDeal(partial,seats,last,true);
|
||||||
|
assert.equal(active.status,'active');
|
||||||
|
assert.deepEqual(active.acceptVotes,['a','b','c','d']);
|
||||||
|
validatePublicDeals([active],seats);
|
||||||
|
}
|
||||||
|
assert.throws(() => validatePublicDeals([{...offered,acceptVotes:['a','b']}],seats), PublicDealError);
|
||||||
|
assert.equal(respondPublicDeal(offered,seats,'b',false).status,'declined');
|
||||||
|
assert.equal(withdrawPublicDeal(offered,seats,'a').status,'withdrawn');
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('proposer consent is implicit and repeated traveler identities need only one vote', () => {
|
||||||
|
const self = setPublicDealTravel(createMultipartyPublicDeal(seats,'a',['b','c','d'],'I travel',3,'self'),
|
||||||
|
{...original,actor:'a'},seats);
|
||||||
|
const offered = setPublicDealAdditionalTravel(self, [extra,{...extra,actor:'b'},{...extra,actor:'b'}], seats);
|
||||||
|
assert.throws(() => respondPublicDeal(offered,seats,'b',true), PublicDealError);
|
||||||
|
const otherVotes = respondPublicDeal(respondPublicDeal(offered,seats,'c',true),seats,'d',true);
|
||||||
|
const active = respondPublicDeal(otherVotes,seats,'b',true);
|
||||||
|
assert.equal(active.status,'active');
|
||||||
|
assert.equal(publicDealTravelTerms(active).length,4);
|
||||||
|
});
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { runInNewContext } from 'node:vm';
|
||||||
|
import { createElement, isValidElement, type ReactElement, type ReactNode } from 'react';
|
||||||
|
import { renderToStaticMarkup } from 'react-dom/server';
|
||||||
|
import * as jsxRuntime from 'react/jsx-runtime';
|
||||||
|
import ts from 'typescript';
|
||||||
|
import * as board from '../game/board';
|
||||||
|
import * as catalog from '../game/catalog';
|
||||||
|
import * as coalitionAlliance from '../game/coalition-alliance';
|
||||||
|
import * as publicDeals from '../game/public-deals';
|
||||||
|
import { PublicDealList, PublicDeals, publicDealOfferAction, publicDealRequests } from '../components/public-deals';
|
||||||
|
import { TravelPromises } from '../components/travel-promises';
|
||||||
|
import type { Action, GameView } from '../game/engine';
|
||||||
|
|
||||||
|
type Element = ReactElement<{children?:ReactNode; [key:string]:unknown}>;
|
||||||
|
function elements(node:ReactNode):Element[] {
|
||||||
|
if (Array.isArray(node)) return node.flatMap(elements);
|
||||||
|
if (!isValidElement<{children?:ReactNode; [key:string]:unknown}>(node)) return [];
|
||||||
|
return [node,...elements(node.props.children)];
|
||||||
|
}
|
||||||
|
const players = [
|
||||||
|
{id:'a',name:'Alice',faction:'atreides',ally:null},
|
||||||
|
{id:'b',name:'Basil',faction:'harkonnen',ally:null},
|
||||||
|
{id:'c',name:'Cora',faction:'emperor',ally:null},
|
||||||
|
{id:'d',name:'Dara',faction:'fremen',ally:null},
|
||||||
|
];
|
||||||
|
const base = {status:'playing',turn:2,me:'a',roomControl:null,coalitionState:null,
|
||||||
|
players,deals:[],dealTravelStatus:{},dealAdditionalTravelStatus:{}} as unknown as GameView;
|
||||||
|
const travel = {kind:'ship',territory:'carthag',minimum:1,answer:true} as const;
|
||||||
|
const extra = {actor:'a',kind:'move',territory:'imperial_basin',minimum:1,answer:true} as const;
|
||||||
|
|
||||||
|
void test('additional travel packets retain old defaults, validate actors and bound terms', () => {
|
||||||
|
assert.deepEqual(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],[extra]),
|
||||||
|
{type:'dealOffer',target:'b',terms:'Terms',travel,additionalTravel:[extra]});
|
||||||
|
assert.deepEqual(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],[{...extra,dueTurn:4}]),
|
||||||
|
{type:'dealOffer',target:'b',terms:'Terms',travel,additionalTravel:[{...extra,dueTurn:4}]});
|
||||||
|
assert.deepEqual(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],[{...extra,dueTurn:2}]),
|
||||||
|
{type:'dealOffer',target:'b',terms:'Terms',travel,additionalTravel:[extra]});
|
||||||
|
assert.equal(publicDealOfferAction(['b'],'Terms',undefined,'a',2,undefined,[],[],[extra]),null);
|
||||||
|
assert.equal(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],[{...extra,actor:'c'}]),null);
|
||||||
|
assert.equal(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],[{...extra,dueTurn:1}]),null);
|
||||||
|
assert.equal(publicDealOfferAction(['b'],'Terms',undefined,'a',2,travel,[],[],Array(13).fill(extra)),null);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('travelers wait for nontravelers, then either can accept; individual statuses remain visible', () => {
|
||||||
|
const deal = {id:'deal',from:'a',to:'b',participants:['a','b','c','d'],acceptVotes:['a'],
|
||||||
|
terms:'Two journeys',turn:2,status:'offered',releaseVotes:[],travel:{...travel,actor:'b'},
|
||||||
|
additionalTravel:[{...extra,actor:'c'}]};
|
||||||
|
const game = {...base,me:'b',deals:[deal]} as unknown as GameView;
|
||||||
|
const button = (current:GameView) => elements(PublicDealList({game:current,disabled:false,act() {}}))
|
||||||
|
.find(row => row.props.children === 'Accept deal');
|
||||||
|
assert.equal(button(game)?.props.disabled,true);
|
||||||
|
assert.deepEqual(publicDealRequests(game),[['offer','deal','waiting']]);
|
||||||
|
const afterOther = {...game,deals:[{...deal,acceptVotes:['a','d']}]} as unknown as GameView;
|
||||||
|
assert.equal(button(afterOther)?.props.disabled,false);
|
||||||
|
assert.equal(button({...afterOther,me:'c'} as unknown as GameView)?.props.disabled,false);
|
||||||
|
assert.deepEqual(publicDealRequests({...afterOther,me:'c'} as unknown as GameView),[['offer','deal','ready']]);
|
||||||
|
const active = {...base,me:'c',deals:[{...deal,status:'active',acceptVotes:['a','b','c','d']}],
|
||||||
|
dealTravelStatus:{deal:'fulfilled'},dealAdditionalTravelStatus:{deal:['pending']}} as unknown as GameView;
|
||||||
|
const html = renderToStaticMarkup(createElement(PublicDealList,{game:active,disabled:false,act() {}}));
|
||||||
|
assert.match(html,/Additional travel 1:/); assert.match(html,/Travel status: fulfilled/); assert.match(html,/Travel status: pending/);
|
||||||
|
assert.deepEqual(publicDealRequests(active),[['travel','deal','0']]);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('own travel history uses the indexed term status for release explanations', () => {
|
||||||
|
const records = [0,1].map(index => ({event:`e${index}`,sourceDeal:'deal',sourceDealIndex:index,player:'a',
|
||||||
|
asker:'b',turn:2,mixed:{kind:'action',action:{kind:'ship',territory:'carthag',minimum:1}},
|
||||||
|
answer:true,fulfilled:false,released:true}));
|
||||||
|
const game = {...base,phase:6,active:null,travelPromises:records,allLeaders:[],combatLocations:[],
|
||||||
|
dealTravelStatus:{deal:'fulfilled'},dealAdditionalTravelStatus:{deal:['void','released']}} as unknown as GameView;
|
||||||
|
const html = renderToStaticMarkup(createElement(TravelPromises,{game,busy:false,act() {}}));
|
||||||
|
assert.match(html,/Void: this agreement is no longer possible/);
|
||||||
|
assert.match(html,/Released: this whole commitment is no longer binding/);
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Exercise actual form state callbacks through an isolated React hook stub. */
|
||||||
|
void test('the form authors, validates and removes an additional term', () => {
|
||||||
|
const states:unknown[] = [], sent:Action[] = []; let cursor = 0;
|
||||||
|
const exported:{PublicDeals?:typeof PublicDeals} = {};
|
||||||
|
runInNewContext(ts.transpileModule(readFileSync(new URL('../components/public-deals.tsx',import.meta.url),'utf8'), {
|
||||||
|
compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,jsx:ts.JsxEmit.ReactJSX},
|
||||||
|
}).outputText,{exports:exported,require(name:string) {
|
||||||
|
if (name === 'react/jsx-runtime') return jsxRuntime;
|
||||||
|
if (name === 'react') return {useState(initial:unknown) {
|
||||||
|
const index = cursor++; if (!(index in states)) states[index] = typeof initial === 'function' ? initial() : initial;
|
||||||
|
return [states[index],(next:unknown) => {states[index] = typeof next === 'function' ? next(states[index]) : next;}];
|
||||||
|
},useRef:() => ({current:null}),useEffect:() => {}};
|
||||||
|
if (name === '@/components/ui/button') return {Button:'button'};
|
||||||
|
if (name === '@/game/board') return board;
|
||||||
|
if (name === '@/game/catalog') return catalog;
|
||||||
|
if (name === '@/game/coalition-alliance') return coalitionAlliance;
|
||||||
|
if (name === '@/game/public-deals') return publicDeals;
|
||||||
|
throw new Error(`Unexpected import ${name}`);
|
||||||
|
}});
|
||||||
|
assert.ok(exported.PublicDeals);
|
||||||
|
const render = () => {cursor=0; return elements(exported.PublicDeals!({game:base,busy:false,act(action) {sent.push(action);}}));};
|
||||||
|
const check = (index:number) => {const node=render().filter(row => row.type === 'input' && row.props.type === 'checkbox')[index];
|
||||||
|
assert.ok(node); (node.props.onChange as (event:{target:{checked:boolean}}) => void)({target:{checked:true}});};
|
||||||
|
const select = (index:number,value:string) => {const node=render().filter(row => row.type === 'select')[index]; assert.ok(node);
|
||||||
|
(node.props.onChange as (event:{target:{value:string}}) => void)({target:{value}});};
|
||||||
|
const click = (text:string) => {const node=render().find(row => row.type === 'button' &&
|
||||||
|
(Array.isArray(row.props.children) ? row.props.children.join('') : row.props.children) === text); assert.ok(node);
|
||||||
|
(node.props.onClick as () => void)();};
|
||||||
|
check(0); check(4); // Basil, then travel after four seats' recipient/payment checkboxes.
|
||||||
|
select(2,'carthag');
|
||||||
|
const textarea=render().find(row => row.type === 'textarea'); assert.ok(textarea);
|
||||||
|
(textarea.props.onChange as (event:{target:{value:string}}) => void)({target:{value:'Two journeys'}});
|
||||||
|
click('Add travel term');
|
||||||
|
const submit = () => render().find(row => row.type === 'button' && row.props.type === 'submit');
|
||||||
|
assert.equal(submit()?.props.disabled,true);
|
||||||
|
select(4,'a'); select(5,'move'); select(7,'imperial_basin');
|
||||||
|
assert.equal(submit()?.props.disabled,false);
|
||||||
|
const form = render().find(row => row.type === 'form'); assert.ok(form);
|
||||||
|
(form.props.onSubmit as (event:{preventDefault():void}) => void)({preventDefault() {}});
|
||||||
|
assert.deepEqual(JSON.parse(JSON.stringify(sent.at(-1))),
|
||||||
|
{type:'dealOffer',target:'b',terms:'Two journeys',travel,additionalTravel:[extra]});
|
||||||
|
click('Remove additional travel 1'); assert.equal(submit()?.props.disabled,false);
|
||||||
|
});
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// @dune-suite integration
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import type { GameView } from '../game/engine';
|
||||||
|
import type { PublicDeal } from '../game/public-deals';
|
||||||
|
|
||||||
|
const base = process.env.DUNE_TEST_URL ?? 'http://localhost:3000';
|
||||||
|
async function request(path: string, cookie?: string, body?: unknown) {
|
||||||
|
const response = await fetch(base + path, {
|
||||||
|
method: body === undefined ? 'GET' : 'POST', signal: AbortSignal.timeout(15_000),
|
||||||
|
headers: {
|
||||||
|
...(body === undefined ? {} : {'Content-Type':'application/json'}),
|
||||||
|
...(cookie ? {cookie} : {}),
|
||||||
|
},
|
||||||
|
...(body === undefined ? {} : {body:JSON.stringify(body)}),
|
||||||
|
});
|
||||||
|
return {status:response.status, cookie:response.headers.get('set-cookie')?.split(';')[0],
|
||||||
|
data:await response.json() as GameView & {error?:string}};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A new two-seat room exercises the actual authenticated offer and consent;
|
||||||
|
* future terms need no staged counters, special cards, or existing saves. */
|
||||||
|
void test('authenticated multi-travel deal exposes each independently scheduled term', async () => {
|
||||||
|
const host = await request('/api/rooms',undefined,{
|
||||||
|
name:'Multiple journeys',faction:'harkonnen',advanced:false,expansions:[],
|
||||||
|
});
|
||||||
|
assert.equal(host.status,201,JSON.stringify(host.data)); assert.ok(host.cookie);
|
||||||
|
const path = `/api/rooms/${host.data.code}`;
|
||||||
|
const guest = await request(path,undefined,{type:'join',name:'Other traveler',faction:'atreides'});
|
||||||
|
assert.equal(guest.status,200,JSON.stringify(guest.data)); assert.ok(guest.cookie);
|
||||||
|
const seats = [{id:host.data.me,cookie:host.cookie},{id:guest.data.me,cookie:guest.cookie}];
|
||||||
|
let view = guest.data;
|
||||||
|
const act = async (cookie: string, action: object) => {
|
||||||
|
const next = await request(path,cookie,{version:view.version,action});
|
||||||
|
assert.equal(next.status,200,JSON.stringify(next.data)); view = next.data;
|
||||||
|
};
|
||||||
|
for (const seat of seats) await act(seat.cookie,{type:'ready'});
|
||||||
|
await act(host.cookie,{type:'start'});
|
||||||
|
for (const seat of seats) {
|
||||||
|
const own = await request(path,seat.cookie);
|
||||||
|
assert.equal(own.status,200,JSON.stringify(own.data)); view = own.data;
|
||||||
|
const choices = own.data.players.find(player => player.id === seat.id)?.traitorChoices;
|
||||||
|
if (choices?.length) await act(seat.cookie,{type:'traitor',leader:choices[0]});
|
||||||
|
}
|
||||||
|
assert.equal(view.status,'playing');
|
||||||
|
const travel = {kind:'ship',territory:'polar_sink',minimum:1,answer:true,dueTurn:view.turn+1};
|
||||||
|
const additionalTravel = [
|
||||||
|
{actor:host.data.me,kind:'move',territory:'imperial_basin',minimum:1,answer:true,dueTurn:view.turn+1},
|
||||||
|
{actor:guest.data.me,kind:'move',territory:'polar_sink',minimum:1,answer:false,dueTurn:view.turn+2},
|
||||||
|
];
|
||||||
|
await act(host.cookie,{type:'dealOffer',target:guest.data.me,
|
||||||
|
terms:'We each agree to the listed future journeys.',travel,additionalTravel});
|
||||||
|
const offered = view.deals.at(-1); assert.ok(offered);
|
||||||
|
assert.equal(offered.status,'offered');
|
||||||
|
assert.deepEqual(offered.travel,travel);
|
||||||
|
assert.deepEqual(offered.additionalTravel,additionalTravel);
|
||||||
|
assert.equal(view.dealTravelStatus[offered.id],undefined);
|
||||||
|
assert.equal(view.dealAdditionalTravelStatus[offered.id],undefined);
|
||||||
|
await act(guest.cookie,{type:'dealRespond',deal:offered.id,accept:true});
|
||||||
|
for (const seat of seats) {
|
||||||
|
const read = await request(path,seat.cookie);
|
||||||
|
assert.equal(read.status,200,JSON.stringify(read.data));
|
||||||
|
const active: PublicDeal | undefined = read.data.deals.find(deal => deal.id === offered.id);
|
||||||
|
assert.ok(active); assert.equal(active.status,'active');
|
||||||
|
assert.deepEqual(active.travel,travel);
|
||||||
|
assert.deepEqual(active.additionalTravel,additionalTravel);
|
||||||
|
assert.equal(read.data.dealTravelStatus[offered.id],'scheduled');
|
||||||
|
assert.deepEqual(read.data.dealAdditionalTravelStatus[offered.id],['scheduled','scheduled']);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { viewGame, type Game } from '../game/engine';
|
||||||
|
import { actTruthTravel as act, createTruthTravelFixture as fixture, settleTruthTravel as settle } from './fixture-truth-travel';
|
||||||
|
|
||||||
|
/** Native public Basic setup and phase-five shipment; only unopened component
|
||||||
|
* order is selected by the shared fixture. All terms and actions are real. */
|
||||||
|
function accepted() {
|
||||||
|
const f = fixture(), dueTurn = f.game.turn+1;
|
||||||
|
let game = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Ship, move and ship next turn.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true},
|
||||||
|
additionalTravel:[
|
||||||
|
{actor:f.target,kind:'move',territory:f.movementTerritory,minimum:1,answer:true},
|
||||||
|
{actor:f.target,kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true,dueTurn},
|
||||||
|
]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
game = act(game,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
return {f,game,id};
|
||||||
|
}
|
||||||
|
function linked(game: Game, id: string) {
|
||||||
|
return (game.travelPromises ?? []).filter(row => row.sourceDeal === id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test('primary and indexed additional terms project independent pending, scheduled, fulfilled and released statuses', () => {
|
||||||
|
const {f,id,game:initial} = accepted();
|
||||||
|
let game = initial;
|
||||||
|
assert.equal(viewGame(game,f.target).dealTravelStatus[id],'pending');
|
||||||
|
assert.deepEqual(viewGame(game,f.target).dealAdditionalTravelStatus[id],['pending','scheduled']);
|
||||||
|
game = settle(act(game,f.target,f.shipmentAction));
|
||||||
|
assert.equal(viewGame(game,f.asker).dealTravelStatus[id],'fulfilled');
|
||||||
|
assert.deepEqual(viewGame(game,f.asker).dealAdditionalTravelStatus[id],['pending','scheduled']);
|
||||||
|
game = settle(act(game,f.target,f.firstMove));
|
||||||
|
assert.deepEqual(viewGame(game,f.target).dealAdditionalTravelStatus[id],['fulfilled','scheduled']);
|
||||||
|
game = act(game,f.asker,{type:'dealRelease',deal:id,agree:true});
|
||||||
|
game = act(game,f.target,{type:'dealRelease',deal:id,agree:true});
|
||||||
|
assert.equal(viewGame(game,f.target).dealTravelStatus[id],'fulfilled');
|
||||||
|
assert.deepEqual(viewGame(game,f.target).dealAdditionalTravelStatus[id],['fulfilled','released']);
|
||||||
|
const rows = linked(game,id);
|
||||||
|
assert.equal(rows[0].fulfilled,true);
|
||||||
|
assert.equal(rows[1].fulfilled,true);
|
||||||
|
assert.equal(rows[2].releasedByDeal,true);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('missing, duplicated, misindexed and mismatched deal travel receipts are rejected without mutation', () => {
|
||||||
|
const {f,id,game} = accepted();
|
||||||
|
const variants: Array<(draft: Game) => void> = [
|
||||||
|
draft => { draft.travelPromises = draft.travelPromises!.filter(row => !(row.sourceDeal === id && row.sourceDealIndex === 0)); },
|
||||||
|
draft => { const row = linked(draft,id)[1]; draft.travelPromises!.push(structuredClone(row)); },
|
||||||
|
draft => { linked(draft,id)[1].sourceDealIndex = 1; },
|
||||||
|
draft => { linked(draft,id)[1].sourceDealIndex = 12; },
|
||||||
|
draft => { linked(draft,id)[1].player = f.asker; },
|
||||||
|
draft => { linked(draft,id)[1].turn += 1; },
|
||||||
|
draft => { linked(draft,id)[1].answer = false; },
|
||||||
|
];
|
||||||
|
for (const corrupt of variants) {
|
||||||
|
const draft = structuredClone(game); corrupt(draft);
|
||||||
|
const before = structuredClone(draft);
|
||||||
|
assert.throws(() => viewGame(draft,f.target));
|
||||||
|
assert.deepEqual(draft,before,'Rejecting a damaged source receipt does not mutate the game.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('legacy immediate-settlement signatures stay identical when there are no additional travel terms', () => {
|
||||||
|
const f = fixture();
|
||||||
|
let game = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Two immediate payments.',
|
||||||
|
payment:{kind:'immediateBribe',payer:f.target,recipient:f.asker,amount:1},
|
||||||
|
additionalImmediatePayments:[{kind:'immediateBribe',payer:f.target,recipient:f.asker,amount:1}]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
game = act(game,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
const deal = game.deals!.find(row => row.id === id)!;
|
||||||
|
assert.equal(deal.additionalTravel,undefined);
|
||||||
|
const expected = 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]);
|
||||||
|
const receipt = game.publicDealSettlementHistory?.find(row => row.deal === id);
|
||||||
|
assert.equal(receipt?.signature,expected);
|
||||||
|
const restored = JSON.parse(JSON.stringify(game)) as Game;
|
||||||
|
assert.doesNotThrow(() => viewGame(restored,f.target));
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('additional travel is included in new immediate-settlement signatures', () => {
|
||||||
|
const f = fixture();
|
||||||
|
let game = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Pay and travel twice.',
|
||||||
|
payment:{kind:'immediateBribe',payer:f.target,recipient:f.asker,amount:1},
|
||||||
|
additionalImmediatePayments:[{kind:'immediateBribe',payer:f.target,recipient:f.asker,amount:1}],
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true},
|
||||||
|
additionalTravel:[{actor:f.target,kind:'move',territory:f.movementTerritory,minimum:1,answer:true}]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
game = act(game,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
assert.ok(game.publicDealSettlementHistory?.some(row => row.deal === id));
|
||||||
|
const changed = structuredClone(game), term = changed.deals!.find(row => row.id === id)!.additionalTravel![0];
|
||||||
|
term.minimum += 1;
|
||||||
|
const before = structuredClone(changed);
|
||||||
|
assert.throws(() => viewGame(changed,f.target));
|
||||||
|
assert.deepEqual(changed,before);
|
||||||
|
});
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { createGame, joinGame, newPlayer, type Action, type Game } from '../game/engine';
|
||||||
|
import { actTruthTravel as act, createTruthTravelFixture as fixture, settleTruthTravel as settle,
|
||||||
|
truthTravelClean as clean, truthTravelInventory as inventory, truthTravelPlayer as player } from './fixture-truth-travel';
|
||||||
|
import { nextStrongholdFactionsNativeStep as next } from './fixture-stronghold-factions';
|
||||||
|
|
||||||
|
function reject(game: Game, actor: string, action: Action) {
|
||||||
|
const before = structuredClone(game);
|
||||||
|
assert.throws(() => act(game, actor, action));
|
||||||
|
assert.deepEqual(game, before, 'Rejected consent preserves every vote, commitment and resource.');
|
||||||
|
}
|
||||||
|
function receipts(game: Game, id: string) {
|
||||||
|
return (game.travelPromises ?? []).filter(row => row.sourceDeal === id);
|
||||||
|
}
|
||||||
|
function answer(game: Game, actor: string, id: string) {
|
||||||
|
return act(game, actor, {type:'dealRespond',deal:id,accept:true});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The original shared fixture reaches a real Basic shipment turn through
|
||||||
|
* public setup and native phase actions. No force, purse, promise or vote is
|
||||||
|
* assigned by these tests. */
|
||||||
|
void test('one deal binds and fulfills both a real shipment and a real move', () => {
|
||||||
|
const f = fixture(), originalCards = inventory(f.game), cash = player(f.game,f.target).spice;
|
||||||
|
let game = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Ship, then move.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true},
|
||||||
|
additionalTravel:[{actor:f.target,kind:'move',territory:f.movementTerritory,minimum:1,answer:true}]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
assert.equal(receipts(game,id).length,0);
|
||||||
|
game = answer(game,f.target,id);
|
||||||
|
const bound = receipts(game,id);
|
||||||
|
assert.equal(bound.length,2);
|
||||||
|
assert.equal(bound[0].sourceDealIndex,undefined);
|
||||||
|
assert.equal(bound[1].sourceDealIndex,0);
|
||||||
|
assert.ok(bound.every(row => row.player === f.target && !row.fulfilled && !row.released));
|
||||||
|
reject(game,f.target,f.currentEnd);
|
||||||
|
game = settle(act(game,f.target,f.shipmentAction));
|
||||||
|
assert.equal(receipts(game,id)[0].fulfilled,true);
|
||||||
|
assert.equal(receipts(game,id)[1].fulfilled,false);
|
||||||
|
reject(game,f.target,f.currentEnd);
|
||||||
|
game = settle(act(game,f.target,f.firstMove));
|
||||||
|
assert.ok(receipts(game,id).every(row => row.fulfilled));
|
||||||
|
assert.equal(player(game,f.target).spice,cash-f.shipmentCost);
|
||||||
|
assert.deepEqual(inventory(game),originalCards);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('a conflicting same-turn required and forbidden shipment rejects final consent', () => {
|
||||||
|
const f = fixture();
|
||||||
|
const offered = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Inconsistent shipment terms.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true},
|
||||||
|
additionalTravel:[{actor:f.target,kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:false}]});
|
||||||
|
const id = offered.deals!.at(-1)!.id;
|
||||||
|
reject(offered,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
assert.equal(offered.deals!.at(-1)!.status,'offered');
|
||||||
|
assert.equal(receipts(offered,id).length,0);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('shipment, movement and a due payment cannot spend the same purse twice', () => {
|
||||||
|
const f = fixture(), cash = player(f.game,f.target).spice;
|
||||||
|
assert.ok(cash >= f.shipmentCost);
|
||||||
|
const offered = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Pay and travel.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true},
|
||||||
|
additionalTravel:[{actor:f.target,kind:'move',territory:f.movementTerritory,minimum:1,answer:true}],
|
||||||
|
payment:{kind:'deferredBribe',payer:f.target,recipient:f.asker,amount:cash,dueTurn:f.game.turn}});
|
||||||
|
const id = offered.deals!.at(-1)!.id;
|
||||||
|
reject(offered,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
assert.equal(offered.deals!.at(-1)!.status,'offered');
|
||||||
|
assert.equal(receipts(offered,id).length,0);
|
||||||
|
assert.equal(player(offered,f.target).spice,cash);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('future multi-travel contradictions reject atomically at final acceptance', () => {
|
||||||
|
const f = fixture(), dueTurn = f.game.turn+1;
|
||||||
|
const offered = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Contradictory future shipment.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true,dueTurn},
|
||||||
|
additionalTravel:[{actor:f.target,kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:false,dueTurn}]});
|
||||||
|
const id = offered.deals!.at(-1)!.id;
|
||||||
|
reject(offered,f.target,{type:'dealRespond',deal:id,accept:true});
|
||||||
|
assert.equal(receipts(offered,id).length,0);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('unanimous release cancels every unfinished term, including future travel for another participant', () => {
|
||||||
|
const f = fixture(), dueTurn = f.game.turn+1;
|
||||||
|
let game = act(f.game,f.asker,{type:'dealOffer',target:f.target,terms:'Both of us will ship next turn.',
|
||||||
|
travel:{kind:'ship',territory:f.shipmentTerritory,minimum:1,answer:true,dueTurn},
|
||||||
|
additionalTravel:[{actor:f.asker,kind:'ship',territory:'polar_sink',minimum:1,answer:true,dueTurn}]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
game = answer(game,f.target,id);
|
||||||
|
assert.deepEqual(receipts(game,id).map(row => row.player),[f.target,f.asker]);
|
||||||
|
assert.ok(receipts(game,id).every(row => row.turn === dueTurn));
|
||||||
|
game = act(game,f.asker,{type:'dealRelease',deal:id,agree:true});
|
||||||
|
assert.ok(receipts(game,id).every(row => !row.released));
|
||||||
|
game = act(game,f.target,{type:'dealRelease',deal:id,agree:true});
|
||||||
|
assert.ok(receipts(game,id).every(row => row.released && row.releasedByDeal));
|
||||||
|
assert.equal(game.deals!.at(-1)!.status,'released');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const proposer = 'atreides', firstTraveler = 'emperor', secondTraveler = 'harkonnen', other = 'fremen';
|
||||||
|
function reach(game: Game, until: (state: Game) => boolean): Game {
|
||||||
|
for (let count = 0; count < 1200; count++) {
|
||||||
|
if (until(game)) return game;
|
||||||
|
assert.notEqual(game.status,'finished');
|
||||||
|
const step = next(game); assert.ok(step, `Native continuation needed at ${game.turn}/${game.phase}.`);
|
||||||
|
game = act(game,step.actor,step.action);
|
||||||
|
}
|
||||||
|
throw Error('The original group game did not reach the movement opportunity.');
|
||||||
|
}
|
||||||
|
/** Four actual human Basic seats, with only unopened cards and spice ordering
|
||||||
|
* selected, continued through native setup to the Emperor's real turn. */
|
||||||
|
function groupFixture(): Game {
|
||||||
|
let game = createGame('MULTITRAVEL',newPlayer(proposer,'Atreides','atreides'),false,[]);
|
||||||
|
for (const [id,faction] of [[firstTraveler,'emperor'],[secondTraveler,'harkonnen'],[other,'fremen']] as const)
|
||||||
|
joinGame(game,newPlayer(id,id,faction));
|
||||||
|
for (const seat of game.players) game = act(game,seat.id,{type:'ready'});
|
||||||
|
game = act(game,proposer,{type:'start'});
|
||||||
|
const cards = game.deck.filter(card => ['projectile','poison','shield','snooper'].includes(card.kind)).slice(0,4);
|
||||||
|
assert.equal(cards.length,4);
|
||||||
|
for (const [position,card] of cards.entries()) {
|
||||||
|
const from = game.deck.findIndex(row => row.id === card.id); assert.ok(from >= position);
|
||||||
|
[game.deck[position],game.deck[from]] = [game.deck[from],game.deck[position]];
|
||||||
|
}
|
||||||
|
game = reach(game,state => state.status === 'playing');
|
||||||
|
const from = game.spiceDeck.findIndex(card => 'territory' in card && !card.discovery); assert.ok(from >= 0);
|
||||||
|
game.spiceDeck.unshift(game.spiceDeck.splice(from,1)[0]);
|
||||||
|
return reach(game,state => state.turn === 1 && state.phase === 5 && state.active === firstTraveler && clean(state));
|
||||||
|
}
|
||||||
|
let source: Game | undefined;
|
||||||
|
const group = () => structuredClone(source ??= groupFixture());
|
||||||
|
for (const voters of [[firstTraveler,secondTraveler],[secondTraveler,firstTraveler]]) void test(
|
||||||
|
`ordinary invitees consent before both travelers, who may accept in either order (${voters.join(' then ')})`, () => {
|
||||||
|
const initial = group(), dueTurn = initial.turn+1, cards = inventory(initial);
|
||||||
|
let game = act(initial,proposer,{type:'dealOffer',targets:[firstTraveler,secondTraveler,other],
|
||||||
|
terms:'Two players will ship on different turns.',
|
||||||
|
travel:{actor:firstTraveler,kind:'ship',territory:'polar_sink',minimum:1,answer:true},
|
||||||
|
additionalTravel:[{actor:secondTraveler,kind:'ship',territory:'polar_sink',minimum:1,answer:true,dueTurn}]});
|
||||||
|
const id = game.deals!.at(-1)!.id;
|
||||||
|
reject(game,voters[0],{type:'dealRespond',deal:id,accept:true});
|
||||||
|
game = answer(game,other,id);
|
||||||
|
game = answer(game,voters[0],id);
|
||||||
|
assert.equal(game.deals!.at(-1)!.status,'offered');
|
||||||
|
assert.equal(receipts(game,id).length,0);
|
||||||
|
game = answer(game,voters[1],id);
|
||||||
|
assert.equal(game.deals!.at(-1)!.status,'active');
|
||||||
|
assert.deepEqual(receipts(game,id).map(row => [row.player,row.turn]),
|
||||||
|
[[firstTraveler,initial.turn],[secondTraveler,dueTurn]]);
|
||||||
|
game = reach(act(game,firstTraveler,{type:'ship',territory:'polar_sink',sector:0,amount:1,elite:0,allyPayment:0}),
|
||||||
|
state => clean(state) && !state.pendingShipment);
|
||||||
|
assert.equal(receipts(game,id)[0].fulfilled,true);
|
||||||
|
assert.equal(receipts(game,id)[1].fulfilled,false);
|
||||||
|
assert.deepEqual(inventory(game),cards);
|
||||||
|
},
|
||||||
|
);
|
||||||
Reference in new issue
Block a user