From c8dbd44975ed338071b731b3149af523eb3d5361 Mon Sep 17 00:00:00 2001 From: Quintine <15965533+Quintine@users.noreply.github.com> Date: Thu, 29 Oct 2026 20:14:11 +1100 Subject: [PATCH] Enable mixed selected-deck Discovery previews --- docs/CURRENT_STATUS.md | 10 +++ docs/DISCOVERY_PROTOTYPE.md | 16 +++++ docs/RULE_DECISIONS.md | 7 ++ game/discovery-module-profile.ts | 15 ++-- game/engine.ts | 4 +- game/reference.ts | 6 +- tests/discovery-module-profile.test.ts | 17 ++++- tests/fixture-mixed-discovery-only.ts | 49 +++++++++++++ tests/mixed-discovery-only-runtime.test.ts | 82 ++++++++++++++++++++++ 9 files changed, 195 insertions(+), 11 deletions(-) create mode 100644 tests/fixture-mixed-discovery-only.ts create mode 100644 tests/mixed-discovery-only-runtime.test.ts diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index 9078920f..48db3f1a 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -17,6 +17,16 @@ open mode gates. ## Current checkpoint and work +**Mixed selected-deck Discovery without extra variants — 29 October. +Prototyped / Partial.** Basic and Advanced previews can select Discovery with +E3 plus Ix and/or CHOAM without also selecting Nexus or independent cards. +Selected decks need not all have a seated native faction. Thirteen related +files pass 82 cases; public-start runtime fixtures exercise Ixian setup and +shipment, a Discovery blow and the Ecaz/Moritani entry, with controlled unopened +Spice and token placement. Advanced Moritani/Harkonnen, deeper interactions, +complete games and deployed verification remain open. +[Scope](DISCOVERY_PROTOTYPE.md#mixed-selected-deck-discovery-alone--29-october-2026). + **Fresh Richese No-Field on native Homeworld — 29 October. Prototyped / Partial.** Advanced Richese can provisionally place a fresh concealed marker on its own World for one spice. The native physical reserve pool stays unchanged, diff --git a/docs/DISCOVERY_PROTOTYPE.md b/docs/DISCOVERY_PROTOTYPE.md index 11f484ae..a2d2cb06 100644 --- a/docs/DISCOVERY_PROTOTYPE.md +++ b/docs/DISCOVERY_PROTOTYPE.md @@ -1,5 +1,21 @@ # Discovery functional prototype +## Mixed selected-deck Discovery alone — 29 October 2026 + +**Prototyped / Partial.** Basic and Advanced previews can use Discovery with +selected Ecaz/Moritani, Ixians/Tleilaxu and/or CHOAM/Richese decks without +requiring Nexus or the independent Ecaz cards. A selected deck need not have a +seated native faction. Existing Tech3+ and Advanced Stronghold prerequisites, +unrelated overlay restrictions and the Advanced Moritani/Harkonnen boundary +remain. The Ecaz/Moritani paired arrival retains its provisional storm order; +its Fremen/Guild Ambassador-created child restrictions are still separate. + +Thirteen related files pass 82 cases. Public-start Basic and Advanced fixtures +exercise original Ixian setup and shipment, an actual Discovery blow, Duke +acquisition and Robbery with legal bot choices. Unopened Spice order and original +Ambassador/Terror placement are controlled. Other optional-module interactions, +complete games and deployed verification remain open. + ## Ecaz and Moritani with Discovery alone — 29 October 2026 **Prototyped / Partial.** A fresh Basic or Advanced preview can select both diff --git a/docs/RULE_DECISIONS.md b/docs/RULE_DECISIONS.md index b501339e..98b1c920 100644 --- a/docs/RULE_DECISIONS.md +++ b/docs/RULE_DECISIONS.md @@ -1,5 +1,12 @@ # Rule decision index +## Mixed selected-deck Discovery alone — 29 October 2026 + +Discovery no longer requires Nexus or independent cards when E3 is selected +alongside Ix and/or CHOAM decks. Existing entry-order interpretations and +unsupported interaction boundaries remain. +[Scope](DISCOVERY_PROTOTYPE.md#mixed-selected-deck-discovery-alone--29-october-2026). + ## Fresh native Homeworld No-Field — 29 October 2026 Advanced Richese may provisionally place its fresh marker on its own World for diff --git a/game/discovery-module-profile.ts b/game/discovery-module-profile.ts index bbef67c3..b28cdec2 100644 --- a/game/discovery-module-profile.ts +++ b/game/discovery-module-profile.ts @@ -1,5 +1,5 @@ import { FACTIONS } from './catalog'; -import { independentDiscoveryProfile, mixedE3NexusRosterProfile, type FactionModuleProfile } from './faction-module-profile'; +import { independentDiscoveryProfile, mixedE3NexusRosterProfile, selectedPhaseModuleRoster, type FactionModuleProfile } from './faction-module-profile'; import type { LeaderSkillProfile } from './leader-skill-profile'; /** Public unused-lobby admission only. The original initializer owns physical @@ -21,7 +21,7 @@ export function discoveryModeSupported(game: FactionModuleProfile): boolean { mixedE3DiscoveryNexusProfile(game) || mixedE1E2DiscoveryNexusProfile(game) || pairedE3DiscoveryNexusProfile(game); if (typeof game.advanced !== 'boolean' || game.discoveryEnabled !== true || game.players.length < 2 || game.players.length > 6 || - (game.techTokens && game.players.length < 3) || game.expansions.length > 2 || + (game.techTokens && game.players.length < 3) || game.expansions.length > 3 || (game.strongholdCards && !game.advanced) || game.leaderSkills || game.nexusCards || game.ecazTreachery || game.advancedPreview || game.kullPreview || game.nexusKullPreview || @@ -30,6 +30,11 @@ export function discoveryModeSupported(game: FactionModuleProfile): boolean { return false; if (game.semutaPreview && (game.homeworlds || !game.expansions.includes('choam') || !game.players.some(player => player.faction === 'richese'))) return false; + if (game.expansions.includes('ecaz') && game.expansions.length > 1) { + return !game.semutaPreview && selectedPhaseModuleRoster(game) && + !(game.advanced && game.players.some(player => player.faction === 'moritani') && + game.players.some(player => player.faction === 'harkonnen')); + } const e3 = game.expansions.length === 1 && game.expansions[0] === 'ecaz'; for (let i = 0; i < game.expansions.length; i++) { const expansion = game.expansions[i]; @@ -55,10 +60,10 @@ export function discoveryModeSupported(game: FactionModuleProfile): boolean { return (!e3 || native >= 1 && native <= 2) && !(game.advanced && moritani && harkonnen); } -/** The original E3 pair can use Discovery without choosing a Nexus or card variant. */ -export function pairedE3DiscoveryOnlyProfile(game: FactionModuleProfile): boolean { +/** The original E3 pair can use selected decks with Discovery without Nexus or cards. */ +export function e3DiscoveryOnlyOverlapProfile(game: FactionModuleProfile): boolean { return !game.nexusCards && !game.ecazTreachery && !game.leaderSkills && - game.expansions.length === 1 && game.expansions[0] === 'ecaz' && + game.expansions.includes('ecaz') && game.players.some(player => player.faction === 'ecaz') && game.players.some(player => player.faction === 'moritani') && discoveryModeSupported(game); } diff --git a/game/engine.ts b/game/engine.ts index af820cbc..f2225733 100644 --- a/game/engine.ts +++ b/game/engine.ts @@ -109,7 +109,7 @@ import { PhaseBidPromiseError, phaseBidPromiseModeSupported, livePhaseBidPromise phaseBidCompletionRange, recordPhaseBid, reconcilePhaseBidPromises, finishPhaseBidPhase, validatePhaseBidPromises, type PhaseBidClaim, type PhaseBidOpportunity, type PhaseBidPromise } from './turn-bid-promises'; -import { classicDiscoveryLeaderSkillsProfile, classicDiscoveryNexusProfile, homeworldDiscoveryProfile, discoveryModeSupported, discoveryModuleProfile, mixedE1E2DiscoveryNexusProfile, mixedE3DiscoveryNexusProfile, pairedDiscoveryNexusProfile, pairedE3DiscoveryNexusProfile, pairedE3DiscoveryOnlyProfile, singleE1E2DiscoveryNexusProfile, standaloneE3DiscoveryNexusProfile } from './discovery-module-profile'; +import { classicDiscoveryLeaderSkillsProfile, classicDiscoveryNexusProfile, homeworldDiscoveryProfile, discoveryModeSupported, discoveryModuleProfile, e3DiscoveryOnlyOverlapProfile, mixedE1E2DiscoveryNexusProfile, mixedE3DiscoveryNexusProfile, pairedDiscoveryNexusProfile, pairedE3DiscoveryNexusProfile, singleE1E2DiscoveryNexusProfile, standaloneE3DiscoveryNexusProfile } from './discovery-module-profile'; import { advancedMoritaniLeaderSkillsProfile, selectedDeckLeaderSkillsProfile, homeworldLeaderSkillsProfile, independentTreacheryLeaderSkillsProfile, classicNexusLeaderSkillsProfile, classicTechLeaderSkillsProfile, guildBetrayalNexusLeaderSkillsProfile, mixedE1E2NexusLeaderSkillsProfile, mixedE3NexusLeaderSkillsProfile, nativeDiscoveryLeaderSkillsProfile, nativeEcazLeaderSkillsProfile, nativeExpansionLeaderSkillsProfile, nativeTechLeaderSkillsProfile, ordinaryLeaderSkillModeSupported, pairedE3LeaderSkillsProfile, pairedE3NexusLeaderSkillsProfile, pairedNexusLeaderSkillsProfile, singleE1E2NexusLeaderSkillsProfile, standaloneE3NexusLeaderSkillsProfile, strongholdLeaderSkillsProfile } from './leader-skill-profile'; import { bribeReceiptTiming, bribeTimingBlock, bribesCloseBeforeNextMentat, maximumBribe, type BribeOptions } from './bribe-options'; import { quoteAtreidesFullPlan } from './atreides-full-plan'; @@ -25166,7 +25166,7 @@ function bareAdvancedNativeArrivalOverlap(g: Game): boolean { function arrivalOverlapModeSupported(g: Game, revivalArrival?: RevivalEntryParent): boolean { if (bareBasicNativeArrivalOverlap(g)) return true; if (bareAdvancedNativeArrivalOverlap(g)) return true; - if (pairedE3DiscoveryOnlyProfile(g)) return true; + if (e3DiscoveryOnlyOverlapProfile(g)) return true; if (homeworldPhaseModulesProfile(g) && byFaction(g, 'ecaz') && byFaction(g, 'moritani')) return true; if (revivalArrival && g.homeworlds && byFaction(g, 'ecaz') && byFaction(g, 'moritani')) return true; if (bareBasicSemutaProfile(g) && byFaction(g, 'ecaz') && byFaction(g, 'moritani')) return true; diff --git a/game/reference.ts b/game/reference.ts index 9d2327b7..58b8086d 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -5925,7 +5925,7 @@ export const RULE_TOPICS: RuleTopic[] = [ summary: 'A development preview connects Great Maker, six Discovery spice blows, private token inspection, stash rewards, revealed locations, next-turn entry, Cistern income, bounded Orgiz transfers, Ornithopter movement, Jacurutu income, Testing Station and Shrine. Supported public starts remain previews; remaining interpretations and complete-mode acceptance stay open.', searchText: 'Hiereg Smuggler Jacurutu Sietch Cistern Ecological Testing Station Shrine Orgiz Processing Station Treachery Card Stash Spice Stash Ornithopter', steps: [ - 'The Discovery-only fresh preview supports classics, selected Ixian/Tleilaxu/CHOAM/Richese families, or Ecaz and/or Moritani with classics, Basic/Advanced2–6, seven extra Spice Cards/eight tokens, optional unused Tech3+ and Advanced Strongholds. The native E3 pair no longer requires Nexus or independent cards. Mixed E3 families and complete-mode acceptance remain separate.', + 'The Discovery-only fresh preview supports classics and selected Ixian/Tleilaxu, CHOAM/Richese and Ecaz/Moritani decks in Basic/Advanced2–6, including mixed selections with unused decks. It supplies seven extra Spice Cards/eight tokens; optional Tech requires3+ and Strongholds require Advanced. Nexus and independent cards are not required. Existing Advanced Moritani/Harkonnen and deeper interaction restrictions remain; complete-mode acceptance stays separate.', 'Fresh Discovery retains original Homeworlds and native reserves in classic and supported E1/E2 or E3 tables, Basic/Advanced2–6, optional Tech3+/Advanced Strongholds. Original Nexus entries additionally admit natives from BOTH Ix+CHOAM families/union47 or BOTH Ecaz+Moritani/ecaz33 with classics, with or without all14 Skills. Maker, actual parent/nested entry, source-local payments/rescue, phase-end industry and original-winner cleanup/Tech remain. Held benefits do not migrate into nested locations. Original capture/roster and unresolved-effect guards remain.', 'The original leader-skills --nexus-cards --discoveries entry composes all14 offered training/all12 Nexus/Discovery7/8 for classics/base33, single or paired one-family E1/E2, natives from BOTH selected Ix+CHOAM families/union47, or standalone OR paired Ecaz/Moritani/ecaz33 with classics. Original Homeworlds may be retained; Tech requires3+ and Strongholds Advanced. Hands/offers, native components and actual Maker/both-pile/alliance-change closing draws remain authoritative. Shared Duke never trains; Advanced paired E3/Moritani excludes Harkonnen. Mixed E3/three-family and pending effects/public starts/save conversion remain separate.', 'Connected native outcomes use original sources: Suboid Cunning and winning trained Suk settle typed fixed casualties before one equal actual Cyborg Tank substitution; original cleanup and mandatory winner Tech precede matching Face Dance, retaining its foreign-Homeworld suppression. Signed Richese two-marker one-invoice physical shipment requires a currently revealed nested site. Ecaz-selected coalition armies and Moritani skill-first assassination remain distinct from shared-Duke training. These programmes do not certify every skill or card band.', @@ -5972,8 +5972,8 @@ export const RULE_TOPICS: RuleTopic[] = [ }, { area: 'Verification', status: 'Partial', - detail: 'Paired E3 Discovery without Nexus or cards passes twelve related files and 77 cases, including public Basic/Advanced starts, Discovery blows and native Duke/Robbery entry with controlled physical tokens and Spice order. Independent Discovery adds frozen15-file118/118, types/lint/build and six original-action/rendered-control programmes; broader modes, visual/deployed acceptance and final assurance remain open. Current Collection batch passes80/80 in6 related files, types/lint and build. Genuine Basic/Advanced cases cover shared equal/full/zero splits, acceptance timing, wrong actors and stale events; helper boundaries cover multiple deposits, exhausted recipients, self/zero-share exclusion and cumulative overflow. Actual390px Basic Red Chasm lot4 changes Ecaz7/Guild8 to8/11 with one transfer and Ready restored, no overflow or errors. Four legal policies complete that Basic allocation via actual actions. Earlier canonical-source and Jacurutu/Station evidence remains source-bound; combinations, assurance, strategy and deployed acceptance remain open.', - evidence: ['tests/paired-e3-discovery-only-runtime.test.ts', 'tests/fixture-discovery-no-field-entry.ts', 'tests/discovery-no-field-entry-engine.test.ts', 'tests/discovery-no-field-entry-quote.test.ts', 'tests/discovery-no-field-entry-controls.test.tsx', 'tests/fixture-discovery-no-field-blow.ts', 'tests/discovery-no-field-blow-engine.test.ts', 'tests/discovery-no-field-blow-preflight.test.ts', 'tests/independent-discovery-nexus-entry.test.ts', 'tests/independent-discovery-cards.test.ts', 'tests/independent-discovery-battles.test.ts', 'tests/mixed-nexus-modules-runtime.test.ts', 'tests/paired-e3-nexus-modules-runtime.test.ts', 'tests/sample-custody.test.ts', 'tests/ambassador-terror-overlap-engine.test.ts', 'tests/e3-nexus-ecaz-runtime.test.ts', 'tests/e3-nexus-moritani-runtime.test.ts', 'tests/single-nexus-e1-runtime.test.ts', 'tests/single-nexus-e2-runtime.test.ts', 'tests/homeworld-paired-nexus-runtime.test.ts', 'tests/homeworld-standalone-nexus-runtime.test.ts', + detail: 'Mixed selected-deck Discovery without Nexus or cards passes thirteen related files and 82 cases, including public Basic/Advanced starts, Ixian shipment, Discovery blows and native Duke/Robbery entry with controlled physical tokens and Spice order. Independent Discovery adds frozen15-file118/118, types/lint/build and six original-action/rendered-control programmes; broader modes, visual/deployed acceptance and final assurance remain open. Current Collection batch passes80/80 in6 related files, types/lint and build. Genuine Basic/Advanced cases cover shared equal/full/zero splits, acceptance timing, wrong actors and stale events; helper boundaries cover multiple deposits, exhausted recipients, self/zero-share exclusion and cumulative overflow. Actual390px Basic Red Chasm lot4 changes Ecaz7/Guild8 to8/11 with one transfer and Ready restored, no overflow or errors. Four legal policies complete that Basic allocation via actual actions. Earlier canonical-source and Jacurutu/Station evidence remains source-bound; combinations, assurance, strategy and deployed acceptance remain open.', + evidence: ['tests/mixed-discovery-only-runtime.test.ts', 'tests/paired-e3-discovery-only-runtime.test.ts', 'tests/fixture-discovery-no-field-entry.ts', 'tests/discovery-no-field-entry-engine.test.ts', 'tests/discovery-no-field-entry-quote.test.ts', 'tests/discovery-no-field-entry-controls.test.tsx', 'tests/fixture-discovery-no-field-blow.ts', 'tests/discovery-no-field-blow-engine.test.ts', 'tests/discovery-no-field-blow-preflight.test.ts', 'tests/independent-discovery-nexus-entry.test.ts', 'tests/independent-discovery-cards.test.ts', 'tests/independent-discovery-battles.test.ts', 'tests/mixed-nexus-modules-runtime.test.ts', 'tests/paired-e3-nexus-modules-runtime.test.ts', 'tests/sample-custody.test.ts', 'tests/ambassador-terror-overlap-engine.test.ts', 'tests/e3-nexus-ecaz-runtime.test.ts', 'tests/e3-nexus-moritani-runtime.test.ts', 'tests/single-nexus-e1-runtime.test.ts', 'tests/single-nexus-e2-runtime.test.ts', 'tests/homeworld-paired-nexus-runtime.test.ts', 'tests/homeworld-standalone-nexus-runtime.test.ts', 'tests/fixture-jacurutu-mixed-dial.ts', 'tests/jacurutu-mixed-dial-runtime.test.ts', 'tests/fixture-testing-station-contest.ts', 'tests/testing-station-contest-runtime.test.ts', 'tests/fixture-discovery-occupied-collection.ts', 'tests/discovery-occupied-collection-runtime.test.ts', 'tests/fixture-discovery-shared-orgiz.ts', 'tests/discovery-shared-orgiz-runtime.test.ts', 'tests/board-resolution-quote.test.ts', 'tests/ecaz-collection-quote.test.ts', diff --git a/tests/discovery-module-profile.test.ts b/tests/discovery-module-profile.test.ts index 77daf992..cd01df8d 100644 --- a/tests/discovery-module-profile.test.ts +++ b/tests/discovery-module-profile.test.ts @@ -17,7 +17,7 @@ void test('Discovery requires the selected native family and does not admit unsu const unsupported = [ lobby(['ixians', 'guild'], []), lobby(['richese', 'guild'], ['ix']), - lobby(['ecaz', 'ixians', 'guild'], ['ecaz', 'ix']), + lobby(['ixians', 'guild'], ['ecaz']), lobby(['moritani', 'harkonnen', 'guild'], ['ecaz']), ]; for (const game of unsupported) assert.throws(() => initializeDiscoveryGameForAudit(game), RuleError); @@ -35,6 +35,21 @@ void test('Discovery requires the selected native family and does not admit unsu assert.equal(basic.discoveries?.tokens.length, 8); }); +void test('Discovery accepts mixed selected decks without requiring a native seat from each', () => { + for (const advanced of [false, true]) for (const expansions of [ + ['ecaz','ix'], ['ecaz','choam'], ['ecaz','ix','choam'], + ]) { + const game = lobby(['ecaz','moritani','guild'], expansions, advanced); + const started = initializeDiscoveryGameForAudit(game); + assert.equal(started.discoveries?.tokens.length, 8); + assert.equal(started.nexusCards, undefined); + assert.equal(started.ecazTreachery, undefined); + assert.ok(initializeDiscoveryGameForAudit(lobby(['guild','atreides'], expansions, advanced)).discoveries); + } + assert.throws(() => initializeDiscoveryGameForAudit( + lobby(['ecaz','moritani','harkonnen'], ['ecaz','ix'], true)), RuleError); +}); + void test('Discovery Tech requires three seats and untouched physical tokens', () => { const two = lobby(['ixians', 'tleilaxu'], ['ix']); two.techTokens = createTechTokens(); assert.throws(() => initializeDiscoveryGameForAudit(two), RuleError); diff --git a/tests/fixture-mixed-discovery-only.ts b/tests/fixture-mixed-discovery-only.ts new file mode 100644 index 00000000..09f80e94 --- /dev/null +++ b/tests/fixture-mixed-discovery-only.ts @@ -0,0 +1,49 @@ +import assert from 'node:assert/strict'; +import { createGame, joinGame, newPlayer, type Action } from '../game/engine'; +import { placeAmbassador } from '../game/ecaz-ambassadors'; +import { placeTerror } from '../game/moritani-terror'; +import { actBasicSemutaAmbassador, advanceBasicSemutaAmbassador, + basicSemutaAmbassadorClean, basicSemutaAmbassadorPlayer } from './fixture-basic-semuta-ambassador'; + +export const act = actBasicSemutaAmbassador; +export const player = basicSemutaAmbassadorPlayer; +export const advance = advanceBasicSemutaAmbassador; + +/** Public mixed-family lobby and native setup. Only the unopened Spice order + * and the original Ambassador/Terror token placements are controlled; no + * resources, force positions, decision or phase are staged. */ +export function mixedDiscoveryOnlyFixture(advanced: boolean, active: 'guild' | 'ixians') { + let game = createGame('MIXEDDISCOVERY', newPlayer('ecaz', 'Ecaz', 'ecaz'), advanced, ['ecaz', 'ix', 'choam']); + for (const faction of ['moritani', 'ixians', 'choam', 'guild'] as const) + joinGame(game, newPlayer(faction, faction, faction)); + game = act(game, 'ecaz', {type:'moduleOption', module:'kullPreview', enabled:false}); + game = act(game, 'ecaz', {type:'moduleOption', module:'discoveries', enabled:true}); + for (const seat of game.players) game = act(game, seat.id, {type:'ready'}); + const lobby = structuredClone(game); + game = act(game, 'ecaz', {type:'start', ...(advanced ? {advancedPreview:true} : {})}); + const setup = structuredClone(game); + game = advance(game, state => state.status === 'playing'); + assert.equal(game.advanced, advanced); + assert.ok(game.discoveries && game.ecazAmbassadors && game.moritaniTerror); + assert.ok(!game.nexusCards && !game.ecazTreachery && !game.leaderSkills); + for (const position of advanced ? [0, 1] : [0]) { + const index = game.spiceDeck.findIndex((card, i) => i >= position && 'territory' in card && + (position === 0 ? card.discovery === 'discovery-hagga-basin' : !card.discovery)); + assert.ok(index >= position); + [game.spiceDeck[position], game.spiceDeck[index]] = [game.spiceDeck[index], game.spiceDeck[position]]; + } + game = advance(game, state => state.turn === 1 && state.phase === 5 && + state.active === active && basicSemutaAmbassadorClean(state)); + const beforeMarkers = structuredClone(game); + const token = game.ecazAmbassadors!.tokens.find(row => row.effect === 'ecaz' && row.zone === 'supply'); + const terror = game.moritaniTerror!.tokens.find(row => row.kind === 'robbery' && row.status === 'available'); + assert.ok(token && terror); + const destination = 'habbanya_ridge_sietch', sector = 17; + game.ecazAmbassadors = placeAmbassador(game.ecazAmbassadors!, token.id, { + turn:game.turn, availableSpice:player(game,'ecaz').spice, + destination:{id:destination,stronghold:true,inStorm:false,allowed:true}, + }).state; + game.moritaniTerror = placeTerror(game.moritaniTerror!, terror.id, destination, game.turn); + const shipment: Action = {type:'ship', territory:destination, sector, amount:1, elite:0, allyPayment:0}; + return {game, lobby, setup, beforeMarkers, destination, sector, token:token.id, terror:terror.id, shipment}; +} diff --git a/tests/mixed-discovery-only-runtime.test.ts b/tests/mixed-discovery-only-runtime.test.ts new file mode 100644 index 00000000..022530e0 --- /dev/null +++ b/tests/mixed-discovery-only-runtime.test.ts @@ -0,0 +1,82 @@ +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 { reserveShipmentCost } from '../game/shipment-price'; +import { act, advance, mixedDiscoveryOnlyFixture, player } from './fixture-mixed-discovery-only'; + +for (const advanced of [false, true]) void test( + `${advanced ? 'Advanced' : 'Basic'} selected E3, Ix and CHOAM Discovery opens its native paired entry`, () => { + const f = mixedDiscoveryOnlyFixture(advanced, 'guild'); + assert.equal(f.lobby.discoveryEnabled, true); + assert.ok(f.setup.discoveries); + assert.equal(f.setup.discoveries!.tokens.length, 8); + assert.equal(f.setup.spiceDeck.filter(card => 'discovery' in card && card.discovery).length, 6); + assert.ok(!f.setup.nexusCards && !f.setup.ecazTreachery); + 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(player(f.game, 'ixians').hand.length > 0, 'The native Ixian setup dealt its original card'); + assert.ok(f.game.mobileStronghold, 'The original Ixian mobile stronghold exists'); + assert.ok(player(f.game, 'choam'), 'CHOAM remains a real native faction in this configuration'); + const price = reserveShipmentCost({faction:'guild', halfRate:true}, 'stronghold', 1); + const originalSpice = player(f.game, 'guild').spice; + const moritaniSpice = player(f.game, 'moritani').spice; + const stolen = Math.ceil((originalSpice - price) / 2); + const duke = structuredClone(f.game.dukeVidal!.leader); + let game = act(f.game, 'guild', f.shipment); + game = advance(game, state => !!state.pendingArrivalOverlap); + assert.equal(player(game, 'guild').spice, originalSpice - price); + 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); + } + if (first === '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'}); + assert.equal(game.pendingTerrorEntry?.token, f.terror); + game = act(game, 'moritani', {type:'decision', reveal:true}); + game = act(game, 'moritani', {type:'decision', choice:'spice'}); + } else { + assert.equal(game.pendingTerrorEntry?.token, f.terror); + game = act(game, 'moritani', {type:'decision', reveal:true}); + game = act(game, 'moritani', {type:'decision', choice:'spice'}); + 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'}); + } + assert.equal(game.pendingArrivalOverlap ?? null, null); + assert.equal(game.pendingAmbassador ?? null, null); + assert.equal(game.pendingTerrorEntry ?? null, null); + assert.equal(player(game, 'guild').spice, originalSpice - price - 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); + }); + +for (const advanced of [false, true]) void test( + `${advanced ? 'Advanced' : 'Basic'} mixed Discovery retains an actual Ixian shipment`, () => { + const f = mixedDiscoveryOnlyFixture(advanced, 'ixians'); + const before = player(f.game, 'ixians'); + const spice = before.spice, reserves = before.reserves; + const eliteReserves = before.elites?.reserves ?? 0; + let game = act(f.game, 'ixians', {type:'ship', territory:'polar_sink', sector:0, amount:1, + elite:eliteReserves > 0 ? 1 : 0}); + game = advance(game, state => !state.response && !state.decision && !state.phaseOpening); + assert.equal(player(game, 'ixians').reserves, reserves - 1); + assert.equal(player(game, 'ixians').spice, spice - 2); + assert.equal(player(game, 'ixians').forces['polar_sink:0'], 1); + if (eliteReserves > 0) assert.equal(player(game, 'ixians').elites!.reserves, eliteReserves - 1); + assert.ok(game.discoveries && game.mobileStronghold); + assert.ok(!game.nexusCards && !game.ecazTreachery); + });