import assert from 'node:assert/strict'; import test from 'node:test'; import { viewGame } from '../game/engine'; import { createTruthMovementNativeEarlyFixture as fixture, actTruthMovementNativeEarly as act, advanceTruthMovementNativeEarly as advance, truthMovementNativeEarlyClean as clean, truthMovementNativeEarlyPlayer as player } from './fixture-truth-movement-native-early'; void test('a positive final Silent bid keeps an affordable movement promise through the allied gift window', () => { const f = fixture(), source = structuredClone(f.game), auction = { method: 'silent' as const }; player(source, f.target).ally = 'choam'; player(source, 'choam').ally = f.target; let game = act(source, f.asker, f.declarationStep.action); while (game.truthtrance?.stage === 'priority') { const seat = game.players.find(p => !game.truthtrance!.passed.includes(p.id)); assert.ok(seat); game = act(game, seat.id, { type: 'truthPass' }); } game = act(game, f.asker, { type: 'truthAsk', question: f.claim }); assert.ok(viewGame(game, f.target).truthMovementAnswers!.includes('yes')); game = advance(act(game, f.target, { type: 'truthAnswer', answer: 'yes' }), clean); game = advance(game, g => g.phase === 3 && clean(g) && !!g.richeseAuction && !g.richeseAuction.outcome, [], auction); game = act(game, f.target, { type: 'pledgeAid', amount: 8 }); const lot = game.richeseAuction!; assert.ok(['choam', 'richese', f.target].every(id => lot.eligible.includes(id))); game = act(game, 'choam', { type: 'richeseBid', event: lot.event, amount: 3, allyPayment: 1 }); for (const id of lot.eligible.filter(id => id !== 'choam' && id !== f.target)) game = act(game, id, { type: 'richeseBid', event: lot.event, amount: 0, allyPayment: 0 }); assert.equal(game.movementPromises![0].released, undefined); game = act(game, f.target, { type: 'richeseBid', event: lot.event, amount: 1, allyPayment: 0 }); assert.deepEqual(game.richeseAuction?.outcome, { kind: 'sold', winner: 'choam', amount: 3 }); assert.equal(game.pendingEmperorAuctionGift?.owner, f.target); assert.equal(game.movementPromises![0].released, undefined); const event = game.pendingEmperorAuctionGift!.event; game = act(game, f.target, { type: 'emperorAuctionGiftContinue', event }); assert.equal(player(game, f.target).spice, 2); assert.equal(game.aid[f.target]?.amount, 7); assert.equal(game.movementPromises![0].released, undefined); game = advance(game, g => g.phase === 5 && clean(g) && g.active === f.target, [], auction); assert.equal(player(game, f.target).spice, 9); game = act(game, f.target, f.shipment); game = advance(game, clean, [], auction); game = act(game, f.target, f.move); assert.equal(game.movementPromises![0].fulfilled, true); });