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

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

No files matched your search

+22 -4
View File
@@ -118,7 +118,21 @@ void test('an optional gross bribe is bound to two distinct participants', () =>
assert.equal(publicDealOfferAction(['b'], 'Terms', payment), null);
});
void test('all players can review the gross payment and only final acceptance is held at a blocked payment window', () => {
void test('a deferred payment and travel show each participant and due turn in the deal history', () => {
const payment = {kind:'deferredBribe', payer:'a', recipient:'b', amount:3, dueTurn:4};
const travel = {kind:'ship', territory:'carthag', minimum:2, answer:true, actor:'e', dueTurn:3};
const combined = {...offer, participants:['a','b','e'], acceptVotes:['a','b','e'], status:'active',
payment, paymentStatus:'pending', travel};
const game = {...base, turn:2, players:base.players.map(player => ({...player, ally:null})),
deals:[combined], dealTravelStatus:{'deal-1':'scheduled'}} as unknown as GameView;
const html = render(game);
assert.match(html, /Alice \(Atreides\) pays exactly 3 spice to Basil \(Harkonnen\) on or before the end of turn 4/);
assert.match(html, /Emperor \(Emperor\) agrees to make a reserve shipment of at least 2 physical forces in one action to Carthag during turn 3/);
assert.match(html, /Payment status: pending/);
assert.match(html, /Travel status: scheduled/);
});
void test('the payer’s own blocked payment quote applies at final acceptance without using another seat’s quote', () => {
const payment = { kind: 'immediateBribe' as const, payer: 'b', recipient: 'a', amount: 3 };
const multi = { ...offer, participants: ['a', 'b', 'e'], acceptVotes: ['a'], payment };
const game = { ...base, players: base.players.map(player =>
@@ -135,10 +149,14 @@ void test('all players can review the gross payment and only final acceptance is
assert.equal(first.find(node => node.props.children === 'Accept deal')?.props.disabled, false);
const lastGame = { ...game, me: 'e', deals: [{ ...multi, acceptVotes: ['a', 'b'] }] } as unknown as GameView;
const last = actions(lastGame, []);
assert.equal(last.find(node => node.props.children === 'Accept deal')?.props.disabled, true);
assert.equal(last.find(node => node.props.children === 'Accept deal')?.props.disabled, false,
'A final recipient cannot use their private quote to block another payer.');
assert.equal(last.find(node => node.props.children === 'Decline deal')?.props.disabled, false);
assert.match(render(lastGame), /Final acceptance must wait: Finish the current decision before paying a bribe/);
const unblocked = { ...lastGame, bribeOptions: { ...lastGame.bribeOptions, blocked: null } } as GameView;
assert.doesNotMatch(render(lastGame), /Final acceptance must wait:/);
const payerFinal = {...lastGame, deals:[{...multi, acceptVotes:['a','b'], payment:{...payment,payer:'e'}}]} as GameView;
assert.equal(actions(payerFinal, []).find(node => node.props.children === 'Accept deal')?.props.disabled, true);
assert.match(render(payerFinal), /Final acceptance must wait: Finish the current decision before paying a bribe/);
const unblocked = { ...payerFinal, bribeOptions: { ...payerFinal.bribeOptions, blocked: null } } as GameView;
assert.equal(actions(unblocked, []).find(node => node.props.children === 'Accept deal')?.props.disabled, false);
});