Support deferred payments with travel deals
Verify and publish checkpoint container / container (push) Successful in 11m29s
Verify and publish checkpoint container / container (push) Successful in 11m29s
This commit is contained in:
1 parent
9536c77062
commit
5e294215be
16 files changed
+603
-100
No files matched your search
@@ -117,12 +117,27 @@ void test('unanimous release ends the pending travel obligation without refundin
|
||||
assert.equal(player(game, f.target).bribes, escrow);
|
||||
});
|
||||
|
||||
void test('paid travel excludes deferred and multiparty payment variants', () => {
|
||||
void test('travel can include a deferred payment while invalid participant lists still reject', () => {
|
||||
const f = fixture(), travel = { kind: 'ship', territory: f.shipmentTerritory, minimum: 1, answer: true };
|
||||
const base = { type: 'dealOffer', target: f.target, terms: 'Travel.', travel } satisfies Action;
|
||||
reject(f.game, f.asker, { ...base, payment: { kind: 'deferredBribe', payer: f.asker, recipient: f.target, amount: 1, dueTurn: f.game.turn } });
|
||||
const payment = { kind: 'deferredBribe', payer: f.asker, recipient: f.target, amount: 1, dueTurn: f.game.turn };
|
||||
const offered = act(f.game, f.asker, { ...base, payment });
|
||||
const deal = offered.deals!.at(-1)!;
|
||||
let game = accept(offered, f.target, deal.id);
|
||||
assert.equal(game.deals!.find(row => row.id === deal.id)!.paymentStatus, 'pending');
|
||||
assert.equal(status(game, f.target, deal.id), 'pending');
|
||||
const payerBefore = player(game, f.asker).spice, recipientBefore = player(game, f.target).bribes;
|
||||
game = act(game, f.asker, {type:'dealPay', deal:deal.id});
|
||||
assert.equal(player(game, f.asker).spice, payerBefore - 1);
|
||||
assert.equal(player(game, f.target).bribes, recipientBefore + 1);
|
||||
assert.equal(game.deals!.find(row => row.id === deal.id)!.paymentStatus, 'paid');
|
||||
game = settle(act(game, f.target, f.shipmentAction));
|
||||
assert.equal(status(game, f.target, deal.id), 'fulfilled');
|
||||
assert.deepEqual(inventory(game), f.originalCards);
|
||||
reject(f.game, f.asker, { type: 'dealOffer', targets: [f.target, f.asker], terms: 'Travel.', travel,
|
||||
payment: { kind: 'immediateBribe', payer: f.asker, recipient: f.target, amount: 1 } });
|
||||
reject(f.game, f.asker, { ...base, payment: { ...payment, dueTurn: f.game.turn - 1 } });
|
||||
reject(f.game, f.asker, { ...base, payment: { ...payment, recipient: f.asker } });
|
||||
});
|
||||
|
||||
void test('the travelling recipient can pay the proposer at final consent and then complete shipment', () => {
|
||||
|
||||
Reference in new issue
Block a user