Support Advanced Semuta at Truthtrance auction answers
Verify and publish checkpoint container / container (push) Successful in 11m23s

This commit is contained in:
Quintine committed 2026-11-16 19:00:42 +11:00
1 parent dd4222ee92
commit 12060f3112
7 files changed
+383 -12

No files matched your search

+12 -2
View File
@@ -17,14 +17,24 @@ open mode gates.
## Current checkpoint and work ## Current checkpoint and work
**Advanced Semuta at Truthtrance auction answers — 16 November. Prototyped /
Partial.** Fresh CHOAM-only Advanced Richese games offer Semuta after supported
definite factual and bid-question Truthtrance discards in ordinary, cache and
Black Market auctions. Native bid promises, auction funding, the seller's
reserved card and any remaining question queue survive claim or pass. An
unknown answer keeps its Truthtrance card. Twenty-four related unit files pass
173 cases. Other question families, profiles,
complete games and deployed acceptance remain open.
[Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026).
**Advanced Semuta at Sapho auction ordering — 16 November. Prototyped / **Advanced Semuta at Sapho auction ordering — 16 November. Prototyped /
Partial.** Fresh CHOAM-only Advanced Richese games offer a neutral Semuta Partial.** Fresh CHOAM-only Advanced Richese games offer a neutral Semuta
reaction when Sapho reorders simultaneous Truthtrance questions in supported reaction when Sapho reorders simultaneous Truthtrance questions in supported
ordinary, cache or Black Market auctions. The original question queue, seller ordinary, cache or Black Market auctions. The original question queue, seller
card, lot, funding and sealed bids remain in place through claim or pass. card, lot, funding and sealed bids remain in place through claim or pass.
Twenty related unit files pass 118 cases, including the original auction clock Twenty related unit files pass 118 cases, including the original auction clock
and an older game without the preview marker. The later Truthtrance discard, and an older game without the preview marker. Other Truthtrance question
other profiles, full games and deployed families, profiles, full games and deployed
acceptance remain open. [Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026). acceptance remain open. [Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026).
**Advanced Black Market Truthtrance — 16 November. Prototyped / Partial.** **Advanced Black Market Truthtrance — 16 November. Prototyped / Partial.**
+10 -3
View File
@@ -15,9 +15,16 @@ In the fresh Advanced CHOAM-only Richese profile, discarding Sapho during
supported ordinary, cache and Black Market auction question ordering now opens supported ordinary, cache and Black Market auction question ordering now opens
the neutral Semuta reaction. Claim or pass resumes the same question queue and the neutral Semuta reaction. Claim or pass resumes the same question queue and
original auction; the Black Market continuation binds the seller's reserved original auction; the Black Market continuation binds the seller's reserved
card without freezing their whole hand. The separate later Truthtrance-card card without freezing their whole hand. The separate later definite
discard, other Advanced profiles, optional combinations, complete games and Truthtrance-card discard also offers Semuta for supported factual and
deployed acceptance remain open. ordinary/Richese bid questions in those auctions, preserving any native bid
binding and queued questions. Unknown answers retain the physical card.
Other question families and Advanced profiles, optional combinations,
complete games and deployed acceptance remain open.
[Truth answer cases](../tests/semuta-advanced-truth-auctions.test.ts) and
[Black Market answer cases](../tests/semuta-advanced-truth-black-market.test.ts)
use original auction actions with conserved, explicitly staged Semuta custody.
Twenty-four related unit files pass 173 cases.
The [public-start cases](../tests/sapho-truth-black-market-runtime.test.ts) 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 use real setup and sale actions, with disclosed conserved card swaps for Sapho
and a second Truthtrance. [Semuta claim/pass cases](../tests/sapho-truth-black-market-advanced-semuta.test.ts) and a second Truthtrance. [Semuta claim/pass cases](../tests/sapho-truth-black-market-advanced-semuta.test.ts)
+2 -2
View File
@@ -5,8 +5,8 @@
The existing provisional Sapho order for simultaneous questions extends to The existing provisional Sapho order for simultaneous questions extends to
clean Advanced Black Market auctions with their original lot and funding. clean Advanced Black Market auctions with their original lot and funding.
The fresh CHOAM-only Advanced profile now offers Semuta on the Sapho discard The fresh CHOAM-only Advanced profile now offers Semuta on the Sapho discard
in supported ordinary, cache and Black Market auctions; the later Truthtrance and supported later definite Truthtrance discards in ordinary, cache and Black
discard is a separate, still-open reaction. Market auctions. Other question families and profiles remain separate.
[Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026). [Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026).
## Mixed current facts and Richese bids — 16 November 2026 ## Mixed current facts and Richese bids — 16 November 2026
+30 -4
View File
@@ -2000,6 +2000,8 @@ export type Game = {
remaining: TruthWindow | null; remaining: TruthWindow | null;
/** Absent on older saved Truth discard receipts. */ /** Absent on older saved Truth discard receipts. */
richeseLotEvent?: string; richeseLotEvent?: string;
/** Fresh Advanced auction answer with its exact native bid ledgers. */
advancedAuctionTruth?: true;
resume: NonNullable<Game['pendingNullentropy']>['resume']; resume: NonNullable<Game['pendingNullentropy']>['resume'];
promise: promise:
| { kind: 'shipment'; index: number; value: ShipmentPromise } | { kind: 'shipment'; index: number; value: ShipmentPromise }
@@ -8038,6 +8040,13 @@ function truthtranceDiscardSignature(g: Game, next: TruthDiscardContinuation) {
...(next.record.question.kind === 'mixedBid' ? { ...(next.record.question.kind === 'mixedBid' ? {
mixedBidQuestions: g.mixedBidQuestions, bidPromises: g.bidPromises, mixedBidQuestions: g.mixedBidQuestions, bidPromises: g.bidPromises,
} : {}), } : {}),
...(next.advancedAuctionTruth ? {advancedAuctionTruth:true, aid:g.aid,
bidPromises:g.bidPromises, phaseBidPromises:g.phaseBidPromises,
richeseBidPromises:g.richeseBidPromises, mixedBidQuestions:g.mixedBidQuestions,
mixedRicheseBidQuestions:g.mixedRicheseBidQuestions,
richeseBidding:g.richeseBidding, richeseFunding:g.richeseFunding,
...(g.richeseAuction?.source === 'blackMarket' ? {offered:g.richeseOfferedCard,
reservedCard:richeseLotCard(g)} : {})} : {}),
...(next.record.question.kind === 'mixedRicheseBid' ? { ...(next.record.question.kind === 'mixedRicheseBid' ? {
mixedRicheseBidQuestions: g.mixedRicheseBidQuestions, richeseBidPromises: g.richeseBidPromises, mixedRicheseBidQuestions: g.mixedRicheseBidQuestions, richeseBidPromises: g.richeseBidPromises,
} : {}), } : {}),
@@ -8123,7 +8132,9 @@ function finishTruthtranceAnswer(g: Game) {
historyIndex, historyIndex,
record, record,
remaining, remaining,
...(supportedRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}), ...(advancedTruthAuctionSupported(g,record.question.kind) ? {advancedAuctionTruth:true as const} : {}),
...(supportedRicheseTruthLot(g) || advancedTruthAuctionSupported(g,record.question.kind) &&
supportedSaphoRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}),
resume, resume,
promise, promise,
parentSignature: '', parentSignature: '',
@@ -9151,8 +9162,12 @@ function treacheryDiscardIntegrity(g: Game) {
'The consumed Truthtrance does not match its completed answer history.', 'The consumed Truthtrance does not match its completed answer history.',
); );
const remaining = c.remaining; const remaining = c.remaining;
requireRule(!c.richeseLotEvent || supportedRicheseTruthLot(g) && g.richeseAuction?.event === c.richeseLotEvent, requireRule(!c.advancedAuctionTruth || c.advancedAuctionTruth === true &&
'The completed Truthtrance no longer matches its original Richese cache lot.'); advancedTruthAuctionSupported(g,record.question.kind),
'The completed Truthtrance no longer matches its original Advanced auction.');
requireRule(!c.richeseLotEvent || (supportedRicheseTruthLot(g) ||
c.advancedAuctionTruth && supportedSaphoRicheseTruthLot(g)) && g.richeseAuction?.event === c.richeseLotEvent,
'The completed Truthtrance no longer matches its original Richese lot.');
requireRule( requireRule(
remaining === null || remaining === null ||
(remaining && (remaining &&
@@ -9938,6 +9953,10 @@ function advancedSaphoAuctionSemuta(g: Game): boolean {
(supportedSaphoRicheseTruthLot(g) || !!g.auction && !g.richeseAuction && (supportedSaphoRicheseTruthLot(g) || !!g.auction && !g.richeseAuction &&
!!g.auction.cards[g.auction.index] && !!g.auction.active); !!g.auction.cards[g.auction.index] && !!g.auction.active);
} }
function advancedTruthAuctionSupported(g: Game, kind: TruthQuestion['kind']): boolean {
return advancedSaphoAuctionSemuta(g) &&
['fact','freeform','bid','mixedBid','phaseBid','richeseBid','mixedRicheseBid'].includes(kind);
}
/** Bind a parked native ride to its original remaining Spice Blow sequence. */ /** Bind a parked native ride to its original remaining Spice Blow sequence. */
function wormDiscardCursor(g: Game): string { function wormDiscardCursor(g: Game): string {
return JSON.stringify([g.turn, g.phase, g.wormRides, g.spiceSequence, return JSON.stringify([g.turn, g.phase, g.wormRides, g.spiceSequence,
@@ -10010,6 +10029,11 @@ function semutaOfferSupported(
const advancedRicheseSaphoDiscard = continuation.kind === 'saphoTruthOrderDiscard' && const advancedRicheseSaphoDiscard = continuation.kind === 'saphoTruthOrderDiscard' &&
advancedSaphoAuctionSemuta(g) && supportedSaphoRicheseTruthLot(g) && advancedSaphoAuctionSemuta(g) && supportedSaphoRicheseTruthLot(g) &&
!!continuation.richeseLotEvent && continuation.richeseLotEvent === g.richeseAuction?.event; !!continuation.richeseLotEvent && continuation.richeseLotEvent === g.richeseAuction?.event;
const advancedTruthAuctionDiscard = continuation.kind === 'truthtranceDiscard' &&
continuation.advancedAuctionTruth === true && continuation.promise === null &&
advancedTruthAuctionSupported(g,continuation.record.question.kind) &&
(!g.richeseAuction || supportedSaphoRicheseTruthLot(g) &&
continuation.richeseLotEvent === g.richeseAuction.event);
const richeseBoxDiscard = supportedRicheseTruthLot(g) && continuation.kind === 'nullentropyDiscard' && const richeseBoxDiscard = supportedRicheseTruthLot(g) && continuation.kind === 'nullentropyDiscard' &&
continuation.auctionBinding?.kind === 'richese'; continuation.auctionBinding?.kind === 'richese';
const richeseDistransDiscard = continuation.kind === 'distransDiscard' && const richeseDistransDiscard = continuation.kind === 'distransDiscard' &&
@@ -10280,6 +10304,7 @@ function semutaOfferSupported(
continuation.kind === 'nullentropyDiscard' || continuation.kind === 'distransDiscard' || continuation.kind === 'nullentropyDiscard' || continuation.kind === 'distransDiscard' ||
continuation.kind === 'residualPoisonDiscard' || continuation.kind === 'choamSaleDiscard' || continuation.kind === 'residualPoisonDiscard' || continuation.kind === 'choamSaleDiscard' ||
continuation.kind === 'saphoTruthOrderDiscard' && advancedSaphoAuctionSemuta(g) || continuation.kind === 'saphoTruthOrderDiscard' && advancedSaphoAuctionSemuta(g) ||
advancedTruthAuctionDiscard ||
continuation.kind === 'karamaEmperorShareDiscard' && continuation.kind === 'karamaEmperorShareDiscard' &&
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) || emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
((continuation.kind === 'choamKulonDiscard' || continuation.kind === 'choamLaLaLaDiscard' || ((continuation.kind === 'choamKulonDiscard' || continuation.kind === 'choamLaLaLaDiscard' ||
@@ -10464,7 +10489,8 @@ function semutaOfferSupported(
continuation.use.response.kind === 'emperorIncome') || continuation.use.response.kind === 'emperorIncome') ||
continuation.kind === 'karamaEmperorShareDiscard' && continuation.kind === 'karamaEmperorShareDiscard' &&
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) || emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
richeseTruthDiscard || advancedRicheseSaphoDiscard || richeseBoxDiscard || richeseDistransDiscard || !g.richeseAuction) && richeseTruthDiscard || advancedRicheseSaphoDiscard || advancedTruthAuctionDiscard ||
richeseBoxDiscard || richeseDistransDiscard || !g.richeseAuction) &&
(richeseGiftDiscard || combatDiscard || alliedTraitorDiscard || occupyDiscard || continuation.kind === 'saphoAggressorDiscard' || (richeseGiftDiscard || combatDiscard || alliedTraitorDiscard || occupyDiscard || continuation.kind === 'saphoAggressorDiscard' ||
(continuation.kind === 'saphoTruthOrderDiscard' && !!continuation.battleEvent && (continuation.kind === 'saphoTruthOrderDiscard' && !!continuation.battleEvent &&
g.phase === 6 && g.battle?.event === continuation.battleEvent && !g.battle.revealed && !g.battle.preparation && g.phase === 6 && g.battle?.event === continuation.battleEvent && !g.battle.revealed && !g.battle.preparation &&
+1 -1
View File
@@ -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.', '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.', '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.', '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 and Advanced Black Market lots preserve their original bidding and funding. Fresh Advanced CHOAM-only Richese games offer Semuta on this Sapho discard in those auctions; the later Truthtrance discard and other 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. Fresh Advanced CHOAM-only Richese games offer Semuta on this Sapho discard and supported definite factual or bid-question Truthtrance discards in those auctions. Other question families and 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.', '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.', '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.', '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.',
@@ -0,0 +1,128 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { viewGame, type Game } from '../game/engine';
import { createTruthRicheseBidFixture } from './fixture-truth-richese-bid';
import { createTruthRicheseSilentFixture } from './fixture-truth-richese-silent';
import {
actTruthtranceRichesePromises as act, advanceTruthtranceRichesePromises as advance,
createTruthtranceRichesePromisesFixture, passTruthRicheseFreshDiscard,
truthtranceRichesePromisesClean as clean, truthtranceRichesePromisesInventory as inventory,
truthtranceRichesePromisesPlayer as seat,
} from './fixture-truthtrance-richese-promises';
type Method = 'ordinary' | 'onceAround' | 'silent';
type Kind = 'fact' | 'bid' | 'mixed';
/** Native Advanced setup and auction actions. The original Semuta moves from
* Richese's cache into its hand as a disclosed conserved custody supplement;
* no bid, wallet, promise or phase is installed. */
function fixture(method: Method) {
let game: Game = method === 'ordinary'
? structuredClone(createTruthtranceRichesePromisesFixture({advanced:true}).earlySource)
: structuredClone((method === 'onceAround' ? createTruthRicheseBidFixture(true) : createTruthRicheseSilentFixture(true)).game);
const asker = 'atreides', owner = 'richese';
if (method === 'ordinary') {
game = advance(game, state => state.phase === 3 && !!state.auction && clean(state));
if (game.auction!.active === asker) game = act(game,asker,{type:'passBid'});
assert.ok(game.auction && game.auction.active !== asker);
} else if (method === 'onceAround') {
assert.equal(game.richeseAuction?.active,asker);
game = act(game,asker,{type:'richeseBid',event:game.richeseAuction!.event,amount:null});
}
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
const cache = game.richeseCache!;
const semutaAt = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(semutaAt >= 0);
assert.notEqual(cache[semutaAt].id,game.richeseAuction?.cardId);
const [semuta] = cache.splice(semutaAt,1); seat(game,owner).hand.push(semuta);
const cards = inventory(game), truth = seat(game,asker).hand.find(card => card.effect === 'truthtrance'); assert.ok(truth);
const target = method === 'ordinary' ? game.auction!.active : 'emperor';
assert.notEqual(target,asker);
const parent = structuredClone({auction:game.auction, richeseAuction:game.richeseAuction,
richeseBidding:game.richeseBidding, richeseFunding:game.richeseFunding, aid:game.aid,
turn:game.turn,phase:game.phase,active:game.active,order:game.order});
return {game,asker,owner,target,truth:truth.id,semuta:semuta.id,cards,parent,method};
}
function assertParent(game: Game, f: ReturnType<typeof fixture>) {
assert.deepEqual({auction:game.auction, richeseAuction:game.richeseAuction,
richeseBidding:game.richeseBidding, richeseFunding:game.richeseFunding, aid:game.aid,
turn:game.turn,phase:game.phase,active:game.active,order:game.order},f.parent);
}
function question(f: ReturnType<typeof fixture>, kind: Kind) {
if (kind === 'fact') return {kind:'fact',target:f.target,fact:{kind:'spice',compare:'gte',value:0}};
const mixed = {kind:'and',terms:[{kind:'fact',fact:{kind:'spice',compare:'gte',value:0}},
{kind:'action',action:{minimum:1}}]};
if (f.method === 'ordinary') return kind === 'bid'
? {kind:'bid',target:f.target,turn:f.game.turn,lot:f.game.auction!.index+1,minimum:1}
: {kind:'mixedBid',target:f.target,turn:f.game.turn,lot:f.game.auction!.index+1,mixed};
return kind === 'bid'
? {kind:'richeseBid',target:f.target,turn:f.game.turn,event:f.game.richeseAuction!.event,minimum:1}
: {kind:'mixedRicheseBid',target:f.target,turn:f.game.turn,event:f.game.richeseAuction!.event,mixed};
}
for (const method of ['ordinary','onceAround','silent'] as const)
for (const kind of ['fact','bid','mixed'] as const)
for (const claim of [false,true]) void test(
`Advanced ${method} ${kind} answer Semuta ${claim ? 'claim' : 'pass'} retains the native auction`, () => {
const f = fixture(method); let game = act(f.game,f.asker,{type:'card',card:f.truth});
while (game.truthtrance?.stage === 'priority') {
const actor = game.players.find(player => !game.truthtrance!.passed.includes(player.id)); assert.ok(actor);
game = act(game,actor.id,{type:'truthPass'});
}
assert.equal(game.truthtrance?.stage,'ask');
game = act(game,f.asker,{type:'truthAsk',question:question(f,kind)});
game = act(game,f.target,{type:'truthAnswer',answer:'yes'});
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'truthtranceDiscard');
assert.equal(pending.batch.entries[0].card.id,f.truth);
assert.equal(game.truthtrance,null);
assert.equal(viewGame(game,f.owner).semutaReaction?.canCommit,true);
assertParent(game,f);
const event = pending.batch.event;
game = claim ? act(game,f.owner,{type:'semutaCommit',event}) : passTruthRicheseFreshDiscard(game);
assert.equal(game.pendingTreacheryDiscard,null);
assert.equal(game.truthtrance,null);
assert.equal(seat(game,f.owner).hand.some(card => card.id === f.truth),claim);
assert.equal(game.discard.some(card => card.id === f.semuta),claim);
assertParent(game,f);
if (kind !== 'fact') {
const guide = method === 'ordinary' ? viewGame(game,f.target).bidPromiseGuide : viewGame(game,f.target).richeseBidPromiseGuide;
assert.ok(guide, 'The native commitment and guide survive the discard response');
game = act(game,f.target,guide.action);
assert.equal(seat(game,f.target).spice,seat(f.game,f.target).spice,'A declaration does not pay the purchase');
if (method === 'silent') {
assert.equal(viewGame(game,f.target).richeseAuction?.ownBid,1);
assert.equal(viewGame(game,f.asker).richeseAuction?.ownBid,null);
assert.equal(viewGame(game,f.asker).richeseAuction?.revealedBids,null);
}
}
assert.deepEqual(inventory(game),f.cards);
});
for (const claim of [false,true]) void test(
`Advanced ordinary phase-wide bid Yes survives Truthtrance Semuta ${claim ? 'claim' : 'pass'}`, () => {
const f = fixture('ordinary');
let game = act(f.game,f.asker,{type:'card',card:f.truth});
while (game.truthtrance?.stage === 'priority') {
const actor = game.players.find(player => !game.truthtrance!.passed.includes(player.id)); assert.ok(actor);
game = act(game,actor.id,{type:'truthPass'});
}
assert.equal(game.truthtrance?.stage,'ask');
game = act(game,f.asker,{type:'truthAsk',question:{kind:'phaseBid',target:f.target,turn:game.turn,minimum:1}});
assert.ok(viewGame(game,f.target).truthPhaseBidAnswers?.includes('yes'));
game = act(game,f.target,{type:'truthAnswer',answer:'yes'});
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'truthtranceDiscard');
assert.equal(pending.batch.entries[0].card.id,f.truth);
assert.equal(viewGame(game,f.owner).semutaReaction?.canCommit,true);
assertParent(game,f);
game = claim ? act(game,f.owner,{type:'semutaCommit',event:pending.batch.event}) : passTruthRicheseFreshDiscard(game);
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null);
assert.equal(seat(game,f.owner).hand.some(card => card.id === f.truth),claim);
assertParent(game,f);
const guide = viewGame(game,f.target).phaseBidPromiseGuide;
assert.ok(guide, 'The native phase-wide bid guide returns after the discard');
game = act(game,f.target,guide.action);
const receipt = viewGame(game,f.target).phaseBidPromises.find(row => row.player === f.target);
assert.ok(receipt?.fulfilled);
assert.deepEqual(inventory(game),f.cards);
});
@@ -0,0 +1,200 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { viewGame, type Action, type Game } from '../game/engine';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { createTruthtranceRichesePromisesFixture, advanceTruthtranceRichesePromises as advance,
actTruthtranceRichesePromises as act, truthtranceRichesePromisesInventory as inventory,
truthtranceRichesePromisesPlayer as player } from './fixture-truthtrance-richese-promises';
type Method = 'normal' | 'onceAround' | 'silent';
type Kind = 'fact' | 'richeseBid' | 'mixedRicheseBid';
/** Real Advanced setup, dealt Truth and seller Shield, and real Black Market
* actions. The original physical Semuta moves from cache into Richese's hand;
* the underlying fixture selects the unopened deal, Spice order and rolls. */
function fixture(method: Method) {
const source = createTruthtranceRichesePromisesFixture({advanced:true});
let game = structuredClone(source.earlySource);
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
const cache = game.richeseCache!;
const at = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(at >= 0);
const [semuta] = cache.splice(at,1); player(game,source.richese).hand.push(semuta);
assert.deepEqual(inventory(game),source.originalCards);
game = advance(game,state => state.decision?.kind === 'richeseBlackMarket');
const card = source.targetCard;
assert.ok(player(game,source.richese).hand.some(held => held.id === card));
game = act(game,source.richese,{type:'decision',event:game.richeseBidding!.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'});
}
const lot = game.richeseAuction; assert.ok(lot && lot.source === 'blackMarket');
if (method === 'silent') game = act(game,source.richese,{type:'richeseBid',event:lot.event,amount:1,allyPayment:0});
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});
return {game,asker:source.asker,target:source.emperor,owner:source.richese,truth:source.truth,
semuta:semuta.id,card,lot:lot.event,cards:source.originalCards,parent};
}
type Fixture = ReturnType<typeof fixture>;
function assertParent(game: Game, f: Fixture) {
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},f.parent);
assert.ok(player(game,f.owner).hand.some(card => card.id === f.card));
if (game.richeseAuction?.method === 'silent') {
assert.equal(viewGame(game,f.owner).richeseAuction?.ownBid,1);
assert.equal(viewGame(game,f.target).richeseAuction?.ownBid,null);
assert.equal(viewGame(game,f.target).richeseAuction?.revealedBids,null);
}
}
function ask(f: Fixture, kind: Kind) {
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 === 'fact' ? {kind,target:f.target,fact:{kind:'spice',compare:'gte',value:0}} :
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});
}
function passOffer(state: Game) {
let game = state;
while (game.pendingTreacheryDiscard?.reaction?.stage === 'offer') {
const pending = game.pendingTreacheryDiscard, reaction = pending.reaction!;
if (reaction.stage !== 'offer') throw Error('Expected a Semuta offer');
const seat = game.players.find(row => !reaction.passed.includes(row.id)); assert.ok(seat);
game = act(game,seat.id,{type:'semutaPass',event:pending.batch.event});
}
return game;
}
for (const method of ['normal','onceAround','silent'] as const) for (const claim of [false,true]) void test(
`Advanced ${method} Black Market definite fact offers Semuta and ${claim ? 'claim' : 'pass'} preserves the lot`,() => {
const f = fixture(method), asked = ask(f,'fact');
let game = act(asked,f.target,{type:'truthAnswer',answer:'yes'});
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'truthtranceDiscard');
assert.equal(pending.batch.entries[0].card.id,f.truth);
assert.equal(viewGame(game,f.owner).semutaReaction?.canCommit,true);
assertParent(game,f);
for (const difficulty of DIFFICULTIES) {
const view = viewGame(game,f.owner); view.players.find(row => row.id === f.owner)!.bot = difficulty;
const action = botActions(view)[0]; assert.ok(action,difficulty);
assert.ok(action.type === 'semutaPass' || action.type === 'semutaCommit');
assert.doesNotThrow(() => act(game,f.owner,action));
}
game = claim ? act(game,f.owner,{type:'semutaCommit',event:pending.batch.event}) : passOffer(game);
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null);
assert.equal(player(game,f.owner).hand.some(card => card.id === f.truth),claim);
assert.equal(game.discard.some(card => card.id === f.semuta),claim);
assertParent(game,f); assert.deepEqual(inventory(game),f.cards);
const lot = game.richeseAuction!;
const actor = method === 'silent' ? lot.eligible.find(id => !Object.hasOwn(lot.sealed,id)) : lot.active;
assert.ok(actor);
game = act(game,actor,{type:'richeseBid',event:f.lot,amount:method === 'silent' ? 0 : null,allyPayment:0});
assert.deepEqual(inventory(game),f.cards);
});
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 its native bid commitment through Semuta`,() => {
const f = fixture(method), asked = ask(f,kind);
let game = act(asked,f.target,{type:'truthAnswer',answer});
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'truthtranceDiscard'); assertParent(game,f);
const native = game.richeseBidPromises?.find(row => row.player === f.target && !row.fulfilled && !row.released);
assert.ok(native); assert.equal(native.answer,answer === 'yes');
game = act(game,f.owner,{type:'semutaCommit',event:pending.batch.event});
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null); assertParent(game,f);
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);
const bad: Action = {...guide.action,richeseBidPromiseId:'stale'};
const before = structuredClone(game); assert.throws(() => act(game,f.target,bad)); assert.deepEqual(game,before);
const amount = answer === 'yes' ? 4 : 2;
game = act(game,f.target,{type:'richeseBid',event:f.lot,amount,allyPayment:0});
assert.ok(game.richeseBidPromises?.find(row => row.id === native.id)?.fulfilled);
if (method === 'silent') {
assert.equal(viewGame(game,f.target).richeseAuction?.ownBid,amount);
assert.equal(viewGame(game,f.owner).richeseAuction?.revealedBids,null);
game = act(game,f.asker,{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(card => card.id === f.card));
assert.equal(game.discard.some(card => card.id === f.semuta),true);
assert.deepEqual(inventory(game),f.cards);
});
void test('Advanced Silent Black Market resumes the second actual Truth question after Semuta claims the first',() => {
const f = fixture('silent'); let game = structuredClone(f.game);
// Move the other original unopened Truth card into Emperor's hand. This is
// the only extra fixture staging; each holder actually declares its card.
const at = game.deck.findIndex(card => card.effect === 'truthtrance' && card.id !== f.truth); assert.ok(at >= 0);
const [second] = game.deck.splice(at,1); player(game,f.target).hand.push(second);
assert.deepEqual(inventory(game),f.cards);
game = act(game,f.asker,{type:'card',card:f.truth});
game = act(game,f.target,{type:'card',card:second.id});
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'});
}
while (game.truthtrance?.stage === 'order') {
const order = game.truthtrance.order!;
const actor = order.holders.find(id => !order.passed.includes(id)); assert.ok(actor);
game = act(game,actor,{type:'truthOrderPass',event:order.event,revision:order.revision});
}
assert.equal(game.truthtrance?.stage,'ask'); assert.equal(game.truthtrance.queue.length,2);
const originalQueue = structuredClone(game.truthtrance.queue), first = originalQueue[0];
game = act(game,first.player,{type:'truthAsk',question:{kind:'fact',target:f.owner,
fact:{kind:'spice',compare:'gte',value:0}}});
game = act(game,f.owner,{type:'truthAnswer',answer:'yes'});
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'truthtranceDiscard');
assert.equal(pending.batch.entries[0].card.id,first.card); assertParent(game,f);
game = act(game,f.owner,{type:'semutaCommit',event:pending.batch.event});
assert.equal(game.pendingTreacheryDiscard,null);
assert.deepEqual(game.truthtrance?.queue,originalQueue.slice(1));
assert.equal(game.truthtrance?.stage,'ask'); assertParent(game,f);
const remaining = game.truthtrance!.queue[0];
game = act(game,remaining.player,{type:'truthAsk',question:{kind:'fact',target:f.owner,
fact:{kind:'spice',compare:'gte',value:0}}});
game = act(game,f.owner,{type:'truthAnswer',answer:'yes'});
assert.ok(game.pendingTreacheryDiscard?.reaction);
game = passOffer(game);
assert.equal(game.truthtrance,null); assertParent(game,f);
assert.deepEqual(inventory(game),f.cards);
});
void test('an unknown Advanced Black Market answer keeps the physical Truth and opens no Semuta discard',() => {
const f = fixture('silent'); 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'});
}
game = act(game,f.asker,{type:'truthAsk',question:{kind:'fact',target:f.target,
fact:{kind:'stormForecast',compare:'gte',value:1}}});
assert.equal(viewGame(game,f.target).truthAnswer,'unknown');
game = act(game,f.target,{type:'truthAnswer',answer:'unknown'});
assert.equal(game.truthtrance?.stage,'unknown');
assert.equal(game.pendingTreacheryDiscard ?? null,null);
assert.ok(player(game,f.asker).hand.some(card => card.id === f.truth));
assert.ok(player(game,f.owner).hand.some(card => card.id === f.semuta));
assertParent(game,f); assert.deepEqual(inventory(game),f.cards);
});