From bf73c41ae039c01fdf73c27c2d0be02df5f72ede Mon Sep 17 00:00:00 2001 From: Quintine <15965533+Quintine@users.noreply.github.com> Date: Thu, 29 Oct 2026 00:22:11 +1100 Subject: [PATCH] Support Kull phase bids with Richese --- components/game-table.tsx | 2 +- docs/CHOAM_KULL_DESIGN.md | 17 +- docs/CURRENT_STATUS.md | 10 ++ docs/RULE_DECISIONS.md | 7 + game/bid-promises.ts | 4 +- game/bribe-promises.ts | 3 +- game/faction-reference.ts | 2 +- game/reference.ts | 4 +- game/turn-bid-promises.ts | 4 +- tests/kull-phase-bid-runtime.test.ts | 8 +- tests/kull-richese-phase-bid-runtime.test.ts | 173 +++++++++++++++++++ tests/public-choam-kull-controls.test.tsx | 2 +- 12 files changed, 222 insertions(+), 14 deletions(-) create mode 100644 tests/kull-richese-phase-bid-runtime.test.ts diff --git a/components/game-table.tsx b/components/game-table.tsx index ce4e7378..2fb3fb1d 100644 --- a/components/game-table.tsx +++ b/components/game-table.tsx @@ -2254,7 +2254,7 @@ export function GameTable({ : <> Requires Basic CHOAM with the CHOAM and Ix decks plus each faction’s deck, and no other optional modules. Combined turn-action Truthtrance questions are unavailable. - When Richese is seated, structured bid, alliance, Revival and bribe commitments are also unavailable, + When Richese is seated, current-lot bid, alliance, Revival and bribe commitments are also unavailable, and some Kull reactions may be unavailable in complex response windows. }{' '} Unfunded non-CHOAM Karama-dependent bids remain deferred. This does not represent complete CHOAM rules. diff --git a/docs/CHOAM_KULL_DESIGN.md b/docs/CHOAM_KULL_DESIGN.md index 72ea3ae1..96118c9b 100644 --- a/docs/CHOAM_KULL_DESIGN.md +++ b/docs/CHOAM_KULL_DESIGN.md @@ -1,5 +1,18 @@ # Kull Wahad: source limits and Karama interruption design +## Basic phase-wide bid answers with Richese — 29 October 2026 + +**Prototyped / Partial.** The phase-wide ordinary bid protocol is available +in the supported Basic printed-Kull profile with Richese and Semuta. An answer +made before Bidding remains binding through the real Richese cache auction, +then through an ordinary-auction Kull response and Semuta's claim or pass. +Kull success retains the original lot; a distinct counter can let it settle +and leave a later ordinary lot for a Yes. The No cap and the non-CHOAM +unfunded-overbid fence remain in force. Current-lot bid and other structured +commitments with Richese, Kull during the cache auction and broader +combinations remain separate. This is the existing provisional online timing, +not a new publisher ruling. [Focused evidence](../tests/kull-richese-phase-bid-runtime.test.ts). + ## Basic phase-wide bid answers — 29 October 2026 **Prototyped / Partial.** In the existing supported Basic printed-Kull profile @@ -8,8 +21,8 @@ a Kull interception. The pending response holds the original answer; after Kull succeeds or a distinct Karama counters it, the ordinary bidding guide continues and a real later lot can satisfy a Yes. A No still caps bids. Future funding witnesses respect the existing non-CHOAM unfunded-overbid fence even -when that player holds Karama. Richese/Semuta with Kull, combined turn-action -questions, Advanced Kull and broader combinations remain separate. This uses +when that player holds Karama. The Richese/Semuta extension is recorded above; +combined turn-action questions, Advanced Kull and broader combinations remain separate. This uses the existing provisional Truthtrance and Kull timings, not a new publisher ruling. [Focused evidence](../tests/kull-phase-bid-runtime.test.ts). diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index 1d576699..528f5139 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -17,6 +17,16 @@ open mode gates. ## Current checkpoint and work +**Basic Kull, Richese and phase-wide bid Truthtrance — 29 October. Prototyped / Partial.** +The supported Basic profile now retains phase-wide bid answers across the +Richese cache auction, ordinary-auction Kull and Semuta claim/pass. Current-lot +bid, other structured commitments with Richese and broader interactions remain +unfinished. Twelve related files pass 59 cases. New cases start an actual Basic +game, select unopened deal and Spice positions, buy Semuta through the cache, +and exercise Kull success/counter, Semuta claim/pass, bot choices and the +rendered answer controls. Typecheck, lint and the production build pass. +[Scope](CHOAM_KULL_DESIGN.md#basic-phase-wide-bid-answers-with-richese--29-october-2026). + **Basic Kull and phase-wide bid Truthtrance — 29 October. Prototyped / Partial.** In the supported non-Richese Basic Kull profile, a phase-wide ordinary bid answer survives Kull interruption and its distinct counter; existing funding diff --git a/docs/RULE_DECISIONS.md b/docs/RULE_DECISIONS.md index d056a9e1..dba5c614 100644 --- a/docs/RULE_DECISIONS.md +++ b/docs/RULE_DECISIONS.md @@ -1,5 +1,12 @@ # Rule decision index +## Basic Kull, Richese and phase-wide bid answers — 29 October 2026 + +The supported Basic Richese profile now carries phase-wide bidding answers +through the cache, ordinary-auction Kull and Semuta continuations. Existing +provisional timing and other commitment fences remain. +[Scope](CHOAM_KULL_DESIGN.md#basic-phase-wide-bid-answers-with-richese--29-october-2026). + ## Basic Kull and phase-wide bid answers — 29 October 2026 The supported non-Richese Basic Kull profile now retains a phase-wide bid diff --git a/game/bid-promises.ts b/game/bid-promises.ts index d48bc76e..c2e22d49 100644 --- a/game/bid-promises.ts +++ b/game/bid-promises.ts @@ -36,10 +36,10 @@ export function bidPromiseModeSupported(game: NativePromiseScope & { nexusIxianReplacementPreview?: unknown; nexusIxianBetrayalPreview?: unknown; nexusHarkonnenBetrayalPreview?: unknown; moritaniAssassinatePreview?: unknown; mobileStronghold?: unknown; -}): boolean { +}, options: {allowKullRichese?: boolean} = {}): boolean { return nativePromiseScopeSupported(game) && !game.semutaPreview && !game.nexusKullPreview && !game.richeseBetrayalPreview && - (!game.kullPreview || bribePromiseModeSupported(game)); + (!game.kullPreview || bribePromiseModeSupported(game, options)); } export function bidClaimText(claim: BidClaim): string { diff --git a/game/bribe-promises.ts b/game/bribe-promises.ts index 4ed9a738..2b647a5f 100644 --- a/game/bribe-promises.ts +++ b/game/bribe-promises.ts @@ -46,7 +46,7 @@ export function bribePromiseModeSupported(game: NativePromiseScope & { nexusIxianReplacementPreview?: unknown; nexusIxianBetrayalPreview?: unknown; nexusHarkonnenBetrayalPreview?: unknown; moritaniAssassinatePreview?: unknown; mobileStronghold?: unknown; -}): boolean { +}, options: {allowKullRichese?: boolean} = {}): boolean { if (!nativePromiseScopeSupported(game) || game.nexusKullPreview || game.richeseBetrayalPreview) return false; if (game.semutaPreview) return game.semutaPreview === true && !game.advanced && @@ -62,6 +62,7 @@ export function bribePromiseModeSupported(game: NativePromiseScope & { game.players.some(player => player.faction === 'choam') && new Set(game.players.map(player => player.faction)).size === game.players.length && game.players.every(player => player.faction === 'choam' || player.faction === 'ixians' || + options.allowKullRichese && player.faction === 'richese' || player.faction === 'tleilaxu' || game.expansions.includes('ecaz') && (player.faction === 'ecaz' || player.faction === 'moritani') || FACTIONS.some(faction => faction.id === player.faction && faction.expansion === 'base')) && diff --git a/game/faction-reference.ts b/game/faction-reference.ts index 4abcb27f..4df077f0 100644 --- a/game/faction-reference.ts +++ b/game/faction-reference.ts @@ -14,7 +14,7 @@ export const FACTION_RULES: Record< 'Use Kulon on your movement turn to add one territory of range. Use La La La during Revival to prevent a player’s free force returns for the phase; a reactive decision lets you stop a pending free revival before it resolves. Both cards have Karama responses before discard.', 'Trip to Gamont returns one other player’s force from a chosen sector to its reserves during Mentat. Elite types are preserved. A Karama response precedes the return, and CHOAM gets a final opportunity after the closing market before victory is checked.', 'Baliset prevents a player from moving into a territory occupied by CHOAM for the turn, while permitting shipment. Jubba Cloak protects CHOAM forces in one territory from a moving storm. Both powers have Karama responses before the card is discarded.', - 'New supported Basic lobbies with CHOAM and the CHOAM and Ix decks enable the Kull preview by default; the host may turn it off. Each selected faction needs its deck, and other optional modules remain outside this profile. React to a legal Karama attempt with held Kull Wahad before costs. The original card stays reserved; only a different eligible Karama can counter before the phase ban applies. Success spends Kull, retains the original unplayed card and prevents the activating player’s Karama uses for the phase. Decline or prevention resumes the original once; a prevented Kull stays held but its physical card’s effect is blocked that phase. With Richese, supported Kull and counter discards offer Semuta, while structured bid, Revival, alliance and bribe commitments are unavailable. Without Richese, phase-wide bid questions are supported. Combined turn-action questions and unfunded non-CHOAM Karama-dependent overbids remain deferred; see the Kull guide. Complete CHOAM rules remain unfinished.', + 'New supported Basic lobbies with CHOAM and the CHOAM and Ix decks enable the Kull preview by default; the host may turn it off. Each selected faction needs its deck, and other optional modules remain outside this profile. React to a legal Karama attempt with held Kull Wahad before costs. The original card stays reserved; only a different eligible Karama can counter before the phase ban applies. Success spends Kull, retains the original unplayed card and prevents the activating player’s Karama uses for the phase. Decline or prevention resumes the original once; a prevented Kull stays held but its physical card’s effect is blocked that phase. With Richese, supported Kull and counter discards offer Semuta; phase-wide bid questions are supported, while current-lot bid, Revival, alliance and bribe commitments are unavailable. Combined turn-action questions and unfunded non-CHOAM Karama-dependent overbids remain deferred; see the Kull guide. Complete CHOAM rules remain unfinished.', ], advanced: [ 'Once per game, spend a real Karama and discard selected other cards for three spice each. The cash-in can occur during pending phase or power decisions, while committed battle cards remain protected. See the CHOAM special Karama topic for funding and timing details.', diff --git a/game/reference.ts b/game/reference.ts index befc7a94..2690d8a2 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -4861,7 +4861,7 @@ export const RULE_TOPICS: RuleTopic[] = [ 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 and no other optional modules. 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 the supported Basic printed Kull preview without Richese, current-lot and phase-wide ordinary bid, Revival, alliance and bribe Truthtrance questions are available, including supported grouped and mixed forms. A pending Kull response holds their controls while the original transaction resolves. The existing Richese Semuta preview does not yet admit these structured commitments; combined turn-action questions and wider interactions remain incomplete.', + 'In the supported Basic printed Kull preview, phase-wide ordinary bid questions are available, including with Richese and Semuta. Without Richese, current-lot bid, Revival, alliance and bribe questions are also available, including supported grouped and mixed forms. A pending Kull response holds their controls while the original transaction resolves. Combined turn-action questions and 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.', 'Decline resumes the original attempt once. Declaring Kull opens the ordinary CHOAM-effect response. Kull is still pending: its target may counter with a different eligible physical Karama before any phase ban applies. The interrupted card stays reserved and cannot serve as its own counter. Other eligible responders use their existing response controls.', 'If everyone allows Kull, CHOAM discards the exact Kull card. The original attempted card remains in its owner’s hand; its effect and additional costs do not occur, and an attempted special once-per-game use remains unspent. Basic prevents that player’s Karama activations for this phase. A new Advanced attempt instead prevents only the specific effect: shipment pricing, free Treachery purchase, that faction’s special, or cancellation of the particular advantage. Other effects remain available; printed and substituted Karama share the same restriction. An allied shipment recipient is not automatically the restricted player.', @@ -4876,7 +4876,7 @@ export const RULE_TOPICS: RuleTopic[] = [ example: 'Bene Gesserit attempts to use Baliset as Karama. CHOAM declares Kull. Baliset cannot also counter Kull; a different eligible Karama may. If Kull succeeds, Baliset stays held; in a new Advanced attempt BG cannot repeat that specific Karama effect this phase but may use another legal effect. If a distinct counter prevents Kull, the original Baliset attempt proceeds to its normal conversion response.', related: ['choam-worthless', 'nexus-choam-kull', 'faction-choam', 'card-karama', 'advanced-beneGesserit', 'special-karama', 'bidding', 'choam-karama', 'nexus-cards', 'implementation-checklist'], checklist: [ - { area: 'Implementation', status: 'Partial', detail: 'Selectable Kull binds typed intents, distinct physical counters and Basic/legacy all-purpose or new Advanced semantic-effect restrictions. Different effects remain playable; phase expiry is provisional in Advanced. Basic printed Kull admits native Richese, Ixians, Tleilaxu, Ecaz and Moritani; supported clean Kull discards offer Semuta before their suspended parent resumes. Without Richese, supported current-lot and phase-wide bid, Revival, alliance and bribe commitments can coexist with the preview; deferred overbid recovery, whole-turn answers and broader module support remain excluded.', evidence: ['game/choam-kull.ts', 'game/kull-purpose.ts', 'game/bribe-promises.ts', 'game/engine.ts', 'tests/kull-bid-runtime.test.ts', 'tests/kull-phase-bid-runtime.test.ts', 'tests/kull-truth-revival-runtime.test.ts', 'tests/kull-alliance-runtime.test.ts', 'tests/kull-richese-semuta-runtime.test.ts'] }, + { area: 'Implementation', status: 'Partial', detail: 'Selectable Kull binds typed intents, distinct physical counters and Basic/legacy all-purpose or new Advanced semantic-effect restrictions. Different effects remain playable; phase expiry is provisional in Advanced. Basic printed Kull admits native Richese, Ixians, Tleilaxu, Ecaz and Moritani; supported clean Kull discards offer Semuta before their suspended parent resumes. Phase-wide bid commitments can coexist with this preview including Richese; current-lot bid, Revival, alliance and bribe commitments remain limited to the non-Richese profile. Deferred overbid recovery, whole-turn answers and broader module support remain excluded.', evidence: ['game/choam-kull.ts', 'game/kull-purpose.ts', 'game/bribe-promises.ts', 'game/engine.ts', 'tests/kull-bid-runtime.test.ts', 'tests/kull-phase-bid-runtime.test.ts', 'tests/kull-richese-phase-bid-runtime.test.ts', 'tests/kull-truth-revival-runtime.test.ts', 'tests/kull-alliance-runtime.test.ts', 'tests/kull-richese-semuta-runtime.test.ts'] }, { area: 'Player controls', status: 'Partial', detail: 'Owner-only legal held costs and decline use the Kull event; counters reuse ordinary response controls. Public viewers receive purpose/actors, not private intent payloads or hidden choices.', evidence: ['components/choam-kull.tsx', 'components/game-table.tsx'] }, { area: 'AI', status: 'Partial', detail: 'Legal preview participation uses projected reactor choices and ordinary distinct counter controls. Full strategy and difficulty calibration remain deferred.', evidence: ['game/bot-choam-kull.ts', 'game/bots.ts'] }, { area: 'Documentation', status: 'Partial', detail: 'Pending versus active restrictions, distinct custody, decline/prevention/success, BG-before-conversion and deferred overbid limits have internal explanations. Publisher-source and full-faction acceptance remain separate.', evidence: ['docs/CHOAM_KULL_DESIGN.md', 'docs/CHOAM_KULL_SOURCE_UPDATE.md', 'docs/NEXUS_CHOAM_RULES.md'] }, diff --git a/game/turn-bid-promises.ts b/game/turn-bid-promises.ts index ed45b571..9be1661b 100644 --- a/game/turn-bid-promises.ts +++ b/game/turn-bid-promises.ts @@ -47,8 +47,8 @@ export function phaseBidPromiseModeSupported(game: Parameters player.faction === 'richese'); - if (basicRichese && game.kullPreview) return false; - return bidPromiseModeSupported(basicRichese ? { ...game, semutaPreview: undefined } : game); + return bidPromiseModeSupported(basicRichese ? { ...game, semutaPreview: undefined } : game, + {allowKullRichese: basicRichese && !!game.kullPreview}); } export function phaseBidClaimText(claim: PhaseBidClaim): string { diff --git a/tests/kull-phase-bid-runtime.test.ts b/tests/kull-phase-bid-runtime.test.ts index 0e7bb12e..0b5d8886 100644 --- a/tests/kull-phase-bid-runtime.test.ts +++ b/tests/kull-phase-bid-runtime.test.ts @@ -4,6 +4,8 @@ import { viewGame, type Game } from '../game/engine'; import { DIFFICULTIES } from '../game/bot-profiles'; import { botActions } from '../game/bots'; import { phaseBidPromiseModeSupported } from '../game/turn-bid-promises'; +import { bidPromiseModeSupported } from '../game/bid-promises'; +import { bribePromiseModeSupported } from '../game/bribe-promises'; import { act, advance, clean, createKullBribeFixture, inventory, player } from './fixture-kull-bribe'; /** The fixture selects physical cards in the unopened deal; the Truthtrance, @@ -68,10 +70,12 @@ void test('pre-bidding phase Yes cannot rely on an unfunded Karama bid in Kull p assert.deepEqual(inventory(game), f.originalCards); }); -void test('phase-wide Kull questions remain fenced with native Richese and Semuta', () => { +void test('phase-wide Kull questions admit the supported native Richese and Semuta profile', () => { const scope = {advanced:false, expansions:['choam','ix'], kullPreview:true, semutaPreview:true, players:[{faction:'choam'}, {faction:'richese'}]}; - assert.equal(phaseBidPromiseModeSupported(scope), false); + assert.equal(phaseBidPromiseModeSupported(scope), true); + assert.equal(bidPromiseModeSupported(scope), false); + assert.equal(bribePromiseModeSupported(scope), false); }); void test('phase-wide Yes survives a real Kull interception and completes its original bid', () => { diff --git a/tests/kull-richese-phase-bid-runtime.test.ts b/tests/kull-richese-phase-bid-runtime.test.ts new file mode 100644 index 00000000..80a22402 --- /dev/null +++ b/tests/kull-richese-phase-bid-runtime.test.ts @@ -0,0 +1,173 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { registerHooks } from 'node:module'; +import { readFileSync } from 'node:fs'; +import { createElement } from 'react'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine'; +import { botActions } from '../game/bots'; +import { DIFFICULTIES } from '../game/bot-profiles'; +import { SEMUTA_DRUG_ID } from '../game/semuta-drug'; +import { act, advance, clean, inventory, player } from './fixture-kull-richese-semuta'; + +const aliases = registerHooks({ + resolve(specifier, context, next) { + return next(specifier === 'next/image' ? 'vinext/shims/image' : + specifier === 'next/link' ? 'vinext/shims/link' : specifier, context); + }, + load(url, context, next) { + if (!url.endsWith('.module.css')) return next(url, context); + const css = readFileSync(new URL(url), 'utf8'); + const classes = Object.fromEntries([...css.matchAll(/\.([a-zA-Z_][\w-]*)/g)].map(match => [match[1], match[1]])); + return {format:'module', source:`export default ${JSON.stringify(classes)}`, shortCircuit:true}; + }, +}); +const {GameTable} = await import('../components/game-table'); +aliases.deregister(); + +/** Public Basic start and six original physical starting cards: only the + * unopened deal order and a safe unopened Spice position are selected. The + * Truthtrance answer, Richese cache auction, Kull and Semuta are real actions. */ +function fixture(answer: 'yes' | 'no') { + let game = createGame('KULLRICHBID', newPlayer('choam', 'CHOAM', 'choam'), false, ['choam', 'ix']); + for (const id of ['richese', 'emperor', 'harkonnen', 'guild'] as const) + joinGame(game, newPlayer(id, id, id)); + game = act(game, 'choam', {type:'moduleOption', module:'kullPreview', enabled:true}); + for (const p of game.players) game = act(game, p.id, {type:'ready'}); + game = act(game, 'choam', {type:'start'}); + assert.equal(game.status, 'setup'); + assert.ok(game.kullPreview && game.semutaPreview); + const originalCards = inventory(game), selected:Game['deck'] = []; + // Harkonnen receives two starting cards before the Guild's single draw. + for (const kind of ['kull', 'filler', 'karama', 'karama', 'filler', 'truth'] as const) { + const index = game.deck.findIndex(card => kind === 'kull' ? card.id === 'ix-kull-wahad' : + kind === 'truth' ? card.effect === 'truthtrance' : kind === 'karama' ? card.effect === 'karama' : + card.kind === 'worthless' && card.id !== 'ix-kull-wahad'); + assert.ok(index >= 0); selected.push(game.deck.splice(index, 1)[0]); + } + game.deck.unshift(...selected); + game = advance(game, state => state.status === 'playing'); + const [kull,,karama,counter,,truth] = selected.map(card => card.id); + for (const [id, card] of [['choam',kull], ['emperor',karama], ['harkonnen',counter], ['guild',truth]] as const) + assert.ok(player(game, id).hand.some(row => row.id === card), `${id} received original ${card}`); + const spice = game.spiceDeck.findIndex(card => 'territory' in card && !card.discovery); assert.ok(spice >= 0); + game.spiceDeck.unshift(game.spiceDeck.splice(spice, 1)[0]); + game = advance(game, state => state.phase === 2 && clean(state) && state.choamCharity?.turn === state.turn); + game = act(game, 'guild', {type:'card', card:truth}); + while (game.truthtrance?.stage === 'priority') { + const actor = game.players.find(seat => !game.truthtrance!.passed.includes(seat.id)); assert.ok(actor); + game = act(game, actor.id, {type:'truthPass'}); + } + game = act(game, 'guild', {type:'truthAsk', question:{kind:'phaseBid', target:'emperor', turn:game.turn, minimum:4}}); + assert.ok(viewGame(game, 'emperor').truthPhaseBidAnswers?.includes(answer)); + const html = renderToStaticMarkup(createElement(GameTable, { + game:viewGame(game, 'emperor'), busy:false, send:async () => {}, onExit() {}, + })); + assert.match(html, /Answer Yes/); + assert.match(html, /Answer No/); + for (const difficulty of DIFFICULTIES) { + const view = viewGame(game, 'emperor'); + view.players.find(seat => seat.id === 'emperor')!.bot = difficulty; + const action = botActions(view)[0]; + assert.equal(action?.type, 'truthAnswer', difficulty); + assert.ok(view.truthPhaseBidAnswers!.includes(action.answer as 'yes' | 'no' | 'unknown'), difficulty); + } + game = act(game, 'emperor', {type:'truthAnswer', answer}); + const event = game.phaseBidPromises!.find(row => row.player === 'emperor')!.event; + game = advance(game, state => player(state, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID) && + !!state.auction && state.auction.active === 'emperor' && clean(state)); + assert.ok(game.phaseBidPromises?.some(row => row.event === event && !row.fulfilled && !row.released), + 'The accepted answer survives Richese buying Semuta in its actual cache auction.'); + assert.deepEqual(inventory(game), originalCards); + return {game, originalCards, event, kull, karama, counter}; +} + +function declare(game:Game, kull:string, counter:string) { + const originalLot = game.auction!.cards[game.auction!.index].id; + const originalIndex = game.auction!.index; + game = act(game, 'harkonnen', {type:'card', mode:'purchase', card:counter}); + assert.equal(game.pendingKull?.stage, 'offer'); + const reaction = viewGame(game, 'choam').kullReaction; assert.ok(reaction); + assert.ok(reaction.plays.some(row => row.card.id === kull && !row.blocked)); + game = act(game, 'choam', {type:'kullDecision', event:reaction.event, source:'printed', card:kull}); + assert.equal(game.pendingKull?.stage, 'counter'); + return {game, originalLot, originalIndex}; +} + +function semuta(game:Game, card:string, claim:boolean):Game { + const pending = game.pendingTreacheryDiscard; assert.ok(pending, 'The original Kull or counter discard offers Semuta.'); + assert.equal(pending.reaction?.stage, 'offer'); + assert.equal(pending.batch.entries[0].card.id, card); + const event = pending.batch.event; + for (const difficulty of DIFFICULTIES) { + const view = viewGame(game, 'richese'); + view.players.find(seat => seat.id === 'richese')!.bot = difficulty; + const action = botActions(view)[0]; assert.ok(action, difficulty); + assert.ok(['semutaPass', 'semutaCommit'].includes(action.type), difficulty); + } + if (claim) { + assert.equal(viewGame(game, 'richese').semutaReaction?.canCommit, true); + game = act(game, 'richese', {type:'semutaCommit', event}); + if (game.pendingTreacheryDiscard?.reaction?.stage === 'select') + game = act(game, 'richese', {type:'semutaSelect', event, card}); + } else { + for (let count = 0; game.pendingTreacheryDiscard?.batch.event === event && count < game.players.length; count++) { + const reaction = game.pendingTreacheryDiscard!.reaction; assert.ok(reaction?.stage === 'offer'); + const actor = game.players.find(row => !reaction.passed.includes(row.id)); assert.ok(actor); + game = act(game, actor.id, {type:'semutaPass', event}); + } + } + assert.notEqual(game.pendingTreacheryDiscard?.batch.event, event); + return game; +} + +for (const claim of [false, true]) void test(`pre-Bidding phase Yes survives Richese cache and Kull success with Semuta ${claim ? 'claim' : 'pass'}`, () => { + const f = fixture('yes'); + const declared = declare(f.game, f.kull, f.counter); + let game = advance(declared.game, state => !!state.pendingTreacheryDiscard); + assert.ok(game.phaseBidPromises?.some(row => row.event === f.event && !row.fulfilled && !row.released)); + game = semuta(game, f.kull, claim); + game = advance(game, clean); + assert.equal(game.auction!.cards[game.auction!.index].id, declared.originalLot); + assert.ok(game.phaseBidPromises?.some(row => row.event === f.event && !row.fulfilled && !row.released)); + const guide = viewGame(game, 'emperor').phaseBidPromiseGuide; assert.ok(guide); + assert.equal(guide.action.type, 'bid'); assert.equal(guide.action.amount, 4); + game = act(game, 'emperor', guide.action); + assert.ok(game.phaseBidPromises?.some(row => row.event === f.event && row.fulfilled)); + assert.ok(player(game, 'harkonnen').hand.some(card => card.id === f.counter)); + assert.equal(player(game, 'richese').hand.some(card => card.id === f.kull), claim); + assert.deepEqual(inventory(game), f.originalCards); +}); + +for (const claim of [false, true]) void test(`countered Kull and Semuta ${claim ? 'claim' : 'pass'} keep a real later lot for phase Yes`, () => { + const f = fixture('yes'); + const declared = declare(f.game, f.kull, f.counter); + assert.ok(declared.game.auction!.cards[declared.originalIndex + 1]); + assert.ok(viewGame(declared.game, 'emperor').responseControls?.cancelCards?.includes(f.karama)); + let game = act(declared.game, 'emperor', {type:'card', mode:'cancel', card:f.karama}); + game = semuta(game, f.karama, claim); + game = advance(game, state => clean(state) && !!state.auction && + state.auction.index > declared.originalIndex && state.auction.active === 'emperor'); + assert.ok(game.phaseBidPromises?.some(row => row.event === f.event && !row.fulfilled && !row.released)); + assert.ok(player(game, 'harkonnen').hand.some(card => card.id === declared.originalLot)); + const guide = viewGame(game, 'emperor').phaseBidPromiseGuide; assert.ok(guide); + assert.equal(guide.action.type, 'bid'); assert.equal(guide.action.amount, 4); + game = act(game, 'emperor', guide.action); + assert.ok(game.phaseBidPromises?.some(row => row.event === f.event && row.fulfilled)); + assert.equal(player(game, 'richese').hand.some(card => card.id === f.karama), claim); + assert.deepEqual(inventory(game), f.originalCards); +}); + +void test('phase No remains binding through the real cache and Kull Semuta interruption', () => { + const f = fixture('no'); + const declared = declare(f.game, f.kull, f.counter); + let game = advance(declared.game, state => !!state.pendingTreacheryDiscard); + game = semuta(game, f.kull, false); + game = advance(game, clean); + const before = structuredClone(game); + assert.throws(() => act(game, 'emperor', {type:'bid', amount:4, allyPayment:0} as Action)); + assert.deepEqual(game, before); + game = act(game, 'emperor', {type:'bid', amount:3, allyPayment:0}); + assert.equal(game.auction?.bid, 3); + assert.deepEqual(inventory(game), f.originalCards); +}); diff --git a/tests/public-choam-kull-controls.test.tsx b/tests/public-choam-kull-controls.test.tsx index 888b0004..1075e7a1 100644 --- a/tests/public-choam-kull-controls.test.tsx +++ b/tests/public-choam-kull-controls.test.tsx @@ -33,7 +33,7 @@ void test('public host lobby shows the explicitly selected Kull preview and its assert.match(html,/Printed Kull is enabled by default/); assert.match(html,/Combined turn-action Truthtrance questions are unavailable/); assert.match(html,/Unfunded non-CHOAM Karama-dependent bids remain deferred/); - assert.match(html,/When Richese is seated, structured bid, alliance, Revival and bribe commitments are also unavailable/); + assert.match(html,/When Richese is seated, current-lot bid, alliance, Revival and bribe commitments are also unavailable/); const off = act(f.lobby,f.lobby.host,{type:'moduleOption',module:'kullPreview',enabled:false}); const unselected = viewGame(off,off.host); assert.equal(unselected.lobbyModules?.kullPreview,false);