From 4fba4860e1f61a6d4228bfcf8a899fb4cd32799a Mon Sep 17 00:00:00 2001 From: Quintine <15965533+Quintine@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:31:43 +1100 Subject: [PATCH] Support Basic Kull and Leader Skills with Ecaz --- docs/CHOAM_KULL_SOURCE_UPDATE.md | 18 +++ docs/CURRENT_STATUS.md | 10 ++ game/bureaucrat-payment.ts | 4 +- game/engine.ts | 30 ++++- game/faction-module-profile.ts | 30 +++++ game/kull-default-profile.ts | 4 +- game/leader-skill-profile.ts | 5 +- game/reference.ts | 2 +- tests/kull-leader-skills.test.ts | 170 +++++++++++++++++++++++++++ tests/kull-skills-profile.test.ts | 62 ++++++++++ tests/nexus-kull-skills-ecaz.test.ts | 93 +++++++++++++++ 11 files changed, 415 insertions(+), 13 deletions(-) create mode 100644 tests/kull-leader-skills.test.ts create mode 100644 tests/kull-skills-profile.test.ts create mode 100644 tests/nexus-kull-skills-ecaz.test.ts diff --git a/docs/CHOAM_KULL_SOURCE_UPDATE.md b/docs/CHOAM_KULL_SOURCE_UPDATE.md index 6bd11ecf..807097ec 100644 --- a/docs/CHOAM_KULL_SOURCE_UPDATE.md +++ b/docs/CHOAM_KULL_SOURCE_UPDATE.md @@ -2,6 +2,24 @@ Checked 2026-09-07 for classic GF9 Dune and CHOAM & Richese; preview policy and source-aware Nexus cost boundary updated 30 September 2026. This supplements [CHOAM_KULL_DESIGN.md](CHOAM_KULL_DESIGN.md), [native CHOAM Cunning](NEXUS_CHOAM_RULES.md) and the Kull section of [CHOAM_REMAINING_RULES.md](CHOAM_REMAINING_RULES.md). The source audit itself did not change runtime behavior; later opt-in development implementations follow the explicit selections below. This update does not claim a newly fetched publisher ruling. +## Basic printed Kull with Leader Skills — 16 November 2026 + +**Prototyped / Partial.** A supported fresh Basic CHOAM game with selected Ix +and CHOAM decks can explicitly combine printed Kull and Leader Skills without +Nexus, with an optional Ecaz deck and independent Ecaz Treachery cards. The +original physical skill deck and training, native faction stock, printed Kull +reaction and applicable Richese Semuta continuation remain connected. No new +timing ruling is implied. Tech Tokens and other optional modules retain their +separate admission boundaries. The host must explicitly select Kull when these +extra options disable its automatic default. + +Ecaz's ordinary allied Occupy composition also accepts the supported Basic +Kull/Skills profile, both with and without Nexus or independent Ecaz cards. +The genuine-start tests train skills, form a real alliance and reach the real +coalition battle and lead choice; board positions are staged conservatively. +Other faction and skill interactions, complete games and deployed acceptance +remain open. + ## Advanced specific-effect scope — 18 October 2026 The authorized supplied Advanced rulebook, physical29/logical27, describes diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index 0e21da35..b7944900 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -17,6 +17,16 @@ open mode gates. ## Current checkpoint and work +**Basic printed Kull and Leader Skills — 16 November. Prototyped / Partial.** +Supported public starts may explicitly select both without Nexus, with optional +independent Ecaz cards. Actual skill training, printed Kull and Richese Semuta +claim/pass on Recruits remain connected. Basic Ecaz Occupy also accepts the +Kull/Skills combination with or without Nexus or independent cards; real +alliance and coalition battle/lead choices are exercised with staged positions. +Eleven related files pass 92 cases. Wider skill interactions, other optional +modules, full games and deployed acceptance remain open. +[Scope](CHOAM_KULL_SOURCE_UPDATE.md#basic-printed-kull-with-leader-skills--16-november-2026). + **Basic Nexus Kull with Leader Skills — 16 November. Prototyped / Partial.** Supported starts retain original Nexus, Kull, skill cards and optional Ecaz cards. Genuine setup and skill assignment, an earned Kull reaction, all four diff --git a/game/bureaucrat-payment.ts b/game/bureaucrat-payment.ts index 2d285e1b..1526d030 100644 --- a/game/bureaucrat-payment.ts +++ b/game/bureaucrat-payment.ts @@ -1,6 +1,6 @@ import { homeworldLeaderSkillsProfile, independentTreacheryLeaderSkillsProfile, classicNexusLeaderSkillsProfile, classicTechLeaderSkillsProfile, guildBetrayalNexusLeaderSkillsProfile, mixedE1E2NexusLeaderSkillsProfile, mixedE3NexusLeaderSkillsProfile, nativeDiscoveryLeaderSkillsProfile, nativeExpansionLeaderSkillsProfile, nativeTechLeaderSkillsProfile, noOtherLeaderSkillModules, pairedE3NexusLeaderSkillsProfile, pairedNexusLeaderSkillsProfile, selectedNexusLeaderSkillsProfile, standaloneE3NexusLeaderSkillsProfile, strongholdLeaderSkillsProfile, type LeaderSkillProfile } from './leader-skill-profile'; import { classicDiscoveryLeaderSkillsProfile } from './discovery-module-profile'; -import { nexusKullLeaderSkillsProfile } from './faction-module-profile'; +import { basicKullLeaderSkillsProfile, nexusKullLeaderSkillsProfile } from './faction-module-profile'; export type BureaucratPaymentKind = 'auction' | 'shipment' | 'bribe' | 'revival'; export type BureaucratPaymentSource = { event: string; @@ -44,7 +44,7 @@ export function bureaucratPaymentSignature(value: object): string { return JSON.stringify({ ...value, signature: undefined }); } export function bureaucratPaymentModeSupported(game: LeaderSkillProfile): boolean { - return nexusKullLeaderSkillsProfile(game) || independentTreacheryLeaderSkillsProfile(game) || (!game.homeworlds && game.expansions.length === 1 && + return basicKullLeaderSkillsProfile(game) || nexusKullLeaderSkillsProfile(game) || independentTreacheryLeaderSkillsProfile(game) || (!game.homeworlds && game.expansions.length === 1 && (game.expansions[0] === 'choam' || game.expansions[0] === 'ix') && pairedNexusLeaderSkillsProfile(game)) || selectedNexusLeaderSkillsProfile(game) || mixedE3NexusLeaderSkillsProfile(game) || mixedE1E2NexusLeaderSkillsProfile(game) || pairedE3NexusLeaderSkillsProfile(game) || diff --git a/game/engine.ts b/game/engine.ts index 7789c958..0f00176f 100644 --- a/game/engine.ts +++ b/game/engine.ts @@ -102,7 +102,7 @@ import { movementShipmentPreparations } from './movement-shipment-preparation'; import { MovementClaimError, liveMovementPromises, movementEventAllowed, movementPromiseModeSupported, movementPromiseTargetAvailable, settleMovementEvent, finishMovementPromises, validMovementClaim, type MovementClaim, type MovementPromise } from './movement-promises'; import { findMovementCompletion, type MovementCompletion } from './movement-promise-search'; import { classicNexusModulesProfile, mixedE1E2NexusProfile, mixedE3NexusProfile, pairedE3NexusProfile, pairedNexusModulesProfile, singleE1E2NexusProfile, standaloneE3NexusProfile } from './nexus-module-profile'; -import { independentDiscoveryProfile, independentNexusProfile, nexusCoreProfile, nativeFactionTechProfile, selectedDiscoverySkillsSemutaProfile, selectedDiscoveryWithoutCardsProfile, selectedFactionStrongholdProfile, selectedIndependentCardsProfile, selectedNexusWithoutCardsProfile, selectedPhaseModuleRoster } from './faction-module-profile'; +import { basicKullLeaderSkillsProfile, independentDiscoveryProfile, independentNexusProfile, nexusCoreProfile, nexusKullLeaderSkillsProfile, nativeFactionTechProfile, selectedDiscoverySkillsSemutaProfile, selectedDiscoveryWithoutCardsProfile, selectedFactionStrongholdProfile, selectedIndependentCardsProfile, selectedNexusWithoutCardsProfile, selectedPhaseModuleRoster } from './faction-module-profile'; import { homeworldOccupationLeaderSkillsProfile, homeworldOccupationModulesProfile, homeworldPhaseModulesProfile } from './homeworld-module-profile'; import { RevivalPromiseError, revivalPromiseModeSupported, liveRevivalPromises, recordPromisedRevival, revivalPromisesSatisfied, validateRevivalPromises, type RevivalClaim, type RevivalPromise } from './revival-promises'; @@ -7285,7 +7285,7 @@ function kullSemutaParentSupported(g: Game, frame?: NonNullable player.faction === 'choam' || player.faction === 'richese' || player.faction === 'ixians' || player.faction === 'tleilaxu' || g.expansions.includes('ecaz') && (player.faction === 'ecaz' || player.faction === 'moritani') || CLASSIC_FACTIONS[player.faction] === true) && - !options.leaderSkills && !g.nexusCards && !g.discoveryEnabled && - !g.homeworlds && (!g.techTokens || basicKullTechRoster(g) && !options.ecazTreachery) && !g.strongholdCards; + !g.nexusCards && !g.discoveryEnabled && + !g.homeworlds && (!g.techTokens || basicKullTechRoster(g) && !options.ecazTreachery && !options.leaderSkills) && !g.strongholdCards; requireRule(supportedBasic || advancedKullLobbyEligible(state), 'Kull preview needs CHOAM and Ix decks. Basic supports selected native factions, independent Ecaz Treachery Cards, or Tech Tokens with three to six CHOAM/classic factions. Advanced supports CHOAM and classic factions without optional modules.'); + if (options.leaderSkills) { + requireRule(supportedBasic, 'Kull with Leader Skills currently requires a supported Basic native roster without Tech Tokens.'); + if (options.ecazTreachery) g.ecazTreachery = true; + requireFreshBaseRuntime(g); + requireFreshFactionInventory(g); + const seed = structuredClone(g); + seed.leaderSkills = createLeaderSkills(random); + requireRule(basicKullLeaderSkillsProfile(seed), 'This Kull and Leader Skills composition is unavailable.'); + const initialized = initializeSetupGameForAudit(seed, false, false, false, false, true, false, true, seed.ecazTreachery === true); + initialized.kullPreview = true; + if (byFaction(initialized, 'richese')) initialized.semutaPreview = true; + if (byFaction(initialized, 'ecaz')) initialized.ecazOccupyPreview = true; + return initialized; + } if (options.ecazTreachery) { requireRule(supportedBasic, 'Kull with independent Ecaz cards currently needs the supported Basic native roster.'); const initialized = initializeEcazTreacheryGameForAudit(g); @@ -13742,6 +13759,7 @@ function initializeFactionExpansionsGame(state: Game, semuta = false): Game { return initialized; } function ecazOccupyCompositionSupported(g: Game): boolean { + if (byFaction(g, 'ecaz') && (basicKullLeaderSkillsProfile(g) || nexusKullLeaderSkillsProfile(g))) return true; if (homeworldPhaseModulesProfile(g) && byFaction(g, 'ecaz')) return true; // Native Basic uses the same physical coalition and selected decks. // Family/roster checks below remain authoritative; optional configurations @@ -13884,7 +13902,7 @@ function basicIndependentRecruitsSemutaProfile(g: Game): boolean { * Recruits reaction without combining the separate legacy preview markers. */ function independentRecruitsSemutaEnabled(g: Game): boolean { return g.semutaRecruitsPreview === true && basicIndependentRecruitsSemutaProfile(g) || - g.ecazTreachery === true && basicNexusKullSemutaProfile(g); + g.ecazTreachery === true && (basicNexusKullSemutaProfile(g) || basicKullSkillsSemutaProfile(g)); } function semutaCardProducerEnabled(g: Game): boolean { return g.semutaPreview === true || g.semutaRecruitsPreview === true && basicIndependentRecruitsSemutaProfile(g); diff --git a/game/faction-module-profile.ts b/game/faction-module-profile.ts index f6a03ecc..f7f445ba 100644 --- a/game/faction-module-profile.ts +++ b/game/faction-module-profile.ts @@ -117,6 +117,36 @@ function basicNativeNexusCore(game: NexusCoreConfiguration): boolean { return true; } +/** Basic Kull and physical Leader Skills without Nexus. The same public + * roster is used while the fresh setup is dealt and after Kull is stamped. */ +export function basicKullLeaderSkillsProfile(game: NexusCoreConfiguration): boolean { + const players = game.players; + if (game.advanced !== false || !game.leaderSkills || !players || + players.length < 2 || players.length > 6 || + (game.expansions.length !== 2 && game.expansions.length !== 3) || + !game.expansions.includes('ix') || !game.expansions.includes('choam') || + game.expansions.some(id => id !== 'ix' && id !== 'choam' && id !== 'ecaz') || + new Set(game.expansions).size !== game.expansions.length || + !players.some(player => player.faction === 'choam') || + game.nexusCards || game.nexusKullPreview || game.homeworlds || game.techTokens || + game.strongholdCards || game.discoveryEnabled || game.discoveries || + game.discoveryStash || game.greatMaker || game.advancedPreview || + game.guildBetrayalPreview || game.richeseBetrayalPreview || + game.nexusIxianReplacementPreview || game.nexusIxianBetrayalPreview || + game.nexusHarkonnenBetrayalPreview || game.moritaniAssassinatePreview || + (game.semutaPreview && (game.semutaPreview !== true || + !players.some(player => player.faction === 'richese'))) || + (game.kullPreview && game.kullPreview !== true)) return false; + const factions = new Set(); + for (const player of players) { + if (factions.has(player.faction)) return false; + factions.add(player.faction); + const faction = FACTIONS.find(candidate => candidate.id === player.faction); + if (!faction || (faction.expansion !== 'base' && !game.expansions.includes(faction.expansion))) return false; + } + return true; +} + /** Basic Nexus/Kull with original Leader Skills. Recognize the fresh setup * before its Kull stamps and live games after both stamps alike. */ export function nexusKullLeaderSkillsProfile(game: NexusCoreConfiguration): boolean { diff --git a/game/kull-default-profile.ts b/game/kull-default-profile.ts index ba8e532f..b634a68f 100644 --- a/game/kull-default-profile.ts +++ b/game/kull-default-profile.ts @@ -64,7 +64,7 @@ export function kullDefaultProfile(game: KullDefaultProfile): KullDefaultEligibi projected?.ecazTreachery || projected?.discoveries || game.leaderSkills || game.ecazTreachery || game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker || game.homeworlds || game.techTokens || game.strongholdCards || game.sandtrout) - return blocked('Kull with Nexus currently requires Basic rules, the Ix and CHOAM decks and no other optional modules; the Ecaz deck may also be selected.'); + return blocked('Automatic Kull is unavailable for this Nexus combination. Select Kull explicitly if the chosen modules support it.'); return { eligible: true, reason: null }; } if (options?.leaderSkills || projected?.leaderSkills || @@ -72,7 +72,7 @@ export function kullDefaultProfile(game: KullDefaultProfile): KullDefaultEligibi game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker || game.homeworlds || game.strongholdCards || (game.techTokens && (!basicKullTechRoster(game) || options?.ecazTreachery || projected?.ecazTreachery))) - return blocked('Automatic Kull supports independent Ecaz Treachery Cards, or Tech Tokens with three to six CHOAM/classic factions and the Ix and CHOAM decks.'); + return blocked('Automatic Kull is unavailable for this combination. Select Kull explicitly if the chosen modules support it.'); return { eligible: true, reason: null }; } diff --git a/game/leader-skill-profile.ts b/game/leader-skill-profile.ts index 834ea02d..557cde39 100644 --- a/game/leader-skill-profile.ts +++ b/game/leader-skill-profile.ts @@ -1,5 +1,5 @@ import { FACTIONS } from './catalog'; -import { independentDiscoveryProfile, independentNexusProfile, classicNexusCoreProfile, nexusCoreProfile, nexusKullLeaderSkillsProfile, mixedE3NexusRosterProfile, selectedNexusWithoutCardsProfile } from './faction-module-profile'; +import { independentDiscoveryProfile, independentNexusProfile, classicNexusCoreProfile, nexusCoreProfile, basicKullLeaderSkillsProfile, nexusKullLeaderSkillsProfile, mixedE3NexusRosterProfile, selectedNexusWithoutCardsProfile } from './faction-module-profile'; import { classicDiscoveryLeaderSkillsProfile, selectedDiscoveryLeaderSkillsProfile } from './discovery-module-profile'; /** Public configuration only; never gate a skill on a hidden card or random deal. */ @@ -498,6 +498,7 @@ export function homeworldLeaderSkillsProfile(game: LeaderSkillProfile): boolean /** Independent cards with registered selected-family all14 setup and original module/role guards. */ export function independentTreacheryLeaderSkillsProfile(game: LeaderSkillProfile): boolean { + if (game.ecazTreachery === true && basicKullLeaderSkillsProfile(game)) return true; if (independentNexusProfile(game) || independentDiscoveryProfile(game)) return true; if (game.ecazTreachery !== true || game.expansions.length > 3 || typeof game.advanced !== 'boolean' || !game.players || @@ -534,7 +535,7 @@ export function independentTreacheryLeaderSkillsProfile(game: LeaderSkillProfile /** Shared by rule quotes, controls and minimal legal bot participation. */ export function ordinaryLeaderSkillModeSupported(game: LeaderSkillProfile): boolean { - return nexusKullLeaderSkillsProfile(game) || independentTreacheryLeaderSkillsProfile(game) || (noOtherLeaderSkillModules(game) && + return basicKullLeaderSkillsProfile(game) || nexusKullLeaderSkillsProfile(game) || independentTreacheryLeaderSkillsProfile(game) || (noOtherLeaderSkillModules(game) && (!game.expansions.length || nativeExpansionLeaderSkillsProfile(game) || (game.expansions.length === 1 && game.expansions[0] === 'choam'))) || classicTechLeaderSkillsProfile(game) || nativeTechLeaderSkillsProfile(game) || diff --git a/game/reference.ts b/game/reference.ts index ccf61a9a..6a9b1f73 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -4927,7 +4927,7 @@ export const RULE_TOPICS: RuleTopic[] = [ developmentStage: 'Prototyped', summary: 'React before a Karama is played; a distinct counter can stop Kull before its phase restriction begins.', steps: [ - 'In a new supported Basic lobby with CHOAM and the CHOAM and Ix decks, printed Kull is enabled by default as a development preview. The host may turn it off to keep the broader non-Kull Truthtrance options. Basic supports Richese, Ixians, Tleilaxu, Ecaz, Moritani and classic factions with each seated faction’s deck, optionally with independent Ecaz Treachery Cards. Tech Tokens are separately supported with three to six CHOAM and classic factions; other optional modules are excluded. In an Advanced preview lobby, the host may explicitly select printed Kull with CHOAM, classic factions and exactly the CHOAM and Ix decks, without optional modules. Advanced supports Bene Gesserit substitutions and legal special powers. Both previews withhold some structured questions and defer unfunded non-CHOAM Karama-dependent bids. Existing games are not retrofitted, and this warning does not certify complete rules.', + 'In a new supported Basic lobby with CHOAM and the CHOAM and Ix decks, printed Kull is enabled by default as a development preview. The host may turn it off to keep the broader non-Kull Truthtrance options. Basic supports Richese, Ixians, Tleilaxu, Ecaz, Moritani and classic factions with each seated faction’s deck, optionally with independent Ecaz Treachery Cards. The host may explicitly select Kull alongside Leader Skills, with or without those independent cards. Tech Tokens are separately supported with three to six CHOAM and classic factions; other optional modules are excluded. In an Advanced preview lobby, the host may explicitly select printed Kull with CHOAM, classic factions and exactly the CHOAM and Ix decks, without optional modules. Advanced supports Bene Gesserit substitutions and legal special powers. Both previews withhold some structured questions and defer unfunded non-CHOAM Karama-dependent bids. Existing games are not retrofitted, and this warning does not certify complete rules.', 'In supported Basic games with independent Ecaz Treachery Cards and Richese, Semuta may claim the discarded successful Kull, a distinct Karama counter, or the original shipment Karama when Kull declines. The original attempt continues under its existing rules; other nested reactions remain incomplete.', 'In the supported Basic printed Kull preview, simple and mixed current-lot ordinary bid, phase-wide bid, ordinary bribe, Revival and alliance questions are available, including with Richese and Semuta. Combined turn-action questions are also available in supported profiles. Some structured questions remain unavailable when Tech Tokens are selected. A pending Kull response holds their controls while the original transaction resolves; some Karama uses remain guarded. Kull and Semuta also retain a paid ordinary or cache sale when Karama targets Harkonnen’s bonus or Emperor income, and an ordinary sale when it targets an Ixian ally’s replacement. Wider interactions remain incomplete.', 'Another player’s legal Karama cancellation, shipment-rate use, immediate auction purchase, winning-bid payment or supported special activation pauses before its card and other costs. CHOAM sees the attempted player and purpose and may decline or choose a legal held Kull Wahad. Each Use names its printed source explicitly. The separate Nexus Kull guide covers additional Cunning costs in its new profile only. The same public opportunity appears without Kull in hand, so waiting does not disclose hidden ownership. Invalid attempts never open this window; CHOAM does not receive a self-targeted Kull offer.', diff --git a/tests/kull-leader-skills.test.ts b/tests/kull-leader-skills.test.ts new file mode 100644 index 00000000..c471ee2d --- /dev/null +++ b/tests/kull-leader-skills.test.ts @@ -0,0 +1,170 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { + applyAction, createGame, joinGame, newPlayer, normalizeAutomaticGame, viewGame, + type Action, type Game, +} from '../game/engine'; +import { LEADER_SKILL_CARDS } from '../game/leader-skill-cards'; +import { validateLeaderSkills } from '../game/leader-skills'; +import { botActions } from '../game/bots'; +import { DIFFICULTIES } from '../game/bot-profiles'; +import { SEMUTA_DRUG_ID } from '../game/semuta-drug'; +import { RECRUITS_CARD_ID } from '../game/recruits'; +import { takeKullCard } from './fixture-choam-kull'; +import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards'; +import { advanceSemutaNexusTrade, type SemutaNexusTradeStep } from './fixture-semuta-nexus-trade'; + +const act = (game: Game, actor: string, action: Action) => applyAction(game, actor, action); +function seat(game: Game, id: string) { + const player = game.players.find(candidate => candidate.id === id); + assert.ok(player); return player; +} +function inventory(game: Game) { + const ids = [ ...game.deck, ...game.discard, ...(game.auction?.cards.slice(game.auction.index) ?? []), + ...(game.ixAuction?.cards ?? []), ...(game.richeseCache ?? []), ...(game.richeseRemoved ?? []), + ...game.players.flatMap(player => player.hand) ].map(card => card.id).sort(); + assert.equal(new Set(ids).size, ids.length); return ids; +} +function skills(game: Game) { + assert.ok(game.leaderSkills); + validateLeaderSkills(game.leaderSkills, game.players); + assert.deepEqual([...game.leaderSkills.deck, + ...Object.values(game.leaderSkills.offers).flatMap(offer => offer.cards), + ...game.leaderSkills.assignments.map(row => row.skill)].sort(), + LEADER_SKILL_CARDS.map(card => card.id).sort()); +} +const clean = (game: Game) => !game.phaseOpening && !game.response && !game.decision && !game.truthtrance; + +/** Public Basic lobby and actual skill training. Only unopened Spice ordering + * and conserved held Treachery positions are staged before the Karama attempt. */ +function fixture(independent: boolean, richese = false) { + let game = createGame('KULLSKILLS', newPlayer('c', 'CHOAM', 'choam'), false, ['ix', 'choam', 'ecaz']); + for (const [id, faction] of [['a', 'atreides'], ['g', 'guild'], ['h', 'harkonnen']] as const) + joinGame(game, newPlayer(id, faction, faction)); + if (richese) joinGame(game, newPlayer('r', 'Richese', 'richese')); + for (const moduleName of [...(independent ? ['ecazTreachery'] : []), 'leaderSkills', 'kullPreview']) + game = act(game, 'c', { type: 'moduleOption', module: moduleName, enabled: true }); + const selected = viewGame(game, 'c').lobbyModules!; + assert.equal(selected.nexusCards, false); assert.equal(selected.leaderSkills, true); + assert.equal(selected.kullPreview, true); + if (independent) assert.equal(selected.ecazTreachery, true); + for (const player of game.players) game = act(game, player.id, { type: 'ready' }); + game = act(game, 'c', { type: 'start' }); + assert.equal(game.kullPreview, true); assert.ok(!game.nexusKullPreview && !game.nexusCards); + assert.equal(game.ecazTreachery === true, independent); + if (richese) { assert.equal(game.semutaPreview, true); assert.ok(game.richeseCache?.length); } + const setup: SemutaNexusTradeStep[] = []; + game = advanceSemutaNexusTrade(game, state => state.status === 'playing', setup); + assert.equal(setup.filter(row => row.action.type === 'leaderSkill').length, game.players.length); + assert.equal(game.leaderSkills!.assignments.length, game.players.length); + skills(game); + const originalSkills = structuredClone(game.leaderSkills), originalCards = inventory(game); + game = advanceSemutaNexusTrade(game, beforeIxSpiceDraw); + orderIxSpiceCards(game, ['land', 'land']); + game = advanceSemutaNexusTrade(game, state => state.phase === 5 && state.active === 'g' && clean(state)); + for (const player of game.players) game.deck.push(...player.hand.splice(0)); + const printed = takeKullCard(game, 'ix-kull-wahad'); seat(game, 'c').hand.push(printed); + const original = takeKullCard(game, 'karama'); seat(game, 'g').hand.push(original); + if (richese) seat(game, 'r').hand.push(takeKullCard(game, SEMUTA_DRUG_ID)); + assert.deepEqual(inventory(game), originalCards); + assert.deepEqual(game.leaderSkills, originalSkills); + game = act(game, 'g', { type: 'card', mode: 'shipment', card: original.id, target: 'g' }); + assert.ok(game.pendingKull); + return { game, printed: printed.id, original: original.id, event: game.pendingKull.event, originalCards, originalSkills }; +} + +function usePrinted(f: ReturnType) { + assert.ok(viewGame(f.game, 'c').kullReaction?.plays.some(play => play.source === 'printed' && play.card.id === f.printed)); + let game = act(f.game, 'c', { type: 'kullDecision', event: f.event, source: 'printed', card: f.printed }); + for (let n = 0; game.pendingKull && n < 20; n++) { + const responder = game.players.find(player => { + const controls = viewGame(game, player.id).responseControls; + return controls && !controls.hasPassed && controls.cancelCards.length > 0; + }); + game = responder ? act(game, responder.id, { type: 'passResponse' }) : normalizeAutomaticGame(game); + } + assert.equal(game.pendingKull, null); + assert.equal(seat(game, 'g').hand.some(card => card.id === f.original), true); + return game; +} + +for (const independent of [false, true]) void test( + `Basic public printed Kull retains trained Skills${independent ? ' and independent Ecaz cards' : ''}`, () => { + const f = fixture(independent); + for (const difficulty of DIFFICULTIES) { + const view = viewGame(f.game, 'c'); view.players.find(player => player.id === 'c')!.bot = difficulty; + const choice = botActions(view).find(action => action.type === 'kullDecision'); + assert.ok(choice); assert.doesNotThrow(() => act(f.game, 'c', choice)); + } + const game = usePrinted(f); + assert.equal(game.discard.filter(card => card.id === f.printed).length, 1); + assert.deepEqual(inventory(game), f.originalCards); + assert.deepEqual(game.leaderSkills, f.originalSkills); skills(game); + }, +); + +void test('Richese can claim printed Kull with Semuta and retain original Skills and cache', () => { + const f = fixture(true, true); + let game = usePrinted(f); + const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction); + assert.deepEqual(pending.batch.entries.map(entry => entry.card.id), [f.printed]); + assert.equal(viewGame(game, 'r').semutaReaction?.canCommit, true); + game = act(game, 'r', { type: 'semutaCommit', event: pending.batch.event }); + if (game.pendingTreacheryDiscard?.reaction?.stage === 'select') + game = act(game, 'r', { type: 'semutaSelect', event: pending.batch.event, card: f.printed }); + assert.equal(game.pendingTreacheryDiscard, null); + assert.ok(seat(game, 'r').hand.some(card => card.id === f.printed)); + assert.ok(game.discard.some(card => card.id === SEMUTA_DRUG_ID)); + assert.deepEqual(inventory(game), f.originalCards); + assert.deepEqual(game.leaderSkills, f.originalSkills); skills(game); +}); + +for (const claim of [false, true]) void test( + `Basic printed Kull and Skills retain Recruits while Richese ${claim ? 'claims' : 'passes'} with Semuta`, () => { + let game = createGame('KULLSKILLSRECRUITS', newPlayer('c', 'CHOAM', 'choam'), false, ['ix', 'choam']); + for (const [id, faction] of [['r', 'richese'], ['a', 'atreides'], ['g', 'guild']] as const) + joinGame(game, newPlayer(id, faction, faction)); + for (const moduleName of ['ecazTreachery', 'leaderSkills', 'kullPreview']) + game = act(game, 'c', { type: 'moduleOption', module: moduleName, enabled: true }); + for (const player of game.players) game = act(game, player.id, { type: 'ready' }); + game = act(game, 'c', { type: 'start' }); + assert.equal(game.ecazTreachery, true); + assert.equal(game.kullPreview, true); + assert.equal(game.semutaPreview, true); + assert.ok(game.leaderSkills && !game.nexusCards && !game.nexusKullPreview); + const setup: SemutaNexusTradeStep[] = []; + game = advanceSemutaNexusTrade(game, state => state.status === 'playing', setup); + assert.equal(setup.filter(row => row.action.type === 'leaderSkill').length, game.players.length); + game = advanceSemutaNexusTrade(game, beforeIxSpiceDraw); + orderIxSpiceCards(game, ['land', 'land']); + game = advanceSemutaNexusTrade(game, state => state.phase === 4 && clean(state) && !state.pendingTreacheryDiscard); + const originalCards = inventory(game), originalSkills = structuredClone(game.leaderSkills); + for (const id of ['a', 'r']) game.deck.push(...seat(game, id).hand.splice(0)); + seat(game, 'a').hand.push(takeKullCard(game, RECRUITS_CARD_ID)); + seat(game, 'r').hand.push(takeKullCard(game, SEMUTA_DRUG_ID)); + assert.deepEqual(inventory(game), originalCards); + const preview = viewGame(game, 'a').recruitsPreview?.play; + assert.ok(preview && !preview.blocked); + game = act(game, 'a', { type: 'card', card: RECRUITS_CARD_ID }); + const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction); + assert.equal(pending.continuation.kind, 'ordinaryCardDiscard'); + assert.deepEqual(pending.batch.entries.map(entry => entry.card.id), [RECRUITS_CARD_ID]); + assert.equal(game.recruits?.turn, game.turn); + if (claim) { + assert.equal(viewGame(game, 'r').semutaReaction?.canCommit, true); + game = act(game, 'r', { type: 'semutaCommit', event: pending.batch.event }); + if (game.pendingTreacheryDiscard?.reaction?.stage === 'select') + game = act(game, 'r', { type: 'semutaSelect', event: pending.batch.event, card: RECRUITS_CARD_ID }); + } else { + for (const player of game.players) game = act(game, player.id, { type: 'semutaPass', event: pending.batch.event }); + } + assert.equal(game.pendingTreacheryDiscard, null); + assert.equal(viewGame(game, 'a').revival.freeRemaining, 4); + assert.equal(viewGame(game, 'a').revival.limit, 7); + assert.equal(seat(game, 'r').hand.some(card => card.id === RECRUITS_CARD_ID), claim); + assert.equal(game.discard.some(card => card.id === RECRUITS_CARD_ID), !claim); + assert.equal(game.discard.some(card => card.id === SEMUTA_DRUG_ID), claim); + assert.deepEqual(inventory(game), originalCards); + assert.deepEqual(game.leaderSkills, originalSkills); skills(game); + }, +); diff --git a/tests/kull-skills-profile.test.ts b/tests/kull-skills-profile.test.ts new file mode 100644 index 00000000..b4ffe678 --- /dev/null +++ b/tests/kull-skills-profile.test.ts @@ -0,0 +1,62 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { basicKullLeaderSkillsProfile, type FactionModuleProfile } from '../game/faction-module-profile'; +import { independentTreacheryLeaderSkillsProfile, ordinaryLeaderSkillModeSupported } from '../game/leader-skill-profile'; +import { bureaucratPaymentModeSupported, quoteBureaucratPayment } from '../game/bureaucrat-payment'; +import { mentatQuestionModeSupported } from '../game/mentat-question'; +import { spiceBankerModeSupported } from '../game/spice-banker'; + +const original: FactionModuleProfile = { + advanced: false, + expansions: ['ix', 'choam', 'ecaz'], + players: [{ faction: 'choam' }, { faction: 'richese' }, { faction: 'ecaz' }], + leaderSkills: {}, +}; + +void test('Basic Kull and Skills retain public skill authority through setup and the live Kull stamp', () => { + for (const independent of [false, true]) for (const semuta of [false, true]) for (const stamped of [false, true]) { + const game = { ...original, ecazTreachery: independent, + ...(semuta ? { semutaPreview: true } : {}), + ...(stamped ? { kullPreview: true } : {}) }; + const label = `independent=${independent}, semuta=${semuta}, stamped=${stamped}`; + assert.equal(basicKullLeaderSkillsProfile(game), true, label); + assert.equal(independentTreacheryLeaderSkillsProfile(game), independent, label); + assert.equal(ordinaryLeaderSkillModeSupported(game), true, label); + assert.equal(mentatQuestionModeSupported(game), true, label); + assert.equal(spiceBankerModeSupported(game), true, label); + assert.equal(bureaucratPaymentModeSupported(game), true, label); + } +}); + +void test('Bureaucrat retains the ordinary amount threshold and phase limit', () => { + const game = { ...original, ecazTreachery: true, semutaPreview: true, kullPreview: true }; + assert.equal(bureaucratPaymentModeSupported(game), true); + const payment = { owner: 'ecaz', payer: 'choam', payee: 'richese', amount: 7, + turn: 2, phase: 3, used: [] }; + assert.deepEqual(quoteBureaucratPayment(payment), { redirect: 2, income: 5 }); + assert.equal(quoteBureaucratPayment({ ...payment, amount: 4 }), null); + assert.equal(quoteBureaucratPayment({ ...payment, + used: [{ event: 'used', owner: 'ecaz', turn: 2, phase: 3, signature: '' }] }), null); +}); + +void test('standalone Kull and Skills reject unrelated modules and unregistered rosters', () => { + const invalid: Array<[string, Partial]> = [ + ['Advanced', { advanced: true }], + ['missing Skills', { leaderSkills: null }], + ['Nexus', { nexusCards: {} }], + ['Nexus Kull stamp', { nexusKullPreview: true }], + ['no CHOAM seat', { players: [{ faction: 'richese' }, { faction: 'ecaz' }] }], + ['duplicate faction', { players: [{ faction: 'choam' }, { faction: 'choam' }] }], + ['unselected faction', { expansions: ['ix', 'choam'] }], + ['duplicate deck', { expansions: ['ix', 'choam', 'ix'] }], + ['missing Ix deck', { expansions: ['choam', 'ecaz'] }], + ['Homeworlds', { homeworlds: {} }], + ['Discovery', { discoveryEnabled: true }], + ['Tech', { techTokens: {} }], + ['Strongholds', { strongholdCards: {} }], + ['unrelated betrayal', { richeseBetrayalPreview: true }], + ['Semuta without Richese', { semutaPreview: true, players: [{ faction: 'choam' }, { faction: 'ecaz' }] }], + ]; + for (const [label, changes] of invalid) + assert.equal(basicKullLeaderSkillsProfile({ ...original, ...changes }), false, label); +}); diff --git a/tests/nexus-kull-skills-ecaz.test.ts b/tests/nexus-kull-skills-ecaz.test.ts new file mode 100644 index 00000000..c2774fd0 --- /dev/null +++ b/tests/nexus-kull-skills-ecaz.test.ts @@ -0,0 +1,93 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { applyAction, createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine'; +import { LEADER_SKILL_CARDS } from '../game/leader-skill-cards'; +import { validateLeaderSkills } from '../game/leader-skills'; +import { validateNexusCards } from '../game/nexus-cards'; +import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards'; +import { nextSemutaNexusTradeNativeStep } from './fixture-semuta-nexus-trade'; + +const act = (g: Game, id: string, action: Action) => applyAction(g, id, action); +const seat = (g: Game, id: string) => { const p = g.players.find(row => row.id === id); assert.ok(p); return p; }; +const clean = (g: Game) => !g.response && !g.phaseOpening && !g.decision && !g.truthtrance && !g.pendingTreacheryDiscard; +function reach(g: Game, until: (g: Game) => boolean) { + for (let i = 0; i < 2000; i++) { + if (until(g)) return g; + assert.notEqual(g.status, 'finished', `Game ended at ${g.turn}/${g.phase}: ${JSON.stringify(g.log.slice(-5))}`); + if (!g.response && !g.phaseOpening && g.decision?.kind === 'ecazPlacement') + g = act(g, g.decision.player, { type: 'decision', decline: true }); + else { + const next = nextSemutaNexusTradeNativeStep(g); + g = act(g, next.actor, next.action); + } + } + throw Error('Native Ecaz/Nexus/Kull/Skills progression did not reach its boundary'); +} +function inventory(g: Game) { + return [...g.deck, ...g.discard, ...(g.richeseCache ?? []), ...(g.richeseRemoved ?? []), + ...(g.auction?.cards.slice(g.auction.index) ?? []), ...(g.ixAuction?.cards ?? []), + ...g.players.flatMap(p => p.hand)].map(card => card.id).sort(); +} +function physicalSkills(g: Game) { + assert.ok(g.leaderSkills); validateLeaderSkills(g.leaderSkills, g.players); + const state = g.leaderSkills; + assert.deepEqual([...state.deck, ...Object.values(state.offers).flatMap(o => o.cards), + ...state.assignments.map(a => a.skill)].sort(), LEADER_SKILL_CARDS.map(c => c.id).sort()); + if (g.nexusCards) validateNexusCards(g.nexusCards.cards!, g.players); +} + +for (const nexus of [false, true]) for (const independent of [false, true]) void test( + `Public Basic Ecaz plays an Occupy battle with ${nexus ? 'Nexus ' : 'printed '}Kull and Skills${independent ? ' and independent Ecaz cards' : ''}`, () => { + let g = createGame('NEXUSKULLECAZ', newPlayer('c', 'CHOAM', 'choam'), false, ['ix', 'choam', 'ecaz']); + for (const [id, faction] of [['e', 'ecaz'], ['a', 'atreides'], ['g', 'guild']] as const) + joinGame(g, newPlayer(id, faction, faction)); + for (const name of [...(independent ? ['ecazTreachery'] : []), ...(nexus ? ['nexusCards'] : []), 'leaderSkills', 'kullPreview']) + g = act(g, 'c', { type: 'moduleOption', module: name, enabled: true }); + for (const p of g.players) g = act(g, p.id, { type: 'ready' }); + g = act(g, 'c', { type: 'start' }); + assert.equal(g.ecazOccupyPreview, true); + assert.equal(g.kullPreview, true); assert.equal(g.nexusKullPreview === true, nexus); + assert.equal(!!g.nexusCards, nexus); + assert.equal(g.ecazTreachery === true, independent); + g = reach(g, state => state.status === 'playing'); + assert.equal(g.leaderSkills!.assignments.length, g.players.length); + physicalSkills(g); + const cards = inventory(g); + // Controlled board staging conserves each faction's pieces; unopened Spice + // order produces the ordinary turn-two worm/alliance without assigning it. + for (const p of g.players) { + p.reserves += Object.values(p.forces).reduce((sum, n) => sum + n, 0); + p.forces = {}; + } + g = reach(g, beforeIxSpiceDraw); orderIxSpiceCards(g, ['land', 'land']); + g = reach(g, state => state.turn === 2 && beforeIxSpiceDraw(state)); + orderIxSpiceCards(g, ['worm', 'land', 'land']); + g = reach(g, state => !!state.nexus && !state.spiceWindow && clean(state)); + g = act(g, 'e', { type: 'alliance', target: 'a' }); + g = act(g, 'a', { type: 'alliance', target: 'e' }); + g = reach(g, state => state.turn === 2 && state.phase === 5 && clean(state)); + assert.equal(seat(g, 'e').ally, 'a'); assert.equal(seat(g, 'a').ally, 'e'); + const territory = g.storm === 11 ? 'arrakeen' : 'carthag'; + const sector = territory === 'carthag' ? 11 : 10; + const location = `${territory}:${sector}`; + for (const [id, amount] of [['e', 5], ['a', 4], ['g', 3]] as const) { + const p = seat(g, id); assert.ok(p.reserves >= amount); + p.reserves -= amount; p.forces[location] = amount; + } + g = reach(g, state => state.turn === 2 && state.phase === 6 && clean(state)); + const choice = viewGame(g, g.active!).battleChoices.find(row => row.territory === territory); + assert.ok(choice); + g = act(g, choice.chooser, { type: 'chooseBattle', territory, + target: choice.attacker === choice.chooser ? choice.defender : choice.attacker }); + g = reach(g, state => !state.response && !state.phaseOpening && state.decision?.kind === 'ecazBattleLead'); + assert.ok(g.decision?.kind === 'ecazBattleLead'); + const event = g.decision.event; + g = act(g, 'e', { type: 'decision', event, lead: 'e' }); + g = reach(g, state => !!state.battle && !state.battle.preparation && + state.battle.preLeader?.closed !== false && clean(state)); + const view = viewGame(g, 'e'); + assert.ok(view.battle?.ecazOccupy?.profile); + assert.equal(view.battle.ecazOccupy.profile.fixedEcazDial, 3); + physicalSkills(g); assert.deepEqual(inventory(g), cards); + }, +);