diff --git a/components/phase-bid-claim-fields.tsx b/components/phase-bid-claim-fields.tsx index 3941ac7e..27012b9a 100644 --- a/components/phase-bid-claim-fields.tsx +++ b/components/phase-bid-claim-fields.tsx @@ -16,7 +16,7 @@ export function PhaseBidClaimFields(props: { }) { const error = phaseBidClaimInputError(props.value); return
- Bid during this turn + Ordinary auction bid during this turn

Turn {props.value.turn} · Remaining ordinary Bidding phase

{error &&

{error}

}

- This asks about one accepted bid of at least this size after the answer, - before Bidding ends this turn. Earlier bids do not count; it does not - promise a win or change the winning payment. + This asks about one accepted ordinary auction bid of at least this size + after the answer, before Bidding ends this turn. Richese cache and Black + Market bids do not count. Earlier bids do not count; it does not promise + a win or change the winning payment.

; } diff --git a/components/phase-bid-promises.tsx b/components/phase-bid-promises.tsx index 0f6553de..5c31288b 100644 --- a/components/phase-bid-promises.tsx +++ b/components/phase-bid-promises.tsx @@ -52,9 +52,10 @@ export function PhaseBidPromises(props: PhaseBidPromiseProps) { : promise.fulfilled ? ' Fulfilled: this commitment is complete.' : ' This answer is binding through this Bidding phase.'} )}

- Yes requires a qualifying future bid while it remains possible. No forbids - qualifying bids through Bidding close. A bid can fulfill Yes even if another - player wins; the original payment rules still apply. + Yes requires a qualifying future ordinary auction bid while it remains possible. + No forbids qualifying ordinary bids through Bidding close. Richese cache and + Black Market bids do not count. A bid can fulfill Yes even if another player + wins; the original payment rules still apply.

Earlier bids do not count. Ordinary auctions retain their original order and diff --git a/components/truthtrance.tsx b/components/truthtrance.tsx index e9188077..d83b9160 100644 --- a/components/truthtrance.tsx +++ b/components/truthtrance.tsx @@ -548,7 +548,7 @@ export function Truthtrance({ ) : w.question!.kind === 'phaseBid' ? ( <> -

Yes requires one qualifying ordinary bid before this turn’s Bidding closes while possible. No forbids all qualifying later bids. A bid does not promise a win; winning still requires payment.

+

Yes requires one qualifying ordinary bid before this turn’s Bidding closes while possible. No forbids qualifying later ordinary bids. Richese cache and Black Market bids do not count. A bid does not promise a win; winning still requires payment.

{(g.truthPhaseBidAnswers ?? []).map(answer =>
{button(`Answer ${answer === 'yes' ? 'Yes' : answer === 'no' ? 'No' : 'I don’t know'}`, { type: 'truthAnswer', answer })}
)} @@ -718,7 +718,7 @@ export function Truthtrance({ - + diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index 558decab..82cef8cd 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -17,14 +17,26 @@ open mode gates. ## Current checkpoint and work +**Advanced Black Market Truthtrance — 16 November. Prototyped / Partial.** +Simultaneous questions now receive the existing provisional Sapho ordering +opportunity during supported Normal, Once Around and Silent lots. Original +card custody, bids and funding remain in place; Advanced Semuta at the Sapho +discard remains open. Genuine Advanced tests also confirm that the previously +implemented single and mixed Richese bid questions work in Once Around and +Silent Black Market lots. Phase-wide questions currently count ordinary bids +only, and the question and controls now say so. Nine related test files pass +53 cases. Full games, combinations and +deployed acceptance remain open. [Sapho scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026), +[mixed bid scope](TRUTHTRANCE_MIXED_BIDS.md#current-facts-and-richese-bids--16-november-2026). + **Mixed Truthtrance facts and Richese bids — 16 November. Prototyped / Partial.** Players can combine answer-time facts and a future bid in a -supported Once Around or Silent Richese cache lot. Native bid funding, one-declaration +supported Once Around or Silent Richese cache or Advanced Black Market lot. Native bid funding, one-declaration timing, card custody, sealed bids and settlement remain authoritative; questions settled by facts create no bid obligation. Player editing, own aggregate guidance and minimal legal bots are connected. Ten related unit -files pass 77 cases. Black Market -and phase-wide mixed questions, optional modules, complete games and deployed +files pass 77 cases. Normal Black Market and phase-wide mixed questions, +optional modules, complete games and deployed acceptance remain open. [Scope](TRUTHTRANCE_MIXED_BIDS.md#current-facts-and-richese-bids--16-november-2026). **Advanced Black Market gifts and Bene Gesserit arrivals — 16 November. diff --git a/docs/JUICE_OF_SAPHO_RUNTIME.md b/docs/JUICE_OF_SAPHO_RUNTIME.md index 886910c1..87b69221 100644 --- a/docs/JUICE_OF_SAPHO_RUNTIME.md +++ b/docs/JUICE_OF_SAPHO_RUNTIME.md @@ -1,5 +1,23 @@ # Juice of Sapho: finite ordering implementation +## Truthtrance order in Advanced Black Market — 16 November 2026 + +**Prototyped / Partial.** The shared opportunity to reorder simultaneous +Truthtrance questions now also opens during a clean Advanced Black Market +lot, using Normal, Once Around or Silent bidding. It keeps the original seller's +reserved physical card, lot, standing bids, funding, order and sealed submissions +while questions resolve. Silent amounts remain private until their native +reveal. Sapho may not spend the card reserved for sale. These online priorities +remain provisional under the authority described below; they are not a +publisher clarification. + +Advanced Sapho currently uses its existing synchronous discard; the separate +Advanced Semuta reaction to this cost is not implemented by this extension. +Other optional combinations, complete games and deployed acceptance remain open. +The [public-start cases](../tests/sapho-truth-black-market-runtime.test.ts) +use real setup and sale actions, with disclosed conserved card swaps for Sapho +and a second Truthtrance. + ## Shared Ambassador and Terror arrival — 29 October 2026 **Prototyped / Partial.** In a supported fresh Basic Richese game, an ordinary diff --git a/docs/RULE_DECISIONS.md b/docs/RULE_DECISIONS.md index 3c2d26ed..817ba812 100644 --- a/docs/RULE_DECISIONS.md +++ b/docs/RULE_DECISIONS.md @@ -1,9 +1,17 @@ # Rule decision index +## Advanced Black Market Truthtrance order — 16 November 2026 + +The existing provisional Sapho order for simultaneous questions extends to +clean Advanced Black Market auctions with their original lot and funding. +Advanced Semuta at this discard remains open. +[Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026). + ## Mixed current facts and Richese bids — 16 November 2026 The existing provisional mixed question and native one-declaration Richese bid -semantics compose in supported Once Around and Silent cache lots. The actual lot, +semantics compose in supported Once Around and Silent cache and Advanced +Black Market lots. The actual lot, funding, sealed bids and original settlement remain authoritative. [Scope](TRUTHTRANCE_MIXED_BIDS.md#current-facts-and-richese-bids--16-november-2026). diff --git a/docs/TRUTHTRANCE_MIXED_BIDS.md b/docs/TRUTHTRANCE_MIXED_BIDS.md index ec370bfd..5c0d78d2 100644 --- a/docs/TRUTHTRANCE_MIXED_BIDS.md +++ b/docs/TRUTHTRANCE_MIXED_BIDS.md @@ -4,7 +4,7 @@ **Prototyped / Partial.** A separate event-bound `mixedRicheseBid` question combines current facts with a future declaration in the same supported Once -Around or Silent Richese cache lot. The original question and whole answer remain +Around or Silent Richese cache or Advanced Black Market lot. The original question and whole answer remain visible to its respondent; frozen fact values and the reduced native threshold are not separately projected. The shared compiler snapshots facts at the answer, and the existing Richese commitment enforces funding, eligibility, @@ -21,8 +21,10 @@ unopened deal and Spice order. The structured editor, own status and native guide are connected; bots use the same feasible answers and guide. Ten related unit files pass 77 cases, including [runtime](../tests/truth-mixed-richese-bid-runtime.test.ts), [controls](../tests/truth-mixed-richese-bid-controls.test.tsx) and -[reduction](../tests/mixed-richese-bid-question.test.ts). Black Market -bidding, phase-wide mixed questions, optional modules, broader combined +[reduction](../tests/mixed-richese-bid-question.test.ts). Later +[Black Market public-start cases](../tests/truth-black-market-bid-runtime.test.ts) +confirm the existing Once Around and Silent implementation, including seller +retention and sealed privacy. Normal Black Market bidding, phase-wide mixed questions, optional modules, broader combined commitments, full games and deployed acceptance remain open. ## Mixed aggregate prototype — 26 October 2026 diff --git a/game/reference.ts b/game/reference.ts index 43415ebb..e9845f6b 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -514,7 +514,7 @@ export const RULE_TOPICS: RuleTopic[] = [ 'If you recover the physical Sapho after choosing Last, you may use it again to choose First, including after suspending your own started turn. This provisionally replaces your own Last protection without restoring spent actions. Completed turns stay complete and a different started current actor finishes first. Another holder cannot replace your protected Last.', 'Between completed battles, choose first or last among remaining battle choosers. The priority lasts for the rest of the Battle phase. You still need a real unresolved battle. Others may choose battles against you before your own turn; last is not immunity. This scope changes the chooser, not each battle’s aggressor or tie advantage.', 'In a fresh Richese battle, use unreserved Sapho at a clean boundary before both combatants finish final battle actions, including after sealed plans and revealed declarations. Habbanya still precedes ordinary aggressor tie priority. Participants, plans, promises, weapon choices and votes do not swap or replay. Older battles retain their pre-plan opportunity.', - 'When two or more players declared Truthtrance in a supported clean parent, each queued holder may continue or use their held Sapho to move their entire pending question group first or last. Physical storm order and each holder’s card order stay unchanged. Supported Semuta claim/pass restores the same question queue, including the selected Homeworld, Leader Skills and Discovery profiles. Clean ordinary auction lots also preserve their standing bid and remaining clock. Richese cache Once Around and Silent lots preserve their original bidding and funding; Black Market, other special auctions and pending-parent combinations remain unfinished.', + 'When two or more players declared Truthtrance in a supported clean parent, each queued holder may continue or use their held Sapho to move their entire pending question group first or last. Physical storm order and each holder’s card order stay unchanged. Supported Semuta claim/pass restores the same question queue, including the selected Homeworld, Leader Skills and Discovery profiles. Clean ordinary auction lots also preserve their standing bid and remaining clock. Richese cache Once Around and Silent lots and Advanced Black Market lots preserve their original bidding and funding. The Advanced Black Market Sapho discard does not yet offer its Semuta reaction; other special auctions and pending-parent combinations remain unfinished.', 'During a clean native Extortion payer decision, use Sapho to take your optional choice first/last among unanswered non-Moritani players. Earlier declines, collected bank5 and the one-payment3 limit remain. The next payer event changes even when that player stays next. You may decline instead of paying.', 'Before either of two Ecological Testing Station occupants chooses, use Sapho to take your adjustment first or last if that changes the order. Fresh choices with Richese seated give both occupants a shared opportunity to use an available order change or continue; an automated occupant cannot advance the station choice while another player is deciding. Each occupant still adjusts the cumulative storm distance once. Physical storm order and its original source stay unchanged. In supported Semuta games, claim or pass resumes the same next choice. Replay of a recovered Sapho remains unfinished; this online priority is provisional.', 'During ordered Advanced Charity, take your remaining turn first or last, then discard Sapho. An accepted current claim provisionally protects that actor while another holder reorders only later unstarted turns. At a clean boundary, the holder may pause its own claimed turn and resume last without repeating the claim or payment. Completed turns stay closed and physical First Player order is unchanged. Basic and older concurrent phases have no ordered scope.', @@ -3757,7 +3757,7 @@ export const RULE_TOPICS: RuleTopic[] = [ category: 'Cards', coverage: 'Partial', developmentStage: 'Prototyped', - summary: 'Combine answer-time facts with future accepted bid declarations in a supported ordinary or Richese cache lot, preserving native funding and payment.', + summary: 'Combine answer-time facts with future accepted bid declarations in a supported ordinary or Richese lot, preserving native funding and payment.', steps: [ 'Choose Combine current facts and ordinary bids. Add full AND/OR groups with at least one current fact and one bid minimum. The fixed public turn and current ordinary lot apply to every bid condition; nested facts share the sixteen-condition, four-level input limit.', 'Current facts freeze at the actual answer. A statement that you hold at least10 spice remains that answer-time fact after the winning purchase leaves6. The answer does not require preserving the same resources afterward.', @@ -3765,8 +3765,8 @@ export const RULE_TOPICS: RuleTopic[] = [ 'A fact may already settle the aggregate, needing no bid. Otherwise only future accepted declarations in this exact lot count. Two smaller bids never add into a larger bid. A qualifying declaration fulfills Yes even when another bidder eventually wins; the original winning payment remains separate.', 'All remaining minima concern one future bid interval. Satisfying two minima requires the larger; satisfying either requires the smaller. This exact reduction retains every legal amount. No forbids qualifying later declarations through actual lot close.', 'Native current funds, prepaid allied aid, Karama overbidding, capacity, active/waiting eligibility, earlier commitments and release order remain. The answer grants no new opportunity, spice or free purchase and assumes no future rival raise.', - 'In a supported Richese Once Around or Silent cache auction, choose Combine current facts and a Richese bid. Facts freeze on answer and bid conditions address your one remaining accepted declaration in that exact lot. The original funding, auction order and winning payment remain; Silent bids stay sealed until their normal reveal.', - 'Raw editing/preview/Ask, private answers, own aggregate status and one exact native bid/pass guide connect to four minimal policies. Fulfilled history does not duplicate or suppress a live guide. Phase-wide questions, Black Market bids, other action families and broader compositions remain unfinished.', + 'In a supported Richese Once Around or Silent cache or Advanced Black Market auction, choose Combine current facts and a Richese bid. Facts freeze on answer and bid conditions address your one remaining accepted declaration in that exact lot. The original funding, auction order and winning payment remain; Silent bids stay sealed until their normal reveal.', + 'Raw editing/preview/Ask, private answers, own aggregate status and one exact native bid/pass guide connect to four minimal policies. Fulfilled history does not duplicate or suppress a live guide. Phase-wide questions, normal Black Market bids, other action families and broader compositions remain unfinished.', ], related: ['card-truthtrance', 'truthtrance-bid', 'truthtrance-mixed-revival', 'implementation-checklist'], checklist: [ @@ -3787,7 +3787,7 @@ export const RULE_TOPICS: RuleTopic[] = [ steps: [ 'Choose Bind a bid in this ordinary lot, another remaining eligible bidder and a positive whole spice minimum. The turn and lot are fixed. Registered native Basic and Advanced tables without optional modules are supported first; broader compositions remain unfinished.', 'In a quiet Richese Once Around auction, choose Bind a bid in this Once Around lot to bind the respondent’s one remaining bid or pass. A waiting Richese owner cannot promise Yes until an actual bid ensures an owner turn. Current hand space, funds and pledged aid remain required; an opposing raise can release an impossible Yes. Normal special auctions remain outside this prototype.', - 'Alternatively choose Bind a bid this Bidding phase. Yes requires one qualifying accepted ordinary bid after the answer and before Bidding closes; No forbids qualifying later ordinary bids across lots. Earlier bids do not count, and a bid does not promise a win.', + 'Alternatively choose Bind an ordinary bid this Bidding phase. Yes requires one qualifying accepted ordinary bid after the answer and before Bidding closes; No forbids qualifying later ordinary bids across lots. Earlier bids do not count, and a bid does not promise a win.', 'In a Silent Richese lot the question binds the respondent’s single sealed submission. Zero declines; a positive bid remains hidden until the native simultaneous reveal. Available answers use that bidder’s own funding, without using opponents’ concealed amounts.', 'Before Basic Bidding, ask about a minimum bid in the first actual Richese cache auction of this turn. The answer waits for the real event and does not predict its card or method. Current uncommitted personal funds and hand space supply a conservative Yes witness; cancellation or an opposing action can release an impossible commitment. The Richese owner’s Once Around turn may vanish if everyone else passes.', 'Your waiting cache commitment remains visible until its auction opens or it ends. Once the real lot opens, the ordinary Richese bid guide takes over.', diff --git a/game/truthtrance.ts b/game/truthtrance.ts index 33a61353..0dcf2f46 100644 --- a/game/truthtrance.ts +++ b/game/truthtrance.ts @@ -1609,12 +1609,14 @@ export function resolveTruthAction( // decision to open it never inspects who holds Juice of Sapho. const ordinaryLot = g.phase === 3 && !!g.auction?.cards[g.auction.index] && !!g.auction.active && !g.currentAuctionSale && !g.ixAuction; - const richeseCacheLot = g.phase === 3 && !!g.richeseAuction && g.richeseAuction.source === 'cache' && - (g.richeseAuction.method === 'onceAround' || g.richeseAuction.method === 'silent') && + const richeseLot = g.phase === 3 && !!g.richeseAuction && + (g.richeseAuction.source === 'cache' && (g.richeseAuction.method === 'onceAround' || g.richeseAuction.method === 'silent') || + g.advanced && g.richeseAuction.source === 'blackMarket' && + ['normal','onceAround','silent'].includes(g.richeseAuction.method)) && !g.richeseAuction.outcome && !g.currentAuctionSale && !g.auction && !g.ixAuction; const clean = g.status === 'playing' && g.expansions.includes('choam') && !g.response && !g.decision && !g.phaseOpening && !g.pendingKarama && !g.pendingTreacheryDiscard && !g.pendingNullentropy && (!g.auction || ordinaryLot) && - (!g.richeseAuction || richeseCacheLot) && + (!g.richeseAuction || richeseLot) && (!g.battle || g.phase === 6 && !!g.battle.event && !g.battle.revealed && !g.battle.preparation && !g.pendingWinnerDiscards && !g.pendingCapture && !g.pendingTech && !g.pendingFaceDance && !g.pendingIxSubstitution) && !g.pendingRevival && !g.pendingShipment && diff --git a/game/turn-bid-promises.ts b/game/turn-bid-promises.ts index 9be1661b..e3414a9c 100644 --- a/game/turn-bid-promises.ts +++ b/game/turn-bid-promises.ts @@ -52,7 +52,7 @@ export function phaseBidPromiseModeSupported(game: Parameters { const p = game.players.find(row => row.id === id); assert.ok(p); return p; }; +type Method = 'normal' | 'onceAround' | 'silent'; + +/** Genuine Advanced R/A/E setup and live Black Market. Controlled conserved + * supplements swap original cached Sapho for Emperor's held card and move an + * undealt physical Truth to Emperor; the actual starting Truth stays Atreides'. */ +function fixture(method: Method) { + const source = createTruthtranceRichesePromisesFixture({advanced:true}); + let game = structuredClone(source.game); + const emperor = player(game,'emperor'), atreides = player(game,'atreides'); + const cache = game.richeseCache!; + const at = cache.findIndex(card => card.effect === 'juiceOfSapho'); assert.ok(at >= 0); + const [sapho] = cache.splice(at,1), [swap] = emperor.hand.splice(0,1); + emperor.hand.push(sapho); cache.push(swap); + const truthAt = game.deck.findIndex(card => card.effect === 'truthtrance'); assert.ok(truthAt >= 0); + const [truth] = game.deck.splice(truthAt,1); emperor.hand.push(truth); + const otherTruth = atreides.hand.find(card => card.effect === 'truthtrance'); assert.ok(otherTruth); + assert.deepEqual(inventory(game),source.originalCards); + game = advance(game,state => state.decision?.kind === 'richeseBlackMarket'); + const offered = player(game,'richese').hand.find(card => card.name === 'Shield'); assert.ok(offered); + game = act(game,'richese',{type:'decision',event:game.richeseBidding!.event,card:offered.id,method, + ...(method === 'onceAround' ? {direction:'clockwise'} : {})}); + for (let n=0; game.response && n<20; n++) { + const actor = game.players.find(row => !game.response!.passed.includes(row.id)); assert.ok(actor); + game = act(game,actor.id,{type:'passResponse'}); + } + const lot = game.richeseAuction; assert.ok(lot && lot.source === 'blackMarket' && lot.method === method); + const bidder = method === 'silent' ? 'richese' : lot.active; assert.ok(bidder); + game = act(game,bidder,{type:'richeseBid',event:lot.event,amount:1,allyPayment:0}); + assert.ok(game.richeseAuction && !game.richeseAuction.outcome); + const parent = structuredClone({turn:game.turn,phase:game.phase,active:game.active,order:game.order, + lot:game.richeseAuction,round:game.richeseBidding,funding:game.richeseFunding,aid:game.aid, + offered:game.richeseOfferedCard,sellerHand:player(game,'richese').hand}); + for (const [actor,card] of [['emperor',truth.id],['atreides',otherTruth.id]] as const) + game = act(game,actor,{type:'card',card}); + while (game.truthtrance?.stage === 'priority') { + const actor = game.players.find(row => !game.truthtrance!.passed.includes(row.id)); assert.ok(actor); + game = act(game,actor.id,{type:'truthPass'}); + } + const current = frame(game); + const mode: 'first' | 'last' = game.truthtrance!.queue[0].player === 'emperor' ? 'last' : 'first'; + return {game,lot:lot.event,offered:offered.id,card:sapho.id,bidder,mode,parent,original:source.originalCards,current}; +} +function assertParent(game: Game, f: ReturnType) { + assert.deepEqual({turn:game.turn,phase:game.phase,active:game.active,order:game.order, + lot:game.richeseAuction,round:game.richeseBidding,funding:game.richeseFunding,aid:game.aid, + offered:game.richeseOfferedCard,sellerHand:player(game,'richese').hand},f.parent); + assert.ok(player(game,'richese').hand.some(card => card.id === f.offered)); +} +function assertSilent(game: Game, bidder: string) { + const ownerView = viewGame(game,bidder).richeseAuction!, otherView = viewGame(game,'emperor').richeseAuction!; + assert.equal(ownerView.ownBid,1); assert.equal(otherView.ownBid,null); + assert.equal(otherView.revealedBids,null); assert.equal('sealed' in otherView,false); +} +for (const method of ['normal','onceAround','silent'] as const) void test( + `Advanced ${method} Black Market retains its original lot when Sapho orders real Truth questions`, () => { + const f = fixture(method), before = structuredClone(f.game); + assertParent(f.game,f); + if (method === 'silent') assertSilent(f.game,f.bidder); + const offered = viewGame(f.game,'emperor').saphoTruthOrderChoices; + assert.ok(offered.some(row => row.card === f.card && row.mode === f.mode)); + reject(f.game,'emperor',{type:'saphoTruthOrder',card:f.card,event:'stale',revision:f.current.revision,mode:f.mode}); + reject(f.game,'emperor',{type:'saphoTruthOrder',card:f.card,event:f.current.event,revision:f.current.revision+1,mode:f.mode}); + for (const difficulty of DIFFICULTIES) { + const view = viewGame(before,'emperor'); view.players.find(row => row.id === 'emperor')!.bot = difficulty; + const action = botActions(view)[0]; assert.ok(action,difficulty); + assert.ok(action.type === 'truthOrderPass' || action.type === 'saphoTruthOrder'); + assert.doesNotThrow(() => act(before,'emperor',action)); + } + let game = play(f.game,'emperor',f.card,f.mode); + assertParent(game,f); + if (method === 'silent') assertSilent(game,f.bidder); + game = finish(game); + assert.equal(f.mode === 'first' ? game.truthtrance!.queue[0].player : game.truthtrance!.queue.at(-1)!.player,'emperor'); + game = answer(game); assert.equal(game.truthtrance,null); assertParent(game,f); + assert.deepEqual(inventory(game),f.original); + if (method === 'silent') assertSilent(game,f.bidder); + const lot = game.richeseAuction!; + const next = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active; + assert.ok(next); + const action: Action = {type:'richeseBid',event:f.lot,amount:method === 'silent' ? 0 : null,allyPayment:0}; + game = act(game,next,action); + assert.deepEqual(inventory(game),f.original); + }); + +void test('a Black Market seller cannot spend their offered Sapho to reorder their own queued Truth', () => { + const source = createTruthtranceRichesePromisesFixture({advanced:true}); + let game = structuredClone(source.game); + const seller = player(game,'richese'), cache = game.richeseCache!; + const at = cache.findIndex(card => card.effect === 'juiceOfSapho'); assert.ok(at >= 0); + const [sapho] = cache.splice(at,1), [swap] = seller.hand.splice(0,1); + seller.hand.push(sapho); cache.push(swap); + const truthAt = game.deck.findIndex(card => card.effect === 'truthtrance'); assert.ok(truthAt >= 0); + const [sellerTruth] = game.deck.splice(truthAt,1); seller.hand.push(sellerTruth); + const otherTruth = player(game,'atreides').hand.find(card => card.effect === 'truthtrance'); assert.ok(otherTruth); + assert.deepEqual(inventory(game),source.originalCards); + game = advance(game,state => state.decision?.kind === 'richeseBlackMarket'); + game = act(game,'richese',{type:'decision',event:game.richeseBidding!.event,card:sapho.id,method:'silent'}); + for (let n=0; game.response && n<20; n++) { + const actor = game.players.find(row => !game.response!.passed.includes(row.id)); assert.ok(actor); + game = act(game,actor.id,{type:'passResponse'}); + } + const lot = game.richeseAuction; assert.ok(lot && lot.cardId === sapho.id); + game = act(game,'emperor',{type:'richeseBid',event:lot.event,amount:1,allyPayment:0}); + for (const [actor,card] of [['richese',sellerTruth.id],['atreides',otherTruth.id]] as const) + game = act(game,actor,{type:'card',card}); + while (game.truthtrance?.stage === 'priority') { + const actor = game.players.find(row => !game.truthtrance!.passed.includes(row.id)); assert.ok(actor); + game = act(game,actor.id,{type:'truthPass'}); + } + const order = frame(game); + assert.ok(order.holders.includes('richese')); + assert.deepEqual(viewGame(game,'richese').saphoTruthOrderChoices,[]); + for (const mode of ['first','last'] as const) + reject(game,'richese',{type:'saphoTruthOrder',card:sapho.id,event:order.event,revision:order.revision,mode}); + assert.ok(player(game,'richese').hand.some(card => card.id === sapho.id)); + assert.equal(game.richeseAuction?.cardId,sapho.id); + game = finish(game); game = answer(game); + assert.ok(player(game,'richese').hand.some(card => card.id === sapho.id)); + assert.equal(game.richeseAuction?.cardId,sapho.id); + assert.deepEqual(inventory(game),source.originalCards); +}); diff --git a/tests/truth-black-market-bid-runtime.test.ts b/tests/truth-black-market-bid-runtime.test.ts new file mode 100644 index 00000000..e84bb375 --- /dev/null +++ b/tests/truth-black-market-bid-runtime.test.ts @@ -0,0 +1,151 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { botActions } from '../game/bots'; +import { DIFFICULTIES } from '../game/bot-profiles'; +import { viewGame, type Action, type Game } from '../game/engine'; +import { + actTruthtranceRichesePromises as act, + advanceTruthtranceRichesePromises as advance, + createTruthtranceRichesePromisesFixture, + passTruthRicheseFreshDiscard, + truthtranceRichesePromisesInventory as inventory, + truthtranceRichesePromisesPlayer as player, +} from './fixture-truthtrance-richese-promises'; + +type Method = 'onceAround' | 'silent'; +type QuestionKind = 'richeseBid' | 'mixedRicheseBid'; + +/** Original Advanced R/A/E setup, starting deal and Charity. Only the + * fixture's disclosed unopened deal/Spice order and scalar rolls are staged; + * Richese offers the physical Shield actually dealt into its own hand. */ +function fixture(method: Method) { + const source = createTruthtranceRichesePromisesFixture({advanced:true}); + let game = advance(structuredClone(source.earlySource), state => state.decision?.kind === 'richeseBlackMarket'); + const card = source.targetCard, event = game.richeseBidding!.event; + assert.ok(player(game,source.richese).hand.some(held => held.id === card)); + game = act(game,source.richese,{type:'decision',event,card,method, + ...(method === 'onceAround' ? {direction:'clockwise'} : {})}); + while (game.response) { + const seat = game.players.find(row => !game.response!.passed.includes(row.id)); assert.ok(seat); + game = act(game,seat.id,{type:'passResponse'}); + } + assert.equal(game.richeseAuction?.source,'blackMarket'); + assert.equal(game.richeseAuction?.method,method); + assert.equal(viewGame(game,source.richese).richeseAuction?.card?.id,card); + assert.equal(viewGame(game,source.asker).richeseAuction?.card?.id,game.richesePeekKnown ? card : undefined); + assert.equal(viewGame(game,source.emperor).richeseAuction?.card,null); + assert.ok(player(game,source.asker).hand.some(held => held.id === source.truth)); + assert.deepEqual(inventory(game),source.originalCards); + return {game,asker:source.asker,target:source.emperor,owner:source.richese, + truth:source.truth,card,lot:game.richeseAuction!.event,originalCards:source.originalCards}; +} + +function reject(game:Game,actor:string,action:Action) { + const before=structuredClone(game); assert.throws(() => act(game,actor,action)); assert.deepEqual(game,before); +} +function ask(f:ReturnType,kind:QuestionKind) { + let game=act(f.game,f.asker,{type:'card',card:f.truth}); + while (game.truthtrance?.stage === 'priority') { + const seat=game.players.find(row => !game.truthtrance!.passed.includes(row.id)); assert.ok(seat); + game=act(game,seat.id,{type:'truthPass'}); + } + assert.equal(game.truthtrance?.stage,'ask'); + const question = kind === 'richeseBid' + ? {kind,target:f.target,turn:game.turn,event:f.lot,minimum:4} + : {kind,target:f.target,turn:game.turn,event:f.lot,mixed:{kind:'and',terms:[ + {kind:'fact',fact:{kind:'spice',compare:'gte',value:10}}, + {kind:'action',action:{minimum:4}}, + ]}}; + return act(game,f.asker,{type:'truthAsk',question}); +} + +for (const method of ['onceAround','silent'] as const) + for (const kind of ['richeseBid','mixedRicheseBid'] as const) + for (const answer of ['yes','no'] as const) void test( + `Advanced ${method} Black Market ${kind} ${answer} retains the original sale`,() => { + const f=fixture(method), asked=ask(f,kind); + assert.equal(viewGame(asked,f.asker).richeseAuction?.card?.id,asked.richesePeekKnown ? f.card : undefined); + assert.equal(viewGame(asked,f.target).richeseAuction?.card,null); + assert.equal(viewGame(asked,f.owner).richeseAuction?.card?.id,f.card); + const answerView=viewGame(asked,f.target); + const answers=kind === 'richeseBid' ? answerView.truthRicheseBidAnswers : answerView.truthMixedRicheseBidAnswers; + assert.ok(answers?.includes(answer)); + assert.equal(player(asked,f.target).spice,10); + for (const difficulty of DIFFICULTIES) { + const botView=viewGame(asked,f.target); botView.players.find(row => row.id === f.target)!.bot=difficulty; + const choice=botActions(botView)[0]; assert.equal(choice?.type,'truthAnswer',difficulty); + assert.ok(answers?.includes(choice.answer as 'yes'|'no'|'unknown')); + } + let game=passTruthRicheseFreshDiscard(act(asked,f.target,{type:'truthAnswer',answer})); + assert.equal(game.richeseAuction?.event,f.lot); + assert.ok(player(game,f.owner).hand.some(held => held.id === f.card)); + if (method === 'onceAround') { + while (game.richeseAuction?.event === f.lot && game.richeseAuction.active !== f.target) { + const actor=game.richeseAuction.active; assert.ok(actor); assert.notEqual(actor,f.owner); + game=act(game,actor,{type:'richeseBid',event:f.lot,amount:null}); + } + } + const guide=viewGame(game,f.target).richeseBidPromiseGuide; assert.ok(guide); + reject(game,f.target,{...guide.action,richeseBidPromiseId:'stale-promise'}); + reject(game,f.target,{type:'richeseBid',event:f.lot,amount:answer === 'yes' ? 3 : 4,allyPayment:0}); + const amount=answer === 'yes' ? 4 : 2; + const beforeBuyer=player(game,f.target).spice, beforeSeller=player(game,f.owner).spice; + game=act(game,f.target,{type:'richeseBid',event:f.lot,amount,allyPayment:0}); + assert.equal(player(game,f.target).spice,beforeBuyer,'Declaring does not pay the winning invoice'); + if (method === 'silent') { + assert.equal(viewGame(game,f.target).richeseAuction?.ownBid,amount); + assert.equal(viewGame(game,f.owner).richeseAuction?.ownBid,null); + assert.equal(viewGame(game,f.owner).richeseAuction?.revealedBids,null); + assert.ok(player(game,f.owner).hand.some(held => held.id === f.card)); + for (const id of [f.asker,f.owner]) + game=act(game,id,{type:'richeseBid',event:f.lot,amount:0,allyPayment:0}); + } else { + while (game.richeseAuction?.event === f.lot && !game.richeseAuction.outcome) { + const actor=game.richeseAuction.active; assert.ok(actor); + game=act(game,actor,{type:'richeseBid',event:f.lot,amount:null}); + } + } + assert.ok(player(game,f.target).hand.some(held => held.id === f.card)); + assert.ok(!player(game,f.owner).hand.some(held => held.id === f.card)); + assert.equal(player(game,f.target).spice,beforeBuyer-amount); + assert.equal(player(game,f.owner).spice,beforeSeller+amount); + assert.equal(game.discard.filter(held => held.id === f.truth).length,1); + assert.deepEqual(inventory(game),f.originalCards); + }); + +for (const method of ['onceAround','silent'] as const) void test( + `Advanced ${method} seller honors a Truthtrance Yes and retains its physical Black Market card`,() => { + const original=fixture(method); + let game=original.game; + if (method === 'onceAround') { + const first=game.richeseAuction!.active; assert.ok(first); assert.notEqual(first,original.owner); + game=act(game,first,{type:'richeseBid',event:original.lot,amount:1,allyPayment:0}); + } + const f={...original,game,target:original.owner}; + const asked=ask(f,'richeseBid'); + assert.ok(viewGame(asked,f.target).truthRicheseBidAnswers?.includes('yes')); + game=passTruthRicheseFreshDiscard(act(asked,f.target,{type:'truthAnswer',answer:'yes'})); + const beforeHand=player(game,f.owner).hand.map(card => card.id); + const beforeSeller=player(game,f.owner).spice, beforeEmperor=player(game,original.target).spice; + if (method === 'onceAround') { + while (game.richeseAuction?.event === f.lot && game.richeseAuction.active !== f.owner) { + const actor=game.richeseAuction.active; assert.ok(actor); + game=act(game,actor,{type:'richeseBid',event:f.lot,amount:null}); + } + } + const guide=viewGame(game,f.owner).richeseBidPromiseGuide; assert.ok(guide); + assert.equal(guide.action.amount,4); + game=act(game,f.owner,guide.action); + if (method === 'silent') { + assert.equal(viewGame(game,f.asker).richeseAuction?.ownBid,null); + assert.equal(viewGame(game,f.asker).richeseAuction?.revealedBids,null); + assert.deepEqual(player(game,f.owner).hand.map(card => card.id),beforeHand); + for (const actor of [f.asker,original.target]) + game=act(game,actor,{type:'richeseBid',event:f.lot,amount:0,allyPayment:0}); + } + assert.deepEqual(player(game,f.owner).hand.map(card => card.id),beforeHand); + assert.equal(player(game,f.owner).spice,beforeSeller-4); + assert.equal(player(game,original.target).spice,beforeEmperor+4); + assert.equal(game.richeseBidding?.blackMarketSold,true); + assert.deepEqual(inventory(game),f.originalCards); + }); diff --git a/tests/truth-phase-bid-controls.test.tsx b/tests/truth-phase-bid-controls.test.tsx index b8fd421d..af2efa9d 100644 --- a/tests/truth-phase-bid-controls.test.tsx +++ b/tests/truth-phase-bid-controls.test.tsx @@ -39,6 +39,8 @@ void test('phase bid editor preserves the current turn and accepts only whole po const props = { value, onChange(next: PhaseBidClaim) { changes.push(next); } }; const html = renderToStaticMarkup(createElement(PhaseBidClaimFields, props)); assert.match(html, /Turn 2/); + assert.match(html, /ordinary auction bid/); + assert.match(html, /Richese cache and Black Market bids do not count/); assert.match(html, /before Bidding ends this turn/); assert.match(html, /Earlier bids do not count/); for (const minimum of [1, 7, Number.MAX_SAFE_INTEGER]) edit(props, minimum); @@ -62,7 +64,8 @@ void test('phase promises remain visible and do not expose another player’s pr const before = structuredClone(game); const html = renderToStaticMarkup(createElement(PhaseBidPromises, { game, busy: false, send() {} })); assert.match(html, /Your Bidding phase promises/); - assert.match(html, /No forbids qualifying bids through Bidding close/); + assert.match(html, /No forbids qualifying ordinary bids through Bidding close/); + assert.match(html, /Richese cache and Black Market bids do not count/); assert.match(html, /Fulfilled: this commitment is complete/); assert.match(html, /Released: this commitment is no longer possible/); assert.match(html, /Your next bid opportunity is still ahead/); diff --git a/tests/truth-phase-bid-integrated-controls.test.tsx b/tests/truth-phase-bid-integrated-controls.test.tsx index 6dc661f8..2724d18e 100644 --- a/tests/truth-phase-bid-integrated-controls.test.tsx +++ b/tests/truth-phase-bid-integrated-controls.test.tsx @@ -40,8 +40,8 @@ for (const advanced of [false, true]) void test( const asker = viewGame(b.declared.game, f.asker); assert.ok(asker.truthPhaseBidTargets.includes(f.target)); const authored = truth(asker); - assert.match(authored, /