Allow proposers to commit their own travel
Verify and publish checkpoint container / container (push) Successful in 11m23s
Verify and publish checkpoint container / container (push) Successful in 11m23s
This commit is contained in:
1 parent
235696263a
commit
13c337a24a
11 files changed
+456
-27
No files matched your search
+9
-3
@@ -6067,6 +6067,11 @@ function publicDealImmediateSignature(deal: PublicDeal): string {
|
||||
function publicDealSettlementSignature(deal: PublicDeal, frame: NonNullable<Game['pendingPublicDealSettlement']>): string {
|
||||
return JSON.stringify([publicDealImmediateSignature(deal),frame.next,frame.initiator,frame.turn,frame.phase]);
|
||||
}
|
||||
/** Travel ledgers need another participant as the originating party. Older
|
||||
* recipient-travel deals continue to identify their original proposer. */
|
||||
function publicDealTravelAsker(deal: PublicDeal): string {
|
||||
return publicDealTravelActor(deal) === deal.from ? deal.to : deal.from;
|
||||
}
|
||||
function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||
if (g.deals !== undefined) publicDealRule(() => validatePublicDeals(g.deals, g.players));
|
||||
const history = g.publicDealSettlementHistory ?? [];
|
||||
@@ -6103,7 +6108,7 @@ function publicDealIntegrity(g: Game, internalSettlement?: string): void {
|
||||
const deal = g.deals?.find(entry => entry.id === row.sourceDeal);
|
||||
const term = deal?.travel;
|
||||
requireRule(deal && term && ['active', 'released'].includes(deal.status) &&
|
||||
row.player === publicDealTravelActor(deal) && row.asker === deal.from && row.turn === publicDealTravelDueTurn(deal) &&
|
||||
row.player === publicDealTravelActor(deal) && row.asker === publicDealTravelAsker(deal) && row.turn === publicDealTravelDueTurn(deal) &&
|
||||
row.answer === term.answer && row.mixed.kind === 'action' &&
|
||||
row.mixed.action.kind === term.kind && row.mixed.action.territory === term.territory &&
|
||||
row.mixed.action.minimum === term.minimum && row.mixed.action.sector === undefined &&
|
||||
@@ -24467,7 +24472,7 @@ function bindPublicDealTravel(g: Game, deal: PublicDeal) {
|
||||
}
|
||||
initializeTravelOrder(g);
|
||||
(g.travelPromises ??= []).push({ ...claim, event: crypto.randomUUID(), sourceDeal: deal.id,
|
||||
player: player.id, asker: deal.from, answer: term.answer, compiled: { kind: 'action', action },
|
||||
player: player.id, asker: publicDealTravelAsker(deal), answer: term.answer, compiled: { kind: 'action', action },
|
||||
shipment: { pending: due > g.turn || g.phase < 5 || shipmentAvailable(g, player), event: null },
|
||||
progress: [], movementClosed: false, fulfilled: false, released: false });
|
||||
appendTravelOrder(g, 'travel', g.travelPromises.length - 1);
|
||||
@@ -43888,7 +43893,8 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
next = publicDealRule(() => releasePublicDeal(current, g.players, id, action.agree as boolean));
|
||||
} else next = publicDealRule(() => withdrawPublicDeal(current, g.players, id));
|
||||
if (current.status === 'offered' && next.status === 'active' && next.travel) {
|
||||
requireRule(id === publicDealTravelActor(next), 'The traveler must give the final consent.');
|
||||
requireRule(publicDealTravelActor(next) === next.from || id === publicDealTravelActor(next),
|
||||
'The traveler must give the final consent.');
|
||||
bindPublicDealTravel(g, next);
|
||||
}
|
||||
if (current.status === 'active' && next.status === 'released' && next.travel) {
|
||||
|
||||
+11
-11
@@ -24,14 +24,15 @@ export type PublicDealAdditionalPayment = {
|
||||
};
|
||||
export const MAX_ADDITIONAL_DEAL_PAYMENTS = 12;
|
||||
export const MAX_ADDITIONAL_IMMEDIATE_DEAL_PAYMENTS = 12;
|
||||
/** One invited recipient commits to one native action (or its absence).
|
||||
* Old two-party records identify that recipient through `to`. */
|
||||
/** One participant commits to one native action (or its absence).
|
||||
* Old two-party records identify the recipient through `to`. */
|
||||
export type PublicDealTravel = {
|
||||
kind: 'ship' | 'move';
|
||||
territory: string;
|
||||
minimum: number;
|
||||
answer: boolean;
|
||||
/** Present only in a multi-party term; the selected recipient accepts last. */
|
||||
/** Explicit in a group term or when a pair names its traveler. An invited
|
||||
* traveler accepts last; the proposer already consents by making the offer. */
|
||||
actor?: string;
|
||||
/** Absent on existing terms: their original offer turn is the due turn. */
|
||||
dueTurn?: number;
|
||||
@@ -148,7 +149,7 @@ export function parsePublicDealPayment(value: unknown, parties: readonly string[
|
||||
amount: value.amount, dueTurn: value.dueTurn };
|
||||
}
|
||||
|
||||
/** Parse an exact travel claim; the multi-party actor is validated against the deal. */
|
||||
/** Parse an exact travel claim; any explicit actor is validated against the deal. */
|
||||
export function parsePublicDealTravel(value: unknown): PublicDealTravel {
|
||||
const keys = object(value) ? Object.keys(value).sort().join(',') : '';
|
||||
requireDeal(object(value) && (keys === 'answer,kind,minimum,territory' ||
|
||||
@@ -212,13 +213,12 @@ export function validatePublicDeals(value: unknown, players: readonly PublicDeal
|
||||
const travel = parsePublicDealTravel(deal.travel);
|
||||
requireDeal(travel.dueTurn === undefined || travel.dueTurn >= (deal.turn as number),
|
||||
'Choose a travel turn no earlier than the offer turn.');
|
||||
requireDeal(multi
|
||||
? !!travel.actor && travel.actor !== deal.from && parties.includes(travel.actor)
|
||||
: !Object.hasOwn(travel, 'actor'),
|
||||
'Choose an invited traveler and an optional bribe between participants.');
|
||||
// The actor's final acceptance is checked privately. An unfinished offer
|
||||
// cannot already contain that vote, even after a decline or withdrawal.
|
||||
if (multi && deal.status !== 'active' && deal.status !== 'released')
|
||||
requireDeal(multi ? !!travel.actor && parties.includes(travel.actor)
|
||||
: !travel.actor || parties.includes(travel.actor),
|
||||
'Choose a deal participant as traveler and an optional bribe between participants.');
|
||||
// An invited actor's final acceptance is checked privately. The proposer
|
||||
// has already consented by making the offer and remains in its votes.
|
||||
if (multi && travel.actor !== deal.from && deal.status !== 'active' && deal.status !== 'released')
|
||||
requireDeal(!(deal.acceptVotes as string[]).includes(travel.actor!),
|
||||
'The committed traveler accepts after all other invited participants.');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user