import assert from 'node:assert/strict'; import test from 'node:test'; import { viewGame } from '../game/engine'; import { botActions } from '../game/bots'; import { DIFFICULTIES } from '../game/bot-profiles'; import { act, player, selectedDiscoverySkillsOverlapFixture } from './selected-discovery-skills-overlap-fixture'; for (const advanced of [false, true]) void test( `${advanced ? 'Advanced' : 'Basic'} mixed Discovery and Skills retain the original Ecaz/Moritani arrival`, () => { const f = selectedDiscoverySkillsOverlapFixture(advanced); assert.equal(f.lobby.discoveryEnabled, true); assert.ok(f.setup.discoveries && f.setup.leaderSkills); assert.equal(f.game.leaderSkills!.assignments.length, f.game.players.length); assert.ok(f.beforeMarkers.spiceDiscard.flat().some(card => 'territory' in card && card.discovery === 'discovery-hagga-basin')); assert.equal(f.beforeMarkers.discoveries!.tokens.filter(token => token.status === 'placed').length, 1); assert.ok(!f.game.nexusCards && !f.game.ecazTreachery); const moritaniSpice = player(f.game, 'moritani').spice; const duke = structuredClone(f.game.dukeVidal!.leader); let game = act(f.game, 'guild', f.shipment); game = f.advance(game, state => !!state.pendingArrivalOverlap); const afterShipment = player(game, 'guild').spice; const stolen = Math.ceil(afterShipment / 2); assert.equal(player(game, 'guild').forces[`${f.destination}:${f.sector}`], 1); const first = game.pendingArrivalOverlap!.first; const responder = first === 'ambassador' ? 'ecaz' : 'moritani'; for (const difficulty of DIFFICULTIES) { const view = viewGame(game, responder); view.players.find(row => row.id === responder)!.bot = difficulty; const choice = botActions(view)[0]; assert.ok(choice, difficulty); assert.doesNotThrow(() => act(game, responder, choice), difficulty); } const ambassador = () => { const entry = game.pendingAmbassador; assert.ok(entry); assert.equal(entry.token, f.token); game = act(game, 'ecaz', {type:'decision', event:entry.event, trigger:true, beneficiary:'ecaz', choice:'duke'}); }; const robbery = () => { assert.equal(game.pendingTerrorEntry?.token, f.terror); game = act(game, 'moritani', {type:'decision', reveal:true}); game = act(game, 'moritani', {type:'decision', choice:'spice'}); }; if (first === 'ambassador') { ambassador(); robbery(); } else { robbery(); ambassador(); } assert.equal(game.pendingArrivalOverlap ?? null, null); assert.equal(game.pendingAmbassador ?? null, null); assert.equal(game.pendingTerrorEntry ?? null, null); assert.equal(player(game, 'guild').spice, afterShipment - stolen); assert.equal(player(game, 'moritani').spice, moritaniSpice + stolen); assert.equal(player(game, 'guild').forces[`${f.destination}:${f.sector}`], 1); assert.equal(game.moritaniTerror!.tokens.find(row => row.id === f.terror)?.status, 'removed'); assert.equal(game.ecazAmbassadors!.tokens.find(row => row.id === f.token)?.zone, 'supply'); assert.deepEqual([game.dukeVidal?.controller, game.dukeVidal?.source], ['ecaz', 'ecaz']); assert.deepEqual(game.dukeVidal?.leader, duke); assert.equal(game.leaderSkills!.assignments.length, game.players.length); }, );