37 lines
1.9 KiB
TypeScript
37 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { viewGame } from '../game/engine';
|
|
import { actDistransPrebid, distransPrebidInventory, distransPrebidPlayer as player } from './fixture-distrans-prebid';
|
|
import { createDistransRichesePrebidFixture } from './fixture-distrans-richese-prebid';
|
|
import { distransAuctionBlock } from '../game/distrans-timing';
|
|
|
|
for (const method of ['onceAround', 'silent'] as const) {
|
|
void test(`a started ${method} cache auction preserves its commitments while Semuta guards Distrans`, () => {
|
|
const f = createDistransRichesePrebidFixture({ method });
|
|
const lot = f.game.richeseAuction!;
|
|
const bidder = method === 'silent'
|
|
? lot.order.find(id => id !== f.holder && player(f.game, id).spice >= 1)!
|
|
: lot.active!;
|
|
assert.ok(bidder && player(f.game, bidder).spice >= 1);
|
|
const game = actDistransPrebid(f.game, bidder, {
|
|
type: 'richeseBid', event: lot.event, amount: 1, allyPayment: 0,
|
|
});
|
|
assert.ok(game.richeseAuction && !game.richeseAuction.outcome);
|
|
assert.ok(game.richeseAuction.acted.includes(bidder));
|
|
assert.equal(distransAuctionBlock(game), null, 'Completed special bid is a valid timing interval');
|
|
const before = structuredClone(game), beforeInventory = distransPrebidInventory(game);
|
|
assert.match(viewGame(game, f.holder).distrans!.blocked!, /Semuta preview/);
|
|
assert.throws(() => actDistransPrebid(game, f.holder, f.action), /Semuta preview/);
|
|
assert.deepEqual(game, before);
|
|
assert.deepEqual(distransPrebidInventory(game), beforeInventory);
|
|
if (method === 'silent') {
|
|
const observer = game.players.find(p => p.id !== bidder)!;
|
|
const hidden = viewGame(game, observer.id).richeseAuction!;
|
|
assert.equal(hidden.ownBid, null);
|
|
assert.equal(hidden.revealedBids, null);
|
|
assert.equal('sealed' in hidden, false);
|
|
assert.equal(viewGame(game, bidder).richeseAuction!.ownBid, 1);
|
|
}
|
|
});
|
|
}
|