From 4270b36be75a21dfd3832bacfd5787b6780e6d5d Mon Sep 17 00:00:00 2001 From: Quintine <15965533+Quintine@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:23:53 +1100 Subject: [PATCH] Connect Nexus Skills and Advanced Ambassador markers --- docs/CURRENT_STATUS.md | 30 ++- docs/GUILD_AMBASSADOR_RULES.md | 22 ++ docs/NEXUS_CARD_RULES.md | 20 +- game/bureaucrat-payment.ts | 3 +- game/engine.ts | 18 +- game/faction-module-profile.ts | 30 ++- game/leader-skill-profile.ts | 4 +- game/reference.ts | 4 +- tests/fixture-nexus-module-payments.ts | 12 + tests/fixture-nexus-richese.ts | 25 +-- ...guild-ambassador-no-field-advanced.test.ts | 208 ++++++++++++++++++ tests/nexus-kull-leader-skills.test.ts | 148 +++++++++++++ tests/nexus-kull-skills-profile.test.ts | 68 ++++++ tests/nexus-module-payments-runtime.test.ts | 27 ++- 14 files changed, 578 insertions(+), 41 deletions(-) create mode 100644 tests/guild-ambassador-no-field-advanced.test.ts create mode 100644 tests/nexus-kull-leader-skills.test.ts create mode 100644 tests/nexus-kull-skills-profile.test.ts diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index 7a304124..0e21da35 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -17,17 +17,35 @@ open mode gates. ## Current checkpoint and work +**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 +bot levels and Richese Semuta have focused coverage. Broader skill interactions, +Advanced, full games and deployed acceptance remain open. +[Scope](NEXUS_CARD_RULES.md#basic-nexus-kull-with-leader-skills--16-november-2026). + +**Advanced Guild Ambassador No-Field — 16 November. Prototyped / Partial.** +Plain Advanced Ecaz/Richese games use the existing provisional combined grant. +Native and allied marker consent, payment, prevention, and the Advanced Guild's +Allow/Stop continuation are connected; a mismatched concealed-marker decision +validation was corrected. Wider combinations and deployed acceptance remain open. +[Scope](GUILD_AMBASSADOR_RULES.md#advanced-no-field-composition--16-november-2026). + +Twelve related test files pass 108 cases, including the two new rule paths and +the earlier seven Nexus/Richese failures. Those seven were stale staged setup: +the Movement fixture retained skipped Charity state and one Moritani scenario +did not select its expansion. Related Nexus payment fixtures now follow ordered +Advanced Charity and Revival and reflect later documented module and shortage +admissions. These are focused results, not comprehensive mode acceptance. + **Harkonnen special at a Richese Black Market lot — 16 November. Prototyped / Partial.** While the seller's physical card is reserved for an unsettled lot, Harkonnen waits until settlement before exchanging that hand. Other hands remain eligible; the table and bots use the public lot condition. Five focused files pass 23 cases, including all four bot levels; the production build passes. -This is a provisional -timing interpretation, and wider interactions and deployed acceptance remain -open. The related test selection also exposed seven failures in -`nexus-richese-engine.test.ts`; the same seven fail at the preceding commit -`88240e2` (six Charity phase checks and one Homeworld income-ledger check). -Whether they indicate stale fixtures or runtime defects remains uninvestigated. +This is a provisional timing interpretation, and wider interactions and +deployed acceptance remain open. The previously reported seven related test +failures are resolved by the fixture corrections above. [Scope](HARKONNEN_EXCHANGE.md#reserved-black-market-lot--16-november-2026). **Advanced Ecaz Duke revival with Harkonnen — 16 November. Prototyped / diff --git a/docs/GUILD_AMBASSADOR_RULES.md b/docs/GUILD_AMBASSADOR_RULES.md index 45adb0a1..c16660db 100644 --- a/docs/GUILD_AMBASSADOR_RULES.md +++ b/docs/GUILD_AMBASSADOR_RULES.md @@ -2,6 +2,28 @@ Primary-source review, 7 September 2026. This is a source contract, not an implementation or a claim of complete expansion compliance. Read alongside [runtime readiness](GUILD_AMBASSADOR_RUNTIME_READINESS.md). +## Advanced No-Field composition — 16 November 2026 + +**Prototyped / Partial.** The existing Basic provisional whole-grant policy now +also applies in supported plain Advanced Ecaz/Richese games. The supplied +revised rulebook, physical p36, treats an unrevealed No-Field as one force; +it does not specifically resolve this Ambassador combination. The grant's +combined cap and allied fee therefore retain the recorded provisional policy. + +The native and allied marker use the original consent, cancellation and +shipment continuations. In Advanced, the Guild's special Karama opportunity +occurs before arrival: Allow continues the same physical marker and Stop spends +the Guild card without moving the marker or charging its payer. The Guild +decision's declared amount counts the still-concealed allied marker as one, +including its zero value; this avoids exposing the selected number before the +committed reveal. Ordinary shipment and movement allowances remain unchanged. + +Focused genuine-start scenarios cover native and allied grants, zero and three +markers, Guild Allow/Stop, ordinary Karama prevention, human projected controls +and all four legal bot profiles. Original packet and unopened card order are +staged. Wider optional modules, combined arrivals, full games and deployed +acceptance remain open. + ## Basic No-Field composition — 24 October 2026 This supersedes the older No-Field implementation gate below for bare Basic diff --git a/docs/NEXUS_CARD_RULES.md b/docs/NEXUS_CARD_RULES.md index 65d79d24..6f5ad216 100644 --- a/docs/NEXUS_CARD_RULES.md +++ b/docs/NEXUS_CARD_RULES.md @@ -2,13 +2,29 @@ Original source audit, 10 September 2026, with dated bounded runtime follow-ups below. This document establishes the printed component inventory, source protocol and implementation boundaries; none lifts expansion release gates. The ordinary worm-triggered alliance Nexus already in the engine is distinct from this optional card module. +## Basic Nexus Kull with Leader Skills — 16 November 2026 + +**Prototyped / Partial.** Supported Basic CHOAM starts with selected Ix and +CHOAM decks, Nexus and Kull may also select Leader Skills, with optional Ecaz +deck and independent Ecaz Treachery cards. Setup deals the original skill cards +and keeps the native Nexus/Kull, Banker and Bureaucrat eligibility. The prior +start rejection described below is superseded for this composition. Normal +Kull and skill rules and the existing provisional reaction ordering still apply; +this is not a new publisher ruling or certification of all skill interactions. + +Focused public-start tests exercise actual skill assignment, an earned Nexus +card, a Karama attempt and the original Kull continuation, with selected hidden +order and physical card locations staged. Profile and payment-quote tests cover +eligibility, Richese Semuta and invalid module combinations. Full games, +broader skill interactions, Advanced and deployed acceptance remain open. + ## Basic independent cards with Nexus Kull — 16 November 2026 **Prototyped / Partial.** A fresh Basic CHOAM game with selected Ix and CHOAM decks (optionally also Ecaz) can explicitly select independent Ecaz Treachery cards, Nexus Cards and Kull together. Setup retains the three physical Ecaz -cards instead of silently omitting them. Leader Skills with this Kull/Nexus -composition reject at start with a reason rather than silently disappearing. +cards instead of silently omitting them. The later Skills follow-up above +supersedes this checkpoint's original combined-start rejection. Automatic Kull eligibility is unchanged; the host explicitly enables Kull for this combination. diff --git a/game/bureaucrat-payment.ts b/game/bureaucrat-payment.ts index 606745ed..2d285e1b 100644 --- a/game/bureaucrat-payment.ts +++ b/game/bureaucrat-payment.ts @@ -1,5 +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'; export type BureaucratPaymentKind = 'auction' | 'shipment' | 'bribe' | 'revival'; export type BureaucratPaymentSource = { event: string; @@ -43,7 +44,7 @@ export function bureaucratPaymentSignature(value: object): string { return JSON.stringify({ ...value, signature: undefined }); } export function bureaucratPaymentModeSupported(game: LeaderSkillProfile): boolean { - return independentTreacheryLeaderSkillsProfile(game) || (!game.homeworlds && game.expansions.length === 1 && + return 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 d7623eaf..7789c958 100644 --- a/game/engine.ts +++ b/game/engine.ts @@ -11446,9 +11446,8 @@ function startModules(state: Game): Game { delete g.lobbyOptions; if (lobbyKullEnabled(state)) { if (g.nexusCards && g.advanced === false) { - requireRule(!options.leaderSkills, 'Kull with Nexus and Leader Skills is not supported yet.'); if (options.ecazTreachery) g.ecazTreachery = true; - return initializeNexusKullGameForAudit(g); + return initializeNexusKullGameForAudit(g, !!options.leaderSkills); } const supportedBasic = g.advanced === false && (g.expansions.length === 2 || g.expansions.length === 3 && g.expansions.includes('ecaz')) && g.expansions.includes('choam') && @@ -13982,7 +13981,7 @@ export function initializeKullGameForAudit(state: Game): Game { return g; } /** Fresh native CHOAM Kull with Nexus and optional independent Ecaz cards. */ -export function initializeNexusKullGameForAudit(state: Game): Game { +export function initializeNexusKullGameForAudit(state: Game, skills = false): Game { requireRule(!state.kullPreview && !state.nexusKullPreview && !state.pendingKull && state.kullRestrictions === undefined && state.kullSequence === undefined && !state.semutaPreview && !state.richeseBetrayalPreview && !state.richeseBetrayal && @@ -13997,8 +13996,11 @@ export function initializeNexusKullGameForAudit(state: Game): Game { !state.advanced && (p.faction === 'richese' || p.faction === 'ixians' || p.faction === 'tleilaxu' || state.expansions.includes('ecaz') && (p.faction === 'ecaz' || p.faction === 'moritani'))), 'Nexus Kull requires a fresh supported CHOAM lobby with selected faction decks and supported Nexus and Ecaz cards.'); + requireRule(!skills || !state.advanced, 'Nexus Kull with Leader Skills currently requires Basic rules.'); requireFreshBaseRuntime(state); - const g = initializeSetupGameForAudit(state, false, true, false, false, false, false, true, state.ecazTreachery === true); + const seed = structuredClone(state); + if (skills) seed.leaderSkills = createLeaderSkills(random); + const g = initializeSetupGameForAudit(seed, false, true, false, false, skills, false, true, state.ecazTreachery === true); g.kullPreview = true; g.nexusKullPreview = true; if (!g.advanced && byFaction(g, 'richese')) g.semutaPreview = true; @@ -20668,7 +20670,7 @@ function kullIntegrity(g: Game): void { g.players.every(p => p.faction === 'choam' || faction(p.faction).expansion === 'base' || !g.advanced && (p.faction === 'richese' || p.faction === 'ixians' || p.faction === 'tleilaxu' || g.expansions.includes('ecaz') && (p.faction === 'ecaz' || p.faction === 'moritani'))) && - !g.homeworlds && !g.leaderSkills && !g.discoveryEnabled && !g.discoveries && + !g.homeworlds && (!g.leaderSkills || !g.advanced) && !g.discoveryEnabled && !g.discoveries && !g.discoveryStash && !g.greatMaker && !g.techTokens && !g.strongholdCards && (!g.ecazTreachery || !g.advanced) && (!g.semutaPreview || !g.advanced && !!byFaction(g, 'richese')) && @@ -26418,7 +26420,8 @@ type GuildMarkerView = { decline?: Action; declineLabel?: string; }; function guildMarkerAvailable(g: Game, beneficiary: string): boolean { - return bareBasicSemutaProfile(g) && !g.pendingAmbassador?.guildMarkerBlocked && !!markerOwner(g, beneficiary); + return (bareBasicSemutaProfile(g) || bareAdvancedEcazSemutaProfile(g)) && + !g.pendingAmbassador?.guildMarkerBlocked && !!markerOwner(g, beneficiary); } function quoteAmbassadorMarker(g: Game, beneficiary: string, fields: { tokenId: string; tokenEvent: string; territory: string; sector: number; payer?: string; elite?: number; @@ -40935,7 +40938,8 @@ function validateGuildShipmentDecision( decision.territory === shipment.territory && decision.sector === shipment.sector && decision.noFieldSkillProof === shipment.noFieldSkillProof && - decision.amount === (shipment.alliedNoField ? 1 : shipment.amount + (shipment.noFieldReserves ?? 0)), + decision.amount === (shipment.alliedNoField || shipment.ambassadorMarker + ? 1 : shipment.amount + (shipment.noFieldReserves ?? 0)), 'The Guild decision does not match the pending shipment.', ); validatePhysicalShipment(g, shipment); diff --git a/game/faction-module-profile.ts b/game/faction-module-profile.ts index 8b3e4283..f6a03ecc 100644 --- a/game/faction-module-profile.ts +++ b/game/faction-module-profile.ts @@ -117,6 +117,34 @@ function basicNativeNexusCore(game: NexusCoreConfiguration): boolean { 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 { + const players = game.players; + if (game.advanced !== false || !game.nexusCards || !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.homeworlds || game.techTokens || game.strongholdCards || + game.discoveryEnabled || game.discoveries || game.discoveryStash || game.greatMaker || + game.advancedPreview || game.richeseBetrayalPreview || game.moritaniAssassinatePreview || + (game.semutaPreview && (game.semutaPreview !== true || + !players.some(player => player.faction === 'richese'))) || + ((game.kullPreview || game.nexusKullPreview) && + (game.kullPreview !== true || game.nexusKullPreview !== 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; +} + /** Original selected decks do not require their native factions or the * independent three-card variant. Hidden E3/Harkonnen compositions retain * their existing separately scoped paths. */ @@ -132,7 +160,7 @@ export function selectedNexusWithoutCardsProfile(game: NexusCoreConfiguration): /** Common consumers of supported classic and selected-deck Nexus games. */ export function nexusCoreProfile(game: NexusCoreConfiguration): boolean { - return classicNexusCoreProfile(game) || selectedIndependentNexusProfile(game) || + return nexusKullLeaderSkillsProfile(game) || classicNexusCoreProfile(game) || selectedIndependentNexusProfile(game) || independentDiscoveryNexusProfile(game) || selectedNexusWithoutCardsProfile(game); } diff --git a/game/leader-skill-profile.ts b/game/leader-skill-profile.ts index 5f9cb6a9..834ea02d 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, mixedE3NexusRosterProfile, selectedNexusWithoutCardsProfile } from './faction-module-profile'; +import { independentDiscoveryProfile, independentNexusProfile, classicNexusCoreProfile, nexusCoreProfile, 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. */ @@ -534,7 +534,7 @@ export function independentTreacheryLeaderSkillsProfile(game: LeaderSkillProfile /** Shared by rule quotes, controls and minimal legal bot participation. */ export function ordinaryLeaderSkillModeSupported(game: LeaderSkillProfile): boolean { - return independentTreacheryLeaderSkillsProfile(game) || (noOtherLeaderSkillModules(game) && + return 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 d63c81d5..ccf61a9a 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -1746,7 +1746,7 @@ export const RULE_TOPICS: RuleTopic[] = [ 'The mobile stronghold can receive a non-Ixian group only from the territory it points to. Ecaz and its ally may co-occupy under Occupy. Advisors keep their applicable stance and accompaniment locks; an eligible arrival can request fighters. CHOAM may use Baliset during Shipment and Movement; if allowed, choose another legal destination. Intrusion or Terror resolves before the original entrant continues. A destination that causes both settles the Intrusion first and then offers the committed Terror entry; no payment or force transfer replays. There is no extra decline after triggering; if no legal move remains, the effect finishes without moving pieces and its token stays consumed.', 'The Guild Ambassador grants an immediate free shipment of zero through four physical reserve forces for Ecaz or its ally, including typed elites. Choose a clear territory and sector; this does not spend ordinary shipment or movement, ally aid or a retained rate card. Fremen may use destinations outside their ordinary reinforcement radius, but their southern reserves stay on-planet and this effect never permits storm entry. Only Ixians may ship directly into their placed mobile stronghold.', 'During Shipment and Movement, Guild can use its special Karama to stop another eligible off-planet Ambassador shipment before forces arrive; it does not stop this grant during a phase-one worm sequence. A successful off-planet shipment may invite Bene Gesserit accompaniment and accrues applicable phase-five Heighliner income once. BG can accompany Ixians into the mobile stronghold. Projected accompaniment choices show blocked sectors and keep Polar Sink and decline available when legal. Intrusion, separate Terror and accompanying fighter-triggered Ambassadors finish before the original entrant or worm rider resumes.', - 'In bare Basic Richese/Ecaz tables, No-Field may replace the whole Guild grant under an explicit provisional policy: concealed native0/3/5 counts as one and ships free; allied use reveals immediately within four available counters and keeps the one/two-spice transport payment to Guild or Bank. Richese chooses its token/payer and the beneficiary must accept before transfer. Prior native revelation, shared token history and physical fallback after scoped prevention remain; ordinary allowances are unchanged. Advanced/optional profiles remain separate. In bounded classic plus Ecaz/Moritani games, a shared Ambassador/Terror entry gives both owners saved optional prompts in current storm order without repeating the committed entry; this is a provisional table order, not a printed publisher priority. A Terror entry now waits for the arrival’s own interaction — Guild income, a Bene Gesserit fighter Intrusion or advisor choice, or Fremen storm protection — and then opens without replaying payment or force transfer. Ambassador-created child arrivals retain their own contracts. The native-module extension now composes ordinary paid arrival order with Atomics, Homeworlds and Nexus; other combinations and complete rules remain unfinished.', + 'In supported plain Basic and Advanced Richese/Ecaz tables, No-Field may replace the whole Guild grant under an explicit provisional policy: concealed native0/3/5 counts as one and ships free; allied use reveals immediately within four available counters and keeps the one/two-spice transport payment to Guild or Bank. Richese chooses its token/payer and the beneficiary must accept before transfer. Prior native revelation, shared token history and physical fallback after scoped prevention remain; ordinary allowances are unchanged. Other optional profiles remain separate. In bounded classic plus Ecaz/Moritani games, a shared Ambassador/Terror entry gives both owners saved optional prompts in current storm order without repeating the committed entry; this is a provisional table order, not a printed publisher priority. A Terror entry now waits for the arrival’s own interaction — Guild income, a Bene Gesserit fighter Intrusion or advisor choice, or Fremen storm protection — and then opens without replaying payment or force transfer. Ambassador-created child arrivals retain their own contracts. The native-module extension now composes ordinary paid arrival order with Atomics, Homeworlds and Nexus; other combinations and complete rules remain unfinished.', 'The Tleilaxu Ambassador returns one eligible own leader or up to four physical forces free. First-death leaders and the first-killed Atreides KH need not wait for the ordinary cohort. Under the provisional repeat interpretation, later native leaders must satisfy their ordinary death condition, and later KH returns must meet their saved next-cohort marker. Preserve the actual opening before resurrection; KH advances its marker beyond both owner and old KH cycles without resetting activation losses or adding a native disc. Ecaz retains native identity bookkeeping. Ecaz may instead return the shared Duke alive and unclaimed under his independent permission; its ally cannot inherit that permission. Native and BG copied grants share eligibility and exclusive alternatives. A positive return provisionally earns seated Tleilaxu one bank spice per beneficiary/turn, sharing ordinary free revival; Ghola stays separate. Canceling income keeps the return and spent entitlement. Ordinary allowance independence and wider custody/module combinations remain provisional.', 'All eleven effect guides are readable. Emperor, Atreides, Harkonnen, CHOAM, Ixian, Richese, Fremen and Guild entry effects are integrated, together with Bene Gesserit copies of those eight effects and direct Duke acquisition or consensual alliance through the reusable Ecaz token. Advanced combined Occupy has a separate bounded Development Verified guide, and Basic even-force Occupy now composes the same shared controls. Remaining effects, exceptional Duke custody and complete Ecaz rules remain unfinished. Ambassadors can be placed on the genuinely placed Hidden Mobile Stronghold, including when its pointer is in storm: the interior is sheltered. Its face-up marker stays attached through Ixian movement. Placement still pays the increasing fee and can be prevented by Karama. This supplies no Terror or direct-shipment permission. Normal public Ecaz starts remain development previews; complete rules and unsupported combinations stay gated.', ], @@ -5997,7 +5997,7 @@ export const RULE_TOPICS: RuleTopic[] = [ developmentStage: 'Verified', summary: 'In the explicit Nexus Kull preview, choose one actual Treachery fuel card at a Karama attempt; the CHOAM Nexus is spent when the declaration is accepted, even if Kull is prevented.', steps: [ - 'Fresh Basic CHOAM games with selected Ix and CHOAM decks and Nexus alone enable this preview by default, including selected Ecaz and Moritani factions with their deck; the host may turn it off. Original Ix Sandtrout stays in the Spice deck. Semuta remains active with Richese even when Kull is turned off. The separate local Advanced audit remains available; other optional modules and Richese Betrayal remain outside this profile.', + 'Fresh Basic CHOAM games with selected Ix and CHOAM decks and Nexus alone enable this preview by default, including selected Ecaz and Moritani factions with their deck; the host may turn it off. The host may explicitly combine Nexus Kull with Leader Skills and optional independent Ecaz Treachery cards. Original Ix Sandtrout stays in the Spice deck. Semuta remains active with Richese even when Kull is turned off. The separate local Advanced audit remains available; other optional modules and Richese Betrayal remain outside this profile.', 'In this Basic Richese profile, a successful printed Kull or distinct Karama counter offers its public discard to Semuta. Successful Nexus-fueled Kull offers the actual private fuel only after the physical Nexus has been spent and the effect committed; claim or pass retains the original Karama continuation.', 'The native Ixian Bidding counter remains bound while Kull resolves, then its original Ixian Nexus opportunity and auction proceed. A waiting Sandtrout does not disable an earned Emperor Nexus ordinary bank-auction benefit; other Sandtrout purchase sources retain their separate limits.', 'The CHOAM Nexus face says: Discard any Treachery Card to obtain a Worthless Card special effect of your choice. Basic uses the CHOAM phase-wide scope; new Advanced attempts use the supplied specific-effect scope with provisional phase expiry. Cunning changes the fuel identity, not the effect, target or timing. Neither text supplies a nested counter priority: distinct counters and BG-before-conversion custody are the recorded user-selected policy, not a publisher clarification.', diff --git a/tests/fixture-nexus-module-payments.ts b/tests/fixture-nexus-module-payments.ts index d4b78e46..793ba17d 100644 --- a/tests/fixture-nexus-module-payments.ts +++ b/tests/fixture-nexus-module-payments.ts @@ -46,6 +46,12 @@ export type NexusModulePaymentsFixture = { /** Use the existing original continuation policy, never a fixture phase jump. */ export function nextNexusModulePaymentsNativeStep(game: Game): NexusModulePaymentStep | null { + if (game.phase === 2 && game.charityOrder && !game.phaseOpening && !game.response && + !game.decision && !game.truthtrance && !game.pendingTreacheryDiscard) { + const actor = game.charityOrder.remaining[0]; + assert.ok(actor, 'An open ordered Charity needs its current actor.'); + return { actor, action: { type: 'ready' } }; + } if (game.nexusCards?.phase?.stage === 'drawing' && !game.response && !game.decision) { const phase = game.nexusCards.phase; const actor = phase.eligible.find(id => !phase.done.includes(id)); @@ -236,6 +242,12 @@ export function createNexusModulePaymentsFixture(options: NexusModulePaymentsOpt const event = kind === 'guild-shipment' ? view.nexusGuildSecretAlly!.event : view.nexusRichese!.event; paymentAction = { type: 'ship', ...target, amount, nexus: event }; } else { + // Advanced Revival belongs to each seat in order. Finish preceding + // opportunities through their real controls before staging casualties. + for (let n = 0; game.revivalOrder && game.revivalOrder.remaining[0] !== actor && n < 30; n++) + game = step(game, actions); + assert.equal(game.phase, 4); + assert.ok(!game.revivalOrder || game.revivalOrder.remaining[0] === actor); const player = game.players.find(p => p.id === actor)!; const tanks = options.tanks ?? 6, elite = options.eliteTanks ?? 0; assert.ok(tanks <= player.reserves && elite <= (player.elites?.reserves ?? 0)); diff --git a/tests/fixture-nexus-richese.ts b/tests/fixture-nexus-richese.ts index 1f172d24..9e830fc6 100644 --- a/tests/fixture-nexus-richese.ts +++ b/tests/fixture-nexus-richese.ts @@ -76,22 +76,14 @@ export function nexusRicheseFixture( 'RICHESENEXUS', newPlayer(owner, ownerFaction, ownerFaction), options.advanced ?? false, - ownerFaction === 'ixians' || opponentFaction === 'ixians' - ? ['ix'] - : ownerFaction === 'richese' ? ['choam'] : [], + [ + ...(ownerFaction === 'ixians' || opponentFaction === 'ixians' ? ['ix' as const] : []), + ...(ownerFaction === 'richese' ? ['choam' as const] : []), + ...(opponentFaction === 'moritani' ? ['ecaz' as const] : []), + ], ); - // The unfinished E3 public deck gate is separate from native Moritani audit - // setup. Fix the final faction before readiness and genuine initialization. - joinGame( - g, - newPlayer( - target, - opponentFaction, - opponentFaction === 'moritani' ? 'harkonnen' : opponentFaction, - ), - ); - if (opponentFaction === 'moritani') - g.players[1] = newPlayer(target, opponentFaction, opponentFaction); + // The selected roster and physical decks precede readiness and native setup. + joinGame(g, newPlayer(target, opponentFaction, opponentFaction)); joinGame(g, newPlayer(observer, observerFaction, observerFaction)); if (options.homeworlds) g = applyAction(g, owner, { type: 'homeworlds', enabled: true }); @@ -155,6 +147,9 @@ export function nexusRicheseFixture( ? holdNexusRicheseCard(g, target, 'karama').id : undefined; g.players[0].spice = options.spice ?? 20; + // This focused Movement fixture intentionally jumps over the remaining + // phases; a live Charity turn cannot survive that staged boundary. + delete g.charityOrder; Object.assign(g, { phase: 5, active: owner, diff --git a/tests/guild-ambassador-no-field-advanced.test.ts b/tests/guild-ambassador-no-field-advanced.test.ts new file mode 100644 index 00000000..05e764b0 --- /dev/null +++ b/tests/guild-ambassador-no-field-advanced.test.ts @@ -0,0 +1,208 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { createElement } from 'react'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { AmbassadorShipment } from '../components/ambassador-shipment'; +import { botActions } from '../game/bots'; +import { DIFFICULTIES } from '../game/bot-profiles'; +import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine'; +import { validateAmbassadors } from '../game/ecaz-ambassadors'; +import { + actGuildAmbassadorNoField as act, + advanceGuildAmbassadorNoField as advance, + guildAmbassadorNoFieldClean as clean, + guildAmbassadorNoFieldInventory as inventory, + guildAmbassadorNoFieldPlayer as player, + passGuildAmbassadorNoFieldResponses as pass, +} from './fixture-guild-ambassador-no-field'; + +/** Genuine public Advanced E2/E3 setup, paid placements, reciprocal alliance + * and paid Harkonnen entry. Only unopened spice order, the selected physical + * Ambassador packet and the cancellation card are staged; all pieces stay in + * their original inventories and no turn, phase or pending choice is assigned. */ +function advancedGrant(beneficiary: 'own' | 'allied') { + let g = createGame('ADVANCEDGUILDMARKER', newPlayer('ecaz', 'Ecaz', 'ecaz'), true, ['ecaz', 'choam']); + for (const id of ['richese', 'harkonnen', 'guild'] as const) joinGame(g, newPlayer(id, id, id)); + for (const p of g.players) g = act(g, p.id, { type: 'ready' }); + g = act(g, 'ecaz', { type: 'start', advancedPreview: true }); + g = advance(g, state => state.status === 'playing'); + assert.equal(g.advanced, true); + const originalCards = inventory(g); + for (const position of [0, 1]) { + const index = g.spiceDeck.findIndex((card, i) => i >= position && 'territory' in card && !card.discovery); + assert.ok(index >= position); + [g.spiceDeck[position], g.spiceDeck[index]] = [g.spiceDeck[index], g.spiceDeck[position]]; + } + g = advance(g, state => state.phase === 4 && !state.response && !state.phaseOpening && state.decision?.kind === 'ecazPlacement'); + const markers = g.ecazAmbassadors!; + const guildToken = markers.tokens.find(token => token.effect === 'guild')!; + if (guildToken.zone === 'pool') { + const replaced = markers.tokens.find(token => token.zone === 'supply' && token.effect !== 'ecaz')!; + const index = markers.cohort.indexOf(replaced.id); assert.ok(index >= 0); + markers.cohort[index] = guildToken.id; + guildToken.zone = 'supply'; replaced.zone = 'pool'; + } + validateAmbassadors(markers); + const selfToken = markers.tokens.find(token => token.effect === 'ecaz')!; + g = act(g, 'ecaz', { type: 'decision', token: selfToken.id, territory: 'carthag' }); + g = advance(g, state => !state.response && state.decision?.kind === 'ecazPlacement'); + g = act(g, 'ecaz', { type: 'decision', token: guildToken.id, territory: 'habbanya_ridge_sietch' }); + g = advance(g, state => !state.response && state.decision?.kind === 'ecazPlacement'); + g = act(g, 'ecaz', { type: 'decision', decline: true }); + g = advance(g, state => state.phase === 5 && state.active === 'ecaz' && clean(state)); + g = act(g, 'ecaz', { type: 'ship', amount: 1, territory: 'polar_sink', sector: 0, elite: 0, allyPayment: 0 }); + g = advance(g, clean); + g = act(g, 'ecaz', { type: 'endMovement' }); + g = advance(g, state => state.active === 'richese' && clean(state)); + g = act(g, 'richese', { type: 'ship', amount: 1, territory: 'carthag', sector: 11, elite: 0, allyPayment: 0 }); + g = advance(g, state => !state.response && state.pendingAmbassador?.stage === 'offer'); + g = act(g, 'ecaz', { type: 'decision', event: g.pendingAmbassador!.event, + trigger: true, beneficiary: 'ecaz', choice: 'alliance' }); + assert.equal(g.pendingAmbassador?.stage, 'allianceReply'); + g = act(g, 'richese', { type: 'decision', event: g.pendingAmbassador!.event, accept: true }); + g = advance(g, clean); + assert.equal(player(g, 'ecaz').ally, 'richese'); + assert.equal(player(g, 'richese').ally, 'ecaz'); + g = act(g, 'richese', { type: 'endMovement' }); + g = advance(g, state => state.active === 'harkonnen' && clean(state)); + g = act(g, 'harkonnen', { type: 'ship', amount: 1, territory: 'habbanya_ridge_sietch', sector: 17, + elite: 0, allyPayment: 0 }); + g = advance(g, state => !state.response && state.pendingAmbassador?.stage === 'offer'); + const beforeTrigger = structuredClone(g); + const recipient = beneficiary === 'own' ? 'richese' : 'ecaz'; + g = act(g, 'ecaz', { type: 'decision', event: g.pendingAmbassador!.event, trigger: true, beneficiary: recipient }); + assert.equal(g.pendingAmbassador?.stage, 'ship'); + assert.equal(g.pendingAmbassador.effect, 'guild'); + assert.equal(g.decision?.player, recipient); + assert.equal(g.active, 'harkonnen'); + assert.deepEqual(inventory(g), originalCards); + return { g, event: g.pendingAmbassador.event, recipient, originalCards, beforeTrigger }; +} + +function addHeldKarama(g: Game, id = 'harkonnen') { + const holder = player(g, id); + const existing = holder.hand.find(card => card.effect === 'karama'); + if (existing) return existing.id; + const index = g.deck.findIndex(card => card.effect === 'karama'); assert.ok(index >= 0); + const card = g.deck.splice(index, 1)[0]; holder.hand.push(card); return card.id; +} +function nativeMarker(g: Game, event: string) { + const richese = player(g, 'richese'); + const token = richese.noField!.tokens.find(token => token.value === 3)!; + return { type: 'decision' as const, event, amount: 1, noField: token.id, + noFieldEvent: richese.noFieldEvent!, territory: 'sietch_tabr', sector: 14 }; +} +function allowances(g: Game) { + return { active: g.active, remaining: g.movementRemaining, + players: g.players.map(p => ({ id: p.id, shipped: p.shipped, moved: p.moved })) }; +} + +void test('Advanced native Guild grant offers and commits Richese marker without spending the ordinary shipment', () => { + const f = advancedGrant('own'), before = structuredClone(f.g); + const view = viewGame(f.g, 'richese'); + assert.equal(view.ambassadorEntry?.noField?.stage, 'own'); + assert.ok(view.ambassadorEntry.noField.options.some(option => option.action.noField === nativeMarker(f.g, f.event).noField)); + assert.equal(viewGame(f.g, 'harkonnen').ambassadorEntry?.noField ?? null, null); + const html = renderToStaticMarkup(createElement(AmbassadorShipment, { game: view, busy: false, act() {} })); + assert.match(html, /Ambassador No-Field shipment/); + for (const difficulty of DIFFICULTIES) { + const botView = viewGame(f.g, 'richese'); botView.players.find(p => p.id === 'richese')!.bot = difficulty; + const action = botActions(botView)[0]; assert.ok(action, difficulty); + assert.doesNotThrow(() => act(f.g, 'richese', action), difficulty); + } + let g = act(f.g, 'richese', nativeMarker(f.g, f.event)); + g = pass(g); + assert.equal(g.decision?.kind, 'guildShipment'); + assert.equal(g.decision.player, 'guild'); + assert.equal(player(g, 'richese').noField!.deployed, null); + g = act(g, 'guild', { type: 'decision', allow: true }); + assert.equal(player(g, 'richese').noField!.deployed?.tokenId, nativeMarker(f.g, f.event).noField); + assert.equal(player(g, 'richese').reserves, player(before, 'richese').reserves); + assert.equal(player(g, 'richese').spice, player(before, 'richese').spice); + assert.deepEqual(allowances(g), allowances(before)); + assert.deepEqual(inventory(g), f.originalCards); + assert.equal(viewGame(g, 'harkonnen').players.find(p => p.id === 'richese')!.noField!.deployed!.effectiveForces, 1); + g = advance(g, clean); + assert.equal(g.pendingAmbassador, null); + assert.equal(g.active, 'harkonnen'); +}); + +for (const value of [0, 3] as const) void test(`Advanced allied Guild grant requests consent and materializes the ${value} marker with its fee`, () => { + const f = advancedGrant('allied'), before = structuredClone(f.g); + assert.equal(viewGame(f.g, 'ecaz').ambassadorEntry?.noField?.stage, 'request'); + let g = act(f.g, 'ecaz', { type: 'decision', event: f.event, requestNoField: true, territory: 'sietch_tabr', sector: 14 }); + assert.equal(viewGame(g, 'richese').ambassadorEntry?.noField?.stage, 'supply'); + const richese = player(g, 'richese'), token = richese.noField!.tokens.find(row => row.value === value)!; + g = act(g, 'richese', { type: 'decision', event: f.event, offerNoField: token.id, noFieldEvent: richese.noFieldEvent!, payer: 'ecaz', elite: 0 }); + assert.equal(viewGame(g, 'ecaz').ambassadorEntry?.noField?.stage, 'consent'); + assert.equal(player(g, 'ecaz').reserves, player(before, 'ecaz').reserves); + g = act(g, 'ecaz', { type: 'decision', event: f.event, acceptNoField: true }); + g = pass(g); + assert.equal(g.decision?.kind, 'guildShipment'); + assert.equal(g.decision.player, 'guild'); + assert.equal(player(g, 'ecaz').forces['sietch_tabr:14'] ?? 0, 0); + g = act(g, 'guild', { type: 'decision', allow: true }); + g = pass(g); + assert.equal(player(g, 'ecaz').forces['sietch_tabr:14'] ?? 0, value); + assert.equal(player(g, 'ecaz').reserves, player(before, 'ecaz').reserves - value); + assert.equal(player(g, 'ecaz').spice, player(before, 'ecaz').spice - 1); + assert.equal(player(g, 'guild').spice, player(before, 'guild').spice + 1); + assert.equal(player(g, 'richese').noField!.lastShipped, token.id); + assert.deepEqual(allowances(g), allowances(before)); + assert.deepEqual(inventory(g), f.originalCards); + g = advance(g, clean); + assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen'); +}); + +void test('Advanced Karama prevents only the Guild marker and preserves the physical shipment fallback', () => { + const f = advancedGrant('own'), g0 = structuredClone(f.g); + const karama = addHeldKarama(g0), before = structuredClone(g0); + assert.deepEqual(inventory(g0), f.originalCards); + let g = act(g0, 'richese', nativeMarker(g0, f.event)); + assert.equal(g.response?.kind, 'richeseNoField'); + g = act(g, 'harkonnen', { type: 'card', mode: 'cancel', card: karama }); + g = advance(g, state => !state.response && !state.pendingTreacheryDiscard); + assert.equal(g.pendingAmbassador?.stage, 'ship'); + assert.equal(g.pendingAmbassador.event, f.event); + assert.equal(player(g, 'richese').noField!.deployed, null); + assert.equal(player(g, 'richese').noFieldBlockedTurn, player(before, 'richese').noFieldBlockedTurn); + assert.equal(player(g, 'richese').reserves, player(before, 'richese').reserves); + assert.deepEqual(allowances(g), allowances(before)); + assert.equal(g.discard.filter(card => card.id === karama).length, 1); + g = act(g, 'richese', { type: 'decision', event: f.event, amount: 1, territory: 'sietch_tabr', sector: 14, elite: 0 }); + g = advance(g, clean); + assert.equal(player(g, 'richese').forces['sietch_tabr:14'], 1); + assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen'); + assert.deepEqual(inventory(g), f.originalCards); +}); + +for (const beneficiary of ['own', 'allied'] as const) void test(`Advanced Guild special stops the ${beneficiary} marker shipment without charging or consuming it`, () => { + const f = advancedGrant(beneficiary), source = structuredClone(f.g); + const karama = addHeldKarama(source, 'guild'), before = structuredClone(source); + let g = source; + if (beneficiary === 'own') g = act(g, 'richese', nativeMarker(g, f.event)); + else { + g = act(g, 'ecaz', { type: 'decision', event: f.event, requestNoField: true, + territory: 'sietch_tabr', sector: 14 }); + const richese = player(g, 'richese'), token = richese.noField!.tokens.find(row => row.value === 3)!; + g = act(g, 'richese', { type: 'decision', event: f.event, offerNoField: token.id, + noFieldEvent: richese.noFieldEvent!, payer: 'ecaz', elite: 0 }); + g = act(g, 'ecaz', { type: 'decision', event: f.event, acceptNoField: true }); + } + g = pass(g); + assert.equal(g.decision?.kind, 'guildShipment'); + assert.equal(g.decision.player, 'guild'); + g = act(g, 'guild', { type: 'card', mode: 'special', card: karama }); + g = advance(g, clean); + assert.equal(player(g, 'guild').specialKaramaUsed, true); + assert.equal(g.discard.filter(card => card.id === karama).length, 1); + assert.equal(player(g, 'richese').noField!.deployed, null); + assert.equal(player(g, 'richese').noField!.lastShipped, player(before, 'richese').noField!.lastShipped); + for (const id of ['richese', 'ecaz', 'guild']) { + assert.equal(player(g, id).spice, player(before, id).spice); + assert.equal(player(g, id).reserves, player(before, id).reserves); + } + assert.deepEqual(allowances(g), allowances(before)); + assert.deepEqual(inventory(g), f.originalCards); + assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen'); +}); diff --git a/tests/nexus-kull-leader-skills.test.ts b/tests/nexus-kull-leader-skills.test.ts new file mode 100644 index 00000000..85ff9cfd --- /dev/null +++ b/tests/nexus-kull-leader-skills.test.ts @@ -0,0 +1,148 @@ +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 { validateNexusCards } from '../game/nexus-cards'; +import { botActions } from '../game/bots'; +import { DIFFICULTIES } from '../game/bot-profiles'; +import { SEMUTA_DRUG_ID } from '../game/semuta-drug'; +import { takeKullCard } from './fixture-choam-kull'; +import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards'; +import { + advanceSemutaNexusTrade, swapSemutaNexusTradeIdentity, + type SemutaNexusTradeStep, +} from './fixture-semuta-nexus-trade'; + +const act = (game: Game, actor: string, action: Action) => applyAction(game, actor, action); +const seat = (game: Game, id: string) => { + const player = game.players.find(candidate => candidate.id === id); + assert.ok(player); return player; +}; +const clean = (game: Game) => !game.phaseOpening && !game.response && !game.decision && !game.truthtrance; +const physical = (game: Game) => [ + ...game.deck, ...game.discard, ...(game.auction?.cards.slice(game.auction.index) ?? []), + ...(game.richeseCache ?? []), ...(game.richeseRemoved ?? []), + ...(game.ixAuction?.cards ?? []), ...game.players.flatMap(player => player.hand), +].map(card => card.id).sort(); +function skills(game: Game) { + assert.ok(game.leaderSkills); + validateLeaderSkills(game.leaderSkills, game.players); + const state = game.leaderSkills; + assert.deepEqual([...state.deck, ...Object.values(state.offers).flatMap(offer => offer.cards), + ...state.assignments.map(assignment => assignment.skill)].sort(), + LEADER_SKILL_CARDS.map(card => card.id).sort()); +} + +/** Public selected-module start, real skill training and a real earned Nexus. + * Only unopened Spice order, the identity of an earned card, and conserved + * board/hand pieces are staged, matching the existing public Kull fixture. */ +function fixture(independent: boolean, richese = false) { + let game = createGame('NEXUSKULLSKILLS', 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'] : []), 'nexusCards', 'leaderSkills', 'kullPreview']) + game = act(game, 'c', { type: 'moduleOption', module: moduleName, enabled: true }); + const selected = viewGame(game, 'c').lobbyModules!; + assert.equal(selected.nexusCards, true); 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.equal(game.nexusKullPreview, true); + if (richese) { assert.equal(game.semutaPreview, true); assert.ok(game.richeseCache?.length); } + assert.ok(game.leaderSkills); assert.ok(game.nexusCards); + assert.equal(game.ecazTreachery === true, independent); + const setupActions: SemutaNexusTradeStep[] = []; + game = advanceSemutaNexusTrade(game, state => state.status === 'playing', setupActions); + assert.equal(setupActions.filter(row => row.action.type === 'leaderSkill').length, game.players.length); + assert.equal(game.leaderSkills!.assignments.length, game.players.length); + skills(game); validateNexusCards(game.nexusCards!.cards!, game.players); + const inventory = physical(game); + const originalSkills = structuredClone(game.leaderSkills); + for (const player of game.players) { + player.reserves += Object.values(player.forces).reduce((sum, amount) => sum + amount, 0); + player.forces = {}; + } + game = advanceSemutaNexusTrade(game, beforeIxSpiceDraw); + orderIxSpiceCards(game, ['land', 'land']); + game = advanceSemutaNexusTrade(game, state => state.turn === 2 && beforeIxSpiceDraw(state)); + orderIxSpiceCards(game, ['worm', 'land', 'land']); + game = advanceSemutaNexusTrade(game, state => !!state.nexus && !state.spiceWindow && clean(state)); + game = act(game, 'a', { type: 'alliance', target: 'h' }); + game = act(game, 'h', { type: 'alliance', target: 'a' }); + game = advanceSemutaNexusTrade(game, state => state.nexusCards?.phase?.stage === 'drawing' && clean(state)); + assert.ok(game.nexusCards!.phase!.eligible.includes('c')); + game = act(game, 'c', { type: 'nexusCardChoice', turn: game.turn, card: null, choice: 'draw', ownRedraws: 0 }); + swapSemutaNexusTradeIdentity(game, 'c', 'choam'); + game = advanceSemutaNexusTrade(game, state => state.phase === 5 && state.active === 'g' && clean(state)); + assert.equal(game.nexusCards!.cards!.hands.c, 'choam'); + for (const player of game.players) game.deck.push(...player.hand.splice(0)); + const fuel = takeKullCard(game, 'ix-hunter-seeker'); seat(game, 'c').hand.push(fuel); + 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(physical(game), inventory); + assert.deepEqual(game.leaderSkills, originalSkills); + game = act(game, 'g', { type: 'card', mode: 'shipment', card: original.id, target: 'g' }); + assert.ok(game.pendingKull); + assert.deepEqual(game.leaderSkills, originalSkills); + return { game, fuel: fuel.id, original: original.id, event: game.pendingKull.event, inventory, originalSkills }; +} + +for (const independent of [false, true]) void test( + `Basic public Nexus Kull keeps trained Leader Skills${independent ? ' with 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)); + } + assert.ok(viewGame(f.game, 'c').kullReaction?.plays.some(play => play.source === 'nexus' && play.card.id === f.fuel)); + let game = act(f.game, 'c', { type: 'kullDecision', event: f.event, source: 'nexus', card: f.fuel }); + while (game.pendingKull) { + 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.nexusCards!.cards!.hands.c, null); + assert.equal(game.discard.filter(card => card.id === f.fuel).length, 1); + assert.equal(seat(game, 'g').hand.some(card => card.id === f.original), true); + assert.deepEqual(physical(game), f.inventory); + assert.deepEqual(game.leaderSkills, f.originalSkills); + skills(game); validateNexusCards(game.nexusCards!.cards!, game.players); + }, +); + +void test('Richese can claim Nexus Kull fuel with Semuta while original Skills and cache remain physical', () => { + const f = fixture(true, true); + assert.ok(viewGame(f.game, 'c').kullReaction?.plays.some(play => play.source === 'nexus' && play.card.id === f.fuel)); + let game = act(f.game, 'c', { type: 'kullDecision', event: f.event, source: 'nexus', card: f.fuel }); + 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); + const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction); + assert.deepEqual(pending.batch.entries.map(entry => entry.card.id), [f.fuel]); + 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.fuel }); + assert.equal(game.pendingTreacheryDiscard, null); + assert.equal(seat(game, 'r').hand.some(card => card.id === f.fuel), true); + assert.equal(game.discard.some(card => card.id === SEMUTA_DRUG_ID), true); + assert.equal(game.nexusCards!.cards!.hands.c, null); + assert.equal(seat(game, 'g').hand.some(card => card.id === f.original), true); + assert.deepEqual(physical(game), f.inventory); + assert.deepEqual(game.leaderSkills, f.originalSkills); + skills(game); validateNexusCards(game.nexusCards!.cards!, game.players); +}); diff --git a/tests/nexus-kull-skills-profile.test.ts b/tests/nexus-kull-skills-profile.test.ts new file mode 100644 index 00000000..73f149d4 --- /dev/null +++ b/tests/nexus-kull-skills-profile.test.ts @@ -0,0 +1,68 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { + independentNexusProfile, nexusCoreProfile, nexusKullLeaderSkillsProfile, + type FactionModuleProfile, +} from '../game/faction-module-profile'; +import { 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' }], + nexusCards: {}, + leaderSkills: {}, + ecazTreachery: true, + semutaPreview: true, +}; + +void test('Basic Nexus, Kull and Skills retain the same public authority before and after Kull stamps', () => { + for (const independent of [false, true]) for (const stamped of [false, true]) { + const game = { ...original, ecazTreachery: independent, + ...(stamped ? { kullPreview: true, nexusKullPreview: true } : {}) }; + const label = `independent=${independent}, stamped=${stamped}`; + assert.equal(nexusKullLeaderSkillsProfile(game), true, label); + assert.equal(nexusCoreProfile(game), true, label); + assert.equal(independentNexusProfile(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 keeps its ordinary once-per-phase quote in this supported composition', () => { + const game = { ...original, kullPreview: true, nexusKullPreview: 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('the Kull and Skills profile rejects unmatched stamps and unrelated module overlays', () => { + const invalid: Array<[string, Partial]> = [ + ['Advanced', { advanced: true }], + ['missing Nexus', { nexusCards: null }], + ['missing Skills', { leaderSkills: null }], + ['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'] }], + ['only Kull stamp', { kullPreview: true }], + ['only Nexus Kull stamp', { nexusKullPreview: true }], + ['Homeworlds', { homeworlds: {} }], + ['Discovery', { discoveryEnabled: true }], + ['Tech', { techTokens: {} }], + ['Strongholds', { strongholdCards: {} }], + ['unrelated betrayal', { richeseBetrayalPreview: true }], + ['Semuta without Richese', { players: [{ faction: 'choam' }, { faction: 'ecaz' }] }], + ]; + for (const [label, patch] of invalid) + assert.equal(nexusKullLeaderSkillsProfile({ ...original, ...patch }), false, label); +}); diff --git a/tests/nexus-module-payments-runtime.test.ts b/tests/nexus-module-payments-runtime.test.ts index 9d636a91..0afa9528 100644 --- a/tests/nexus-module-payments-runtime.test.ts +++ b/tests/nexus-module-payments-runtime.test.ts @@ -209,7 +209,7 @@ for (const kind of ['emperor-revival', 'fremen-revival'] as const) { }); } -void test('Fremen prior free returns count toward the quota, exhausted improvement is unavailable, and real Truthtrance blocks both grants', () => { +void test('Fremen prior free returns count toward the quota, short returns work, and real Truthtrance blocks both grants', () => { const f = createNexusModulePaymentsFixture({ kind: 'fremen-revival' }); const late = advanceNexusModulePaymentsToPhase(applyAction(f.game, f.actor, { type: 'revive', amount: 1 }), 4); const granted = applyAction(late, f.actor, f.paymentAction); @@ -219,8 +219,19 @@ void test('Fremen prior free returns count toward the quota, exhausted improveme assert.equal(returned.players.find(p => p.id === f.actor)!.revived, 3); for (const kind of ['fremen-revival', 'emperor-revival'] as const) { const short = createNexusModulePaymentsFixture({ kind, tanks: 2 }); - if (kind === 'emperor-revival') rejected(short.game, short.actor, short.paymentAction); - else { + if (kind === 'emperor-revival') { + // The later positive-shortage policy returns the available one or two + // forces in addition to the ordinary allowance; it supersedes the + // original full-three-only test expectation. + const before = short.beforePayment.players.find(p => p.id === short.actor)!; + const partial = payNexusModulePaymentsFixture(short); + const after = partial.players.find(p => p.id === short.actor)!; + assert.equal(after.tanks, 0); + assert.equal(after.reserves, before.reserves + 2); + assert.equal(after.revived, before.revived); + assert.equal(after.freeForcesRevived, before.freeForcesRevived); + assert.equal(partial.nexusCards!.cards!.discard.filter(card => card === 'emperor').length, 1); + } else { const enabled = applyAction(short.game, short.actor, short.paymentAction); rejected(enabled, short.actor, { type: 'revive', amount: 3 }); const partial = advanceNexusModulePaymentsToPhase(applyAction(enabled, short.actor, { type: 'revive', amount: 2 }), 4); @@ -266,14 +277,20 @@ void test('new module admission rejects too few Tech seats, Basic Strongholds, u assert.throws(() => initializeNexusGameForAudit(lobby)); assert.deepEqual(lobby, before); } - // Selected native-expansion cards/factions are not another path to admission. + // A selected Ix deck with classic factions is now a supported Nexus/Tech + // setup; it retains both original module selections through initialization. let lobby = createGame('NEXUSMODULEDECK', newPlayer('a', 'Atreides', 'atreides'), false, ['ix']); joinGame(lobby, newPlayer('h', 'Harkonnen', 'harkonnen')); joinGame(lobby, newPlayer('e', 'Emperor', 'emperor')); lobby.nexusCards = { cards: null, phase: null }; lobby.techTokens = createTechTokens(); for (const player of lobby.players) lobby = applyAction(lobby, player.id, { type: 'ready' }); - assert.throws(() => initializeNexusGameForAudit(lobby)); + const before = structuredClone(lobby); + const initialized = initializeNexusGameForAudit(lobby); + assert.deepEqual(lobby, before); + assert.deepEqual(initialized.expansions, ['ix']); + assert.ok(initialized.techTokens); + assert.ok(initialized.nexusCards); }); for (const strongholds of [false, true]) {