Support Advanced Semuta at Sapho auction ordering
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-11-16 18:54:59 +11:00
1 parent 868713eeb9
commit dd4222ee92
9 files changed
+270 -19

No files matched your search

+12 -2
View File
@@ -17,11 +17,21 @@ open mode gates.
## Current checkpoint and work
**Advanced Semuta at Sapho auction ordering — 16 November. Prototyped /
Partial.** Fresh CHOAM-only Advanced Richese games offer a neutral Semuta
reaction when Sapho reorders simultaneous Truthtrance questions in supported
ordinary, cache or Black Market auctions. The original question queue, seller
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
and an older game without the preview marker. The later Truthtrance discard,
other profiles, full games and deployed
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.**
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
card custody, bids and funding remain in place; the fresh CHOAM-only profile
now offers Semuta at the Sapho discard. 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
+12 -4
View File
@@ -11,12 +11,20 @@ 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.
In the fresh Advanced CHOAM-only Richese profile, discarding Sapho during
supported ordinary, cache and Black Market auction question ordering now opens
the neutral Semuta reaction. Claim or pass resumes the same question queue and
original auction; the Black Market continuation binds the seller's reserved
card without freezing their whole hand. The separate later Truthtrance-card
discard, other Advanced profiles, 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.
and a second Truthtrance. [Semuta claim/pass cases](../tests/sapho-truth-black-market-advanced-semuta.test.ts)
also stage the original Semuta card by conserved movement from the cache.
[Ordinary and cache cases](../tests/sapho-truth-auction-advanced-semuta.test.ts)
include claim, pass and a game without the preview marker. Twenty related unit
files pass 118 cases, including the original auction clock.
## Shared Ambassador and Terror arrival — 29 October 2026
+3 -1
View File
@@ -4,7 +4,9 @@
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.
The fresh CHOAM-only Advanced profile now offers Semuta on the Sapho discard
in supported ordinary, cache and Black Market auctions; the later Truthtrance
discard is a separate, still-open reaction.
[Scope](JUICE_OF_SAPHO_RUNTIME.md#truthtrance-order-in-advanced-black-market--16-november-2026).
## Mixed current facts and Richese bids — 16 November 2026
+32 -8
View File
@@ -1766,7 +1766,7 @@ export type Game = {
revision: number;
mode: 'first' | 'last';
truth: TruthWindow;
/** Present only on new supported Richese cache continuations. */
/** Present on supported cache and source-qualified Black Market continuations. */
richeseLotEvent?: string;
/** New battle continuations bind their original battle event and state. */
battleEvent?: string;
@@ -6668,7 +6668,9 @@ function saphoTruthOrderDiscardSignature(g: Game, c: SaphoTruthOrderDiscardConti
...(g.auction ? {auction:g.auction,aid:g.aid} : {}),
...(c.battleEvent ? {battleEvent:c.battleEvent,battle:g.battle} : {}),
...(c.richeseLotEvent ? {richeseLotEvent:c.richeseLotEvent,richeseAuction:g.richeseAuction,
richeseBidding:g.richeseBidding,richeseFunding:g.richeseFunding,richeseCache:g.richeseCache,aid:g.aid} : {})});
richeseBidding:g.richeseBidding,richeseFunding:g.richeseFunding,richeseCache:g.richeseCache,aid:g.aid,
...(g.richeseAuction?.source === 'blackMarket' ? {offered:g.richeseOfferedCard,
reservedCard:richeseLotCard(g)} : {})} : {})});
}
type SaphoMovementDiscardContinuation = Extract<
NonNullable<Game['pendingTreacheryDiscard']>['continuation'],
@@ -8631,7 +8633,7 @@ function treacheryDiscardIntegrity(g: Game) {
entry.discardedBy === c.player && entry.card.id === c.card &&
richeseCardDefinition(entry.card)?.card.effect === 'juiceOfSapho' &&
!c.resume.response && !c.resume.decision && !c.resume.pendingKarama && !c.resume.phaseOpening &&
(!c.richeseLotEvent || supportedRicheseTruthLot(g) && g.richeseAuction?.event === c.richeseLotEvent) &&
(!c.richeseLotEvent || supportedSaphoRicheseTruthLot(g) && g.richeseAuction?.event === c.richeseLotEvent) &&
(!c.battleEvent || g.phase === 6 && g.battle?.event === c.battleEvent &&
!g.battle.revealed && !g.battle.preparation) &&
truth && truth.question === null && (truth.stage === 'order' || truth.stage === 'ask') &&
@@ -9918,6 +9920,24 @@ function supportedRicheseTruthLot(g: Game): boolean {
(lot.method === 'onceAround' || lot.method === 'silent') && !lot.outcome &&
!g.currentAuctionSale && !g.auction && !g.ixAuction;
}
/** Sapho's new Advanced Black Market reaction binds only its own real parent;
* it must not broaden the separate Truthtrance and Box discard profiles. */
function supportedSaphoRicheseTruthLot(g: Game): boolean {
if (supportedRicheseTruthLot(g)) return true;
const lot = g.richeseAuction;
const seller = lot && g.players.find(player => player.id === lot.owner);
return g.semutaAdvancedOrdinaryPreview === true && bareAdvancedClassicSemutaProfile(g) &&
g.phase === 3 && !!lot && lot.source === 'blackMarket' &&
['normal','onceAround','silent'].includes(lot.method) && !lot.outcome &&
!g.currentAuctionSale && !g.auction && !g.ixAuction && !!seller &&
seller.hand.filter(card => card.id === lot.cardId).length === 1;
}
function advancedSaphoAuctionSemuta(g: Game): boolean {
return g.semutaAdvancedOrdinaryPreview === true && bareAdvancedClassicSemutaProfile(g) &&
g.status === 'playing' && g.phase === 3 && !g.currentAuctionSale && !g.ixAuction &&
(supportedSaphoRicheseTruthLot(g) || !!g.auction && !g.richeseAuction &&
!!g.auction.cards[g.auction.index] && !!g.auction.active);
}
/** Bind a parked native ride to its original remaining Spice Blow sequence. */
function wormDiscardCursor(g: Game): string {
return JSON.stringify([g.turn, g.phase, g.wormRides, g.spiceSequence,
@@ -9987,6 +10007,9 @@ function semutaOfferSupported(
const richeseTruthDiscard = supportedRicheseTruthLot(g) &&
(continuation.kind === 'truthtranceDiscard' || continuation.kind === 'saphoTruthOrderDiscard') &&
!!continuation.richeseLotEvent && continuation.richeseLotEvent === g.richeseAuction?.event;
const advancedRicheseSaphoDiscard = continuation.kind === 'saphoTruthOrderDiscard' &&
advancedSaphoAuctionSemuta(g) && supportedSaphoRicheseTruthLot(g) &&
!!continuation.richeseLotEvent && continuation.richeseLotEvent === g.richeseAuction?.event;
const richeseBoxDiscard = supportedRicheseTruthLot(g) && continuation.kind === 'nullentropyDiscard' &&
continuation.auctionBinding?.kind === 'richese';
const richeseDistransDiscard = continuation.kind === 'distransDiscard' &&
@@ -10256,6 +10279,7 @@ function semutaOfferSupported(
continuation.kind === 'battleCleanup' && continuation.source === 'winner' ||
continuation.kind === 'nullentropyDiscard' || continuation.kind === 'distransDiscard' ||
continuation.kind === 'residualPoisonDiscard' || continuation.kind === 'choamSaleDiscard' ||
continuation.kind === 'saphoTruthOrderDiscard' && advancedSaphoAuctionSemuta(g) ||
continuation.kind === 'karamaEmperorShareDiscard' &&
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
((continuation.kind === 'choamKulonDiscard' || continuation.kind === 'choamLaLaLaDiscard' ||
@@ -10440,7 +10464,7 @@ function semutaOfferSupported(
continuation.use.response.kind === 'emperorIncome') ||
continuation.kind === 'karamaEmperorShareDiscard' &&
emperorAuctionGiftResumeMatches(g, continuation.use.response, continuation.resume.decision) ||
richeseTruthDiscard || richeseBoxDiscard || richeseDistransDiscard || !g.richeseAuction) &&
richeseTruthDiscard || advancedRicheseSaphoDiscard || richeseBoxDiscard || richeseDistransDiscard || !g.richeseAuction) &&
(richeseGiftDiscard || combatDiscard || alliedTraitorDiscard || occupyDiscard || continuation.kind === 'saphoAggressorDiscard' ||
(continuation.kind === 'saphoTruthOrderDiscard' && !!continuation.battleEvent &&
g.phase === 6 && g.battle?.event === continuation.battleEvent && !g.battle.revealed && !g.battle.preparation &&
@@ -30325,12 +30349,12 @@ function saphoTruthOrderSemutaSupported(g: Game,p: Player,card: string,mode: 'fi
recordNativePrintedCardPlay(trial,p.id,'juiceOfSapho');
const used = discard(trial,actor,card);
guardTurnActionPrintedCardCost(trial,actor,used);
if (!trial.semutaPreview) return true;
if (!trial.semutaPreview && !advancedSaphoAuctionSemuta(trial)) return true;
w.queue = result.queue;
if (result.done) { delete w.order; w.stage = 'ask'; } else w.order = result.frame;
const c: SaphoTruthOrderDiscardContinuation = {kind:'saphoTruthOrderDiscard',player:p.id,card:used.id,
event,revision,mode,truth:structuredClone(w),
...(supportedRicheseTruthLot(trial) ? {richeseLotEvent:trial.richeseAuction!.event} : {}),
...(supportedSaphoRicheseTruthLot(trial) ? {richeseLotEvent:trial.richeseAuction!.event} : {}),
...(trial.battle?.event ? {battleEvent:trial.battle.event} : {}),
resume:{response:trial.response,decision:trial.decision,
pendingKarama:trial.pendingKarama,phaseOpening:trial.phaseOpening},stateSignature:''};
@@ -30366,11 +30390,11 @@ function playSaphoTruthOrder(g: Game,p: Player,action: Action) {
if (result.done) { delete w.order; w.stage = 'ask'; } else w.order = result.frame;
log(g, `${p.name} discarded Juice of Sapho to ask ${String(action.mode)} among the simultaneous Truthtrance holders.`,
{faction:p.faction,name:'Juice of Sapho'});
if (g.semutaPreview) {
if (g.semutaPreview || advancedSaphoAuctionSemuta(g)) {
const c: SaphoTruthOrderDiscardContinuation = {kind:'saphoTruthOrderDiscard',player:p.id,card:used.id,
event:action.event as string,revision:action.revision as number,mode:action.mode as 'first'|'last',
truth:structuredClone(w),
...(supportedRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}),
...(supportedSaphoRicheseTruthLot(g) ? {richeseLotEvent:g.richeseAuction!.event} : {}),
...(g.battle?.event ? {battleEvent:g.battle.event} : {}),
resume:{response:g.response,decision:g.decision,pendingKarama:g.pendingKarama,phaseOpening:g.phaseOpening},
stateSignature:''};
+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.',
'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 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.',
'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.',
'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.',
@@ -0,0 +1,88 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { viewGame, type Game } from '../game/engine';
import { createSaphoTruthRicheseFixture, assertRicheseParent } from './fixture-sapho-truth-richese';
import { createSaphoTruthAuctionFixture, assertAuctionParent, act, inventory, player } from './fixture-sapho-truth-auction';
import { passTruthOrder, playSaphoTruthOrder, finishOriginalTruthQuestions, passFreshDiscard } from './fixture-sapho-truth-order';
/** All games start through native Advanced setup and bidding. Cache cases use
* the fixture's disclosed physical cache/hand swaps. The ordinary case swaps
* the original cached Semuta with a held card after the actual Sapho purchase. */
for (const method of ['onceAround','silent'] as const) for (const claim of [false,true]) void test(
`Advanced ${method} cache Sapho Semuta ${claim ? 'claim' : 'pass'} restores the original auction and queued questions`, () => {
const f = createSaphoTruthRicheseFixture({advanced:true,method,standingBid:true,semuta:true});
assert.equal(f.game.semutaAdvancedOrdinaryPreview,true); assert.ok(f.semuta);
let game = passTruthOrder(f.game,f.other);
game = playSaphoTruthOrder(game,f.owner,f.card,f.mode);
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'saphoTruthOrderDiscard');
assert.equal(pending.batch.entries[0].card.id,f.card);
assert.equal(viewGame(game,f.semutaHolder).semutaReaction?.canCommit,true);
assertRicheseParent(game,f.parent);
if (method === 'silent') {
assert.equal(viewGame(game,f.semutaHolder).richeseAuction?.ownBid,1);
assert.equal(viewGame(game,f.owner).richeseAuction?.revealedBids,null);
}
game = claim ? act(game,f.semutaHolder,{type:'semutaCommit',event:pending.batch.event}) : passFreshDiscard(game);
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance?.stage,'ask');
assert.equal(f.mode === 'first' ? game.truthtrance!.queue[0].player : game.truthtrance!.queue.at(-1)!.player,f.owner);
assert.equal(player(game,f.semutaHolder).hand.some(card => card.id === f.card),claim);
assert.equal(game.discard.some(card => card.id === f.semuta),claim);
assertRicheseParent(game,f.parent);
game = finishOriginalTruthQuestions(game); assert.equal(game.truthtrance,null);
assertRicheseParent(game,f.parent); assert.deepEqual(inventory(game),f.originalCards);
const lot = game.richeseAuction!;
const actor = method === 'onceAround' ? lot.active : lot.eligible.find(id => !Object.hasOwn(lot.sealed,id));
assert.ok(actor);
game = act(game,actor,{type:'richeseBid',event:f.lot,amount:method === 'silent' ? 0 : null,allyPayment:0});
assert.deepEqual(inventory(game),f.originalCards);
},
);
for (const claim of [false,true]) void test(
`Advanced ordinary standing bid survives Sapho Truth-order Semuta ${claim ? 'claim' : 'pass'}`, () => {
const f = createSaphoTruthAuctionFixture({advanced:true,standingBid:true,mode:'first'});
let game: Game = structuredClone(f.game);
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
const claimant = player(game,'atreides'), cache = game.richeseCache;
assert.ok(cache && claimant.hand.length);
const index = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(index >= 0);
const [semuta] = cache.splice(index,1), [exchange] = claimant.hand.splice(0,1);
claimant.hand.push(semuta); cache.push(exchange);
assertAuctionParent(game,f.parent); assert.deepEqual(inventory(game),f.originalCards);
game = passTruthOrder(game,f.other);
game = playSaphoTruthOrder(game,f.owner,f.card,'first');
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'saphoTruthOrderDiscard');
assert.equal(viewGame(game,'atreides').semutaReaction?.canCommit,true);
assertAuctionParent(game,f.parent);
game = claim ? act(game,'atreides',{type:'semutaCommit',event:pending.batch.event}) : passFreshDiscard(game);
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance?.stage,'ask');
assert.equal(game.truthtrance?.queue[0].player,f.owner);
assert.equal(player(game,'atreides').hand.some(card => card.id === f.card),claim);
assert.equal(game.discard.some(card => card.id === semuta.id),claim);
assertAuctionParent(game,f.parent);
game = finishOriginalTruthQuestions(game); assert.equal(game.truthtrance,null);
assertAuctionParent(game,f.parent); assert.deepEqual(inventory(game),f.originalCards);
game = act(game,game.auction!.active,{type:'passBid'});
assert.equal(game.auction?.bid,1); assert.equal(game.auction?.bidder,f.parent.auction!.bidder);
assert.deepEqual(inventory(game),f.originalCards);
},
);
void test('an older Advanced cache game without the Semuta preview marker keeps its original synchronous Sapho continuation', () => {
const f = createSaphoTruthRicheseFixture({advanced:true,method:'silent',standingBid:true,semuta:true});
const older = structuredClone(f.game);
delete older.semutaAdvancedOrdinaryPreview; // Simulate a saved start predating the marker.
assert.ok(f.semuta && player(older,f.semutaHolder).hand.some(card => card.id === f.semuta));
let game = passTruthOrder(older,f.other);
game = playSaphoTruthOrder(game,f.owner,f.card,f.mode);
assert.equal(game.pendingTreacheryDiscard ?? null,null);
assert.equal(game.truthtrance?.stage,'ask');
assert.equal(f.mode === 'first' ? game.truthtrance!.queue[0].player : game.truthtrance!.queue.at(-1)!.player,f.owner);
assert.ok(player(game,f.semutaHolder).hand.some(card => card.id === f.semuta));
assertRicheseParent(game,f.parent);
game = finishOriginalTruthQuestions(game);
assert.equal(game.truthtrance,null); assertRicheseParent(game,f.parent);
assert.deepEqual(inventory(game),f.originalCards);
});
+2 -2
View File
@@ -48,7 +48,7 @@ function openTimedTruth(advanced: boolean, semuta: boolean) {
for (const scenario of [
{label:'Basic Semuta pass',advanced:false,semuta:true,claim:false},
{label:'Basic Semuta claim',advanced:false,semuta:true,claim:true},
{label:'Advanced without Semuta preview',advanced:true,semuta:false,claim:false},
{label:'Advanced neutral Semuta offer',advanced:true,semuta:false,claim:false},
]) void test(`${scenario.label}: the native bidder clock pauses through Truth order and Sapho disposal`, () => {
const {f,game:opened,initial} = openTimedTruth(scenario.advanced,scenario.semuta);
let game = opened;
@@ -61,7 +61,7 @@ for (const scenario of [
assert.equal(game.auctionClock?.event,event); assert.equal(game.auctionClock?.player,playerId);
assert.equal(game.auctionClock?.remainingMs,8_000); assert.equal(game.auctionClock?.startedAt,null);
assert.deepEqual(game.auction,beforeLot);
if (scenario.semuta) {
if (scenario.semuta || scenario.advanced) {
assert.ok(game.pendingTreacheryDiscard?.reaction);
const pendingEvent = game.pendingTreacheryDiscard.batch.event;
const held = advanceAuctionClock(game,100_000,epoch);
@@ -0,0 +1,117 @@
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 } from './fixture-truthtrance-richese-promises';
import { truthOrderFrame, playSaphoTruthOrder, finishTruthOrder, finishOriginalTruthQuestions } from './fixture-sapho-truth-order';
const player = (game: Game, id: string) => { const p = game.players.find(row => row.id === id); assert.ok(p); return p; };
type Method = 'normal' | 'onceAround' | 'silent';
/** Genuine Advanced R/A/E public start and original Black Market actions.
* Conserved staged custody moves original Sapho and Semuta from the cache and
* one unopened Truth to hands. The unopened deal/Spice order is selected by
* the underlying fixture; the sale, bid and Truth declarations are actual. */
function fixture(method: Method) {
const source = createTruthtranceRichesePromisesFixture({advanced:true});
let game = structuredClone(source.game);
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
const cache = game.richeseCache!, emperor = player(game,'emperor'), richese = player(game,'richese');
const saphoAt = cache.findIndex(card => card.effect === 'juiceOfSapho'); assert.ok(saphoAt >= 0);
const [sapho] = cache.splice(saphoAt,1), [swap] = emperor.hand.splice(0,1);
emperor.hand.push(sapho); cache.push(swap);
const semutaAt = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(semutaAt >= 0);
const [semuta] = cache.splice(semutaAt,1); richese.hand.push(semuta);
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 = 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');
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});
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 order = truthOrderFrame(game);
const mode: 'first' | 'last' = game.truthtrance!.queue[0].player === 'emperor' ? 'last' : 'first';
return {game,parent,offered:offered.id,lot:lot.event,bidder,order,mode,sapho:sapho.id,semuta:semuta.id,cards:source.originalCards};
}
function assertParent(game: Game, f: ReturnType<typeof 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,'richese').hand.some(card => card.id === f.offered));
}
function assertSilent(game: Game, bidder: string) {
const owner = viewGame(game,bidder).richeseAuction!, observer = viewGame(game,'emperor').richeseAuction!;
assert.equal(owner.ownBid,1); assert.equal(observer.ownBid,null);
assert.equal(observer.revealedBids,null); assert.equal('sealed' in observer,false);
}
function passOffer(state: Game): Game {
let game = state;
for (let n=0; game.pendingTreacheryDiscard?.reaction?.stage === 'offer' && n<game.players.length; n++) {
const pending = game.pendingTreacheryDiscard, reaction = pending.reaction!;
assert.equal(reaction.stage,'offer');
if (reaction.stage !== 'offer') throw Error('Expected Semuta offer');
const actor = game.players.find(row => !reaction.passed.includes(row.id)); assert.ok(actor);
game = act(game,actor.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 Sapho Truth order offers Semuta and ${claim?'claim':'pass'} resumes`, () => {
const f = fixture(method);
const before = structuredClone(f.game), queue = structuredClone(before.truthtrance!.queue);
assert.ok(viewGame(before,'emperor').saphoTruthOrderChoices.some(row => row.card === f.sapho && row.mode === f.mode));
let game = playSaphoTruthOrder(before,'emperor',f.sapho,f.mode);
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.equal(pending.continuation.kind,'saphoTruthOrderDiscard');
assert.equal(pending.batch.entries[0].card.id,f.sapho);
assert.equal(game.truthtrance,null);
assert.equal(viewGame(game,'richese').semutaReaction?.canCommit,true);
assertParent(game,f);
if (method === 'silent') assertSilent(game,f.bidder);
for (const difficulty of DIFFICULTIES) {
const view = viewGame(game,'richese'); view.players.find(row => row.id === 'richese')!.bot = difficulty;
const action = botActions(view)[0]; assert.ok(action,difficulty);
assert.ok(action.type === 'semutaCommit' || action.type === 'semutaPass');
assert.doesNotThrow(() => act(game,'richese',action));
}
const event = pending.batch.event;
game = claim ? act(game,'richese',{type:'semutaCommit',event}) : passOffer(game);
assert.equal(game.pendingTreacheryDiscard,null);
assert.equal(player(game,'richese').hand.some(card => card.id === f.sapho),claim);
assert.equal(game.discard.some(card => card.id === f.semuta),claim);
assertParent(game,f);
assert.deepEqual(game.truthtrance!.queue.map(row => row.card).sort(),queue.map(row => row.card).sort());
if (game.truthtrance?.stage === 'order') game = finishTruthOrder(game);
assert.equal(f.mode === 'first' ? game.truthtrance!.queue[0].player : game.truthtrance!.queue.at(-1)!.player,'emperor');
game = finishOriginalTruthQuestions(game);
assert.equal(game.truthtrance,null); assertParent(game,f);
assert.deepEqual(inventory(game),f.cards);
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.cards);
});
@@ -6,7 +6,8 @@ import { DIFFICULTIES } from '../game/bot-profiles';
import { createTruthtranceRichesePromisesFixture, advanceTruthtranceRichesePromises as advance,
actTruthtranceRichesePromises as act, truthtranceRichesePromisesInventory as inventory } from './fixture-truthtrance-richese-promises';
import { truthOrderFrame as frame, playSaphoTruthOrder as play,
finishTruthOrder as finish, finishOriginalTruthQuestions as answer, rejectSaphoTruthOrder as reject } from './fixture-sapho-truth-order';
finishTruthOrder as finish, finishOriginalTruthQuestions as answer, rejectSaphoTruthOrder as reject,
passFreshDiscard } from './fixture-sapho-truth-order';
const player = (game: Game, id: string) => { const p = game.players.find(row => row.id === id); assert.ok(p); return p; };
type Method = 'normal' | 'onceAround' | 'silent';
@@ -80,6 +81,7 @@ for (const method of ['normal','onceAround','silent'] as const) void test(
let game = play(f.game,'emperor',f.card,f.mode);
assertParent(game,f);
if (method === 'silent') assertSilent(game,f.bidder);
game = passFreshDiscard(game);
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);