Preserve Basic actions while Sandtrout waits
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-11-16 17:10:21 +11:00
1 parent 338f2d8980
commit c86102583f
10 files changed
+398 -3

No files matched your search

+11
View File
@@ -1,5 +1,16 @@
# Ordinary bribe controls
## Basic bribe with waiting Sandtrout — 16 November 2026
**Prototyped / Partial.** A waiting Sandtrout no longer blocks the existing
supported direct-bribe interruption windows. The actual bribe still uses the
original nonally and uncommitted-spice checks, the recipient's deferred
collection, and the original pending response or decision. This retains the
existing provisional online timing interpretation, not a new publisher ruling.
The focused Basic Ix test draws Sandtrout, pays during the next native phase
opening and follows the saved opening. Other parent and module combinations,
complete games and deployed acceptance remain open.
## Basic ordinary movement responses — 29 October 2026
On supported Basic tables, a direct nonallied bribe may interrupt a clean
+10
View File
@@ -17,6 +17,16 @@ open mode gates.
## Current checkpoint and work
**Basic actions with waiting Sandtrout — 16 November. Prototyped / Partial.**
An actual Ix Spice draw no longer disables supported No-Field reveal, direct
bribes or Emperor gifts during Extortion. The original choice, payment and
commitment safeguards remain. The Extortion scenario forms its alliance after
Sandtrout's break. Six related unit files pass 26 cases; other parent/module
combinations, complete games and deployed acceptance remain open.
[Reveal](RICHESE_NO_FIELD_RULES.md#basic-reveal-with-waiting-sandtrout--16-november-2026),
[bribe](BRIBE_CONTROLS.md#basic-bribe-with-waiting-sandtrout--16-november-2026),
[gift](EMPEROR_ALLIANCE_TIMING.md#basic-extortion-gift-with-waiting-sandtrout--16-november-2026).
**Waiting Sandtrout and battle cards — 16 November. Prototyped / Partial.**
The ordinary waiting Spice effect no longer disables otherwise supported Mirror
Weapon, Stone Burner or independent Reinforcements use. Genuine Basic draws and
+14
View File
@@ -1,5 +1,19 @@
# Emperor alliance gift timing
## Basic Extortion gift with waiting Sandtrout — 16 November 2026
**Prototyped / Partial.** In the existing supported Basic Extortion decision,
waiting Sandtrout no longer suppresses the Emperor's allied spice gift. The
real alliance must exist after Sandtrout's original alliance break. A gift,
its native Karama response or Continue preserves the original payer and token
decision. The existing neutral human-Emperor opportunity before a bot's answer
remains; the online priority is provisional, not a publisher timing ruling.
Focused public-start scenarios draw Sandtrout, form a real Ecaz/Emperor
alliance, reveal Extortion and exercise Allow, cancellation and the bot wait.
Unopened Spice order, a Terror location, one card and the payer's wallet are
staged. Other combinations, complete games and deployed acceptance remain open.
## Advanced Emperor gifts at Ix openings — 16 November 2026
**Prototyped / Partial.** The user-authorized revised Advanced rules, physical
+10
View File
@@ -2,6 +2,16 @@
Audit date: 2026-09-06. This document distinguishes the printed token lifecycle from engine integration and unresolved combinations. It does not certify Richese, Homeworlds, or any other gated game mode.
## Basic reveal with waiting Sandtrout — 16 November 2026
**Prototyped / Partial.** Waiting Sandtrout does not block the existing
supported before-Battle No-Field interruptions. A genuine Basic Ix draw and
the original CHOAM free-Revival Allow or La La La response show the marker
materializing from current reserves before the original force return or
prevention. Prior payment and the physical Spice effect remain unchanged.
Other parents and module combinations, complete games and deployed acceptance
remain open; this extends the existing provisional online ordering.
## Basic reveal after Truthtrance facts — 16 November 2026
**Prototyped / Partial.** A public current-turn history containing only
+2 -2
View File
@@ -17961,7 +17961,7 @@ function bribePaymentPreservesPromises(g: Game, p: Player, recipient: string, am
function basicBribeInterrupt(g: Game, p: Player): boolean {
if (g.status !== 'playing' || g.advanced ||
g.inflation?.side === 'double' || g.techTokens || g.strongholdCards || g.leaderSkills ||
g.homeworlds || g.nexusCards || g.discoveryEnabled || g.discoveries || g.discoveryStash || g.greatMaker || g.sandtrout || g.coalitionState ||
g.homeworlds || g.nexusCards || g.discoveryEnabled || g.discoveries || g.discoveryStash || g.greatMaker || g.coalitionState ||
g.ecazTreachery || g.semutaRecruitsPreview || g.truthtrance ||
g.pendingKarama || g.pendingKull || g.pendingTreacheryDiscard || g.pendingNullentropy ||
g.bureaucratPayments?.pending || g.battle || g.pendingRicheseGift || g.pendingShipment ||
@@ -30892,7 +30892,7 @@ function emperorExtortionGiftPublicEligible(g: Game, p: Player): boolean {
!['atreides', 'beneGesserit', 'emperor', 'fremen', 'guild', 'harkonnen', 'moritani'].includes(seat.faction))
: !g.expansions.includes('ecaz') || !selectedPhaseModuleRoster(g)) ||
g.ecazTreachery || g.techTokens || g.strongholdCards || g.leaderSkills || g.homeworlds || g.nexusCards ||
g.discoveryEnabled || g.sandtrout || g.coalitionState || g.response || g.phaseOpening ||
g.discoveryEnabled || g.coalitionState || g.response || g.phaseOpening ||
g.truthtrance || g.pendingKarama || g.pendingTreacheryDiscard || g.battle ||
g.pendingRicheseGift || g.pendingNullentropy || g.pendingShipment || g.pendingArrivalOverlap ||
!extortion || extortion.stage !== 'payment' || decision?.kind !== 'moritaniExtortion' ||
+3
View File
@@ -296,6 +296,8 @@ export const RULE_TOPICS: RuleTopic[] = [
steps: [
'Open Bribes beneath the table. Choose a non-allied faction and a positive whole amount, then use the named Pay button. The amount is public and leaves your supply immediately. A message or promise alone does not pay spice.',
'The recipient keeps paid spice separately until the next Mentat opening. A payment after the current opening waits for next turn’s opening. Your incoming bribes are shown separately from your spendable supply; they cannot fund bids, shipments or another bribe yet.',
'A waiting Sandtrout does not prevent the supported Basic bribe interruption windows.',
'During a supported Basic Extortion decision, a waiting Sandtrout does not prevent the Emperor gifting spice to an ally formed after the Sandtrout draw.',
'You may pay out of turn when no decision or response is pending, including during Mentat after opening collection. In supported Basic games with classic or selected native expansion factions, direct bribes can also interrupt a normal auction-payment decision, Atreides auction inspection, Fremen allied-revival grant, ordinary Fremen or Ixian movement response, or CHOAM movement decision. Supported Basic Ix and Moritani games also allow payments during the Amal opening or an Extortion choice. The original parent and its passes remain pending. You cannot bribe yourself or your ally, or while Inflation shows Double. Emperor gifts to allies use their own power controls.',
'Your payment limit excludes reserved spending and preserves binding Truthtrance answers. If an alliance, pending decision or available supply changes, recheck the recipient and amount. A rejected payment does not change the game.',
'In the Basic group preview, group allies are excluded from ordinary bribes and nonallied deals. Existing agreements remain recorded and can be released; a deferred bribe to a newly allied recipient stays pending while it is unavailable, subject to its original deadline.',
@@ -1132,6 +1134,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'Richese has three No-Fields, numbered zero, three and five. A concealed token counts as one force. Only one may be deployed on Arrakis, and consecutive own or allied shipments cannot use the same token.',
'In Basic play, your own single concealed No-Field may provisionally ship into an ally’s territory if it can legally enter; move it and any paid accompanying forces out before your turn ends. Paid companions require the High Richese Homeworld power. If the marker remains, reveal it and send its newly materialized forces to Tanks under the provisional no-departure policy. A zero marker reveals but contributes no casualties. Existing physical forces and the ally are not part of that new-visitor loss. Paired markers keep their separate guards.',
'A normal No-Field shipment pays the one-force price. The concealed token moves like a force. Before Battle, Richese may reveal it voluntarily; a token involved in battle is revealed with the Battle Plan. Revelation brings the indicated forces from reserves, limited by what remains there.',
'A waiting Sandtrout does not prevent the supported Basic voluntary-reveal interruption windows.',
'In supported Basic interruptions, a current-turn history of factual Truthtrance answers does not by itself block your reveal. Live promises and questions about future actions retain their existing safeguards.',
'In supported Basic games the voluntary reveal can also occur while CHOAM decides whether to prevent an already-declared free Revival. Reveal uses current reserves; the original Revival and CHOAM decision then continue once.',
'In supported Basic native games, voluntary revelation is also available during an Ix phase opening or selected auction and market decisions without replacing that decision. Other interruption windows remain unfinished.',
+1 -1
View File
@@ -23,7 +23,7 @@ export function richeseRevealInterruptSupported(g: Game): boolean {
g.players.some(player => (player.faction === 'ecaz' || player.faction === 'moritani') && !g.expansions.includes('ecaz')) ||
g.coalitionState || g.coalitionPreview || g.techTokens || g.strongholdCards || g.leaderSkills ||
g.homeworlds || g.nexusCards || g.discoveryEnabled || g.discoveries || g.discoveryStash ||
g.greatMaker || g.sandtrout || g.ecazTreachery || g.truthtrance ||
g.greatMaker || g.ecazTreachery || g.truthtrance ||
g.biddingEnd || g.battle || g.stormResolution || g.spiceResolution || g.spiceSequence ||
g.victoryContinuation || g.currentAuctionSale || g.richeseAllyOffer ||
g.bureaucratPayments?.pending) return false;
@@ -0,0 +1,62 @@
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 Game } from '../game/engine';
import { actIxSpice as act, advanceIxSpice as advance, createIxSpiceFixture,
orderIxSpiceCards } from './fixture-ix-spice-cards';
const seat = (game: Game, id: string) => {
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
};
/** Native Basic Ix setup and actual Sandtrout draw; only unopened Spice order
* is selected by the existing fixture. */
function source() {
const f = createIxSpiceFixture();
let game = f.game;
orderIxSpiceCards(game, ['sandtrout', 'land']);
game = advance(game, state => state.turn === 1 && state.phase === 2 && !!state.phaseOpening);
assert.equal(game.sandtrout, true);
assert.ok(game.log.some(entry => String(entry.text ?? '').includes('Sandtrout')));
return game;
}
void test('an actual waiting Sandtrout does not block a bribe during the next Ix phase opening', () => {
const game = source(), before = structuredClone(game);
const opening = structuredClone(game.phaseOpening);
const payer = seat(game, 'fremen').spice, recipient = seat(game, 'atreides').spice;
const owed = seat(game, 'atreides').bribes;
const options = viewGame(game, 'fremen').bribeOptions;
assert.equal(options.blocked, null);
assert.ok(options.targets.some(target => target.id === 'atreides'));
let after = act(game, 'fremen', {type:'bribe', target:'atreides', amount:1});
assert.deepEqual(game, before);
assert.deepEqual(after.phaseOpening, opening);
assert.equal(seat(after, 'fremen').spice, payer - 1);
assert.equal(seat(after, 'atreides').spice, recipient);
assert.equal(seat(after, 'atreides').bribes, owed + 1);
assert.equal(after.sandtrout, true);
for (const difficulty of DIFFICULTIES) {
const view = viewGame(after, 'harkonnen');
view.players.find(row => row.id === 'harkonnen')!.bot = difficulty;
const ready = botActions(view).find(action => action.type === 'ready');
assert.ok(ready, difficulty); assert.doesNotThrow(() => act(after, 'harkonnen', ready), difficulty);
}
for (const player of after.players) after = act(after, player.id, {type:'ready'});
assert.equal(after.phaseOpening, null);
assert.equal(after.sandtrout, true);
assert.equal(seat(after, 'atreides').bribes, owed + 1);
});
void test('without Sandtrout the same Basic Ix opening still accepts a bribe', () => {
const f = createIxSpiceFixture();
let game = f.game;
orderIxSpiceCards(game, ['land']);
game = advance(game, state => state.turn === 1 && state.phase === 2 && !!state.phaseOpening);
assert.equal(!!game.sandtrout, false);
assert.equal(viewGame(game, 'fremen').bribeOptions.blocked, null);
const next = act(game, 'fremen', {type:'bribe', target:'atreides', amount:1});
assert.deepEqual(next.phaseOpening, game.phaseOpening);
assert.equal(seat(next, 'atreides').bribes, seat(game, 'atreides').bribes + 1);
});
@@ -0,0 +1,152 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
import { territory } from '../game/board';
import { placeTerror } from '../game/moritani-terror';
import { botActions, runBots } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards';
import { nextStrongholdFactionsNativeStep } from './fixture-stronghold-factions';
const act = (g: Game, id: string, action: Action) => applyAction(g, id, action);
function seat(g: Game, id: string) { const p = g.players.find(row => row.id === id); assert.ok(p); return p; }
const clean = (g: Game) => !g.response && !g.decision && !g.phaseOpening && !g.truthtrance && !g.pendingTreacheryDiscard;
function cards(g: Game) {
const ids = [...g.deck, ...g.discard, ...(g.auction?.cards.slice(g.auction.index) ?? []),
...(g.ixAuction?.cards ?? []), ...g.players.flatMap(p => p.hand)].map(c => c.id).sort();
assert.equal(new Set(ids).size, ids.length); return ids;
}
function advance(g: Game, until: (g: Game) => boolean): Game {
for (let n = 0; n < 2000; n++) {
if (until(g)) return g;
assert.notEqual(g.status, 'finished', JSON.stringify({turn:g.turn,phase:g.phase,log:g.log.filter(x => /Extortion|extortion/i.test(x.text))}));
if (g.status === 'setup' && g.setupStage === 'forces' && seat(g, 'ecaz').reserves === 20)
g = act(g, 'ecaz', {type:'ecazSetup', placements:{'imperial_basin:9':6}});
else if (g.status === 'setup' && !g.setupStage && g.decision?.kind === 'moritaniSetup')
g = act(g, 'moritani', {type:'decision', territory:'oh_gap', sector:9});
else if (g.decision?.kind === 'ecazPlacement' && !g.response && !g.phaseOpening)
g = act(g, 'ecaz', {type:'decision', decline:true});
else if (g.decision?.kind === 'moritaniPlacement' && !g.response && !g.phaseOpening)
g = act(g, 'moritani', {type:'decision', decline:true});
else {
const next = nextStrongholdFactionsNativeStep(g); assert.ok(next, `No native continuation at ${g.phase}/${g.decision?.kind}`);
g = act(g, next.actor, next.action);
}
}
throw Error('Native play did not reach the Extortion choice');
}
function passResponse(g: Game): Game {
while (g.response) {
const responder = g.players.find(p => !g.response!.passed.includes(p.id)); assert.ok(responder);
g = act(g, responder.id, {type:'passResponse'});
}
return g;
}
/** Genuine public setup, first Spice draw, Ecaz alliance and Extortion entry.
* Unopened Spice order, conserved board placement, Terror location, one Karama
* and the final payer's wallet are staged for this narrow timing case. */
function fixture() {
let g = createGame('EXTORTIONSANDTROUT', newPlayer('ecaz','Ecaz','ecaz'), false, ['ecaz','ix']);
for (const id of ['moritani','emperor','atreides','guild'] as const) joinGame(g, newPlayer(id,id,id));
for (const p of g.players) g = act(g,p.id,{type:'ready'});
g = act(g,'ecaz',{type:'start'});
g = advance(g, state => state.status === 'playing');
const inventory = cards(g);
for (const p of g.players) {
p.reserves += Object.values(p.forces).reduce((sum, amount) => sum + amount, 0);
p.forces = {};
}
g = advance(g, beforeIxSpiceDraw);
orderIxSpiceCards(g, ['sandtrout','land']);
g = advance(g, state => state.phase === 4 && !state.response && !state.phaseOpening && state.decision?.kind === 'ecazPlacement');
assert.equal(g.sandtrout,true);
const spots = ['habbanya_ridge_sietch','sietch_tabr','carthag','arrakeen','tueks_sietch']
.map(id => ({territory:id,sector:territory(id).sectors.find(s => s !== g.storm)}))
.filter((row): row is {territory:string;sector:number} => row.sector !== undefined);
assert.ok(spots.length >= 2);
const [allianceSpot, terrorSpot] = spots;
const self = g.ecazAmbassadors!.tokens.find(row => row.effect === 'ecaz'); assert.ok(self);
g = act(g,'ecaz',{type:'decision', token:self.id, territory:allianceSpot.territory});
g = advance(g, state => !state.response && state.decision?.kind === 'ecazPlacement');
g = act(g,'ecaz',{type:'decision',decline:true});
g = advance(g, state => state.phase === 5 && clean(state));
const terror = g.moritaniTerror!.tokens.find(row => row.kind === 'extortion'); assert.ok(terror);
g.moritaniTerror = placeTerror(g.moritaniTerror!,terror.id,terrorSpot.territory,g.turn);
let emperorEntered = false, atreidesEntered = false;
for (let n=0; g.phase === 5 && n<100; n++) {
if (!clean(g)) {
const next = nextStrongholdFactionsNativeStep(g); assert.ok(next);
g = act(g,next.actor,next.action); continue;
}
if (g.active === 'emperor' && !emperorEntered) {
g = act(g,'emperor',{type:'ship',amount:1,territory:allianceSpot.territory,sector:allianceSpot.sector});
g = advance(g,state => !state.response && state.pendingAmbassador?.stage === 'offer');
const event = g.pendingAmbassador!.event;
g = act(g,'ecaz',{type:'decision',event,trigger:true,beneficiary:'ecaz',choice:'alliance'});
g = act(g,'emperor',{type:'decision',event,accept:true});
assert.equal(g.pendingAmbassador?.stage,'loan');
g = act(g,'ecaz',{type:'decision',event,loan:false});
assert.equal(seat(g,'ecaz').ally,'emperor'); assert.equal(seat(g,'emperor').ally,'ecaz');
assert.equal(g.sandtrout,true); emperorEntered = true;
} else if (g.active === 'atreides' && !atreidesEntered) {
g = act(g,'atreides',{type:'ship',amount:1,territory:terrorSpot.territory,sector:terrorSpot.sector});
g = advance(g,state => !state.response && state.decision?.kind === 'moritaniTerror');
g = act(g,'moritani',{type:'decision',reveal:true});
assert.equal(g.moritaniTerror!.tokens.find(row => row.id === terror.id)?.status,'extortion');
atreidesEntered = true;
} else {
const next = nextStrongholdFactionsNativeStep(g); assert.ok(next);
g = act(g,next.actor,next.action);
}
}
assert.ok(emperorEntered && atreidesEntered); assert.equal(g.sandtrout,true);
assert.ok(g.moritaniExtortion, JSON.stringify({phase:g.phase,log:g.log.slice(-8)}));
g = advance(g,state => state.phase === 8 && state.decision?.kind === 'moritaniExtortion');
while (g.decision?.kind === 'moritaniExtortion' && g.decision.player !== 'ecaz')
g = act(g,g.decision.player,{type:'decision',event:g.decision.event,pay:false});
assert.ok(g.decision?.kind === 'moritaniExtortion' && g.decision.player === 'ecaz');
seat(g,'ecaz').spice = 2;
assert.ok(seat(g,'emperor').spice >= 1);
const guild = seat(g,'guild');
let karama = guild.hand.find(card => card.effect === 'karama');
if (!karama) {
const source = g.players.find(p => p.id !== 'guild' && p.hand.some(c => c.effect === 'karama'))?.hand ?? g.deck;
const index = source.findIndex(c => c.effect === 'karama'); assert.ok(index >= 0);
[karama] = source.splice(index,1); guild.hand.push(karama);
}
assert.deepEqual(cards(g),inventory);
return {g, token:terror.id, karama:karama.id, inventory};
}
for (const cancel of [false,true]) void test(`Basic Emperor gift during Extortion with waiting Sandtrout ${cancel ? 'can be canceled' : 'enables payment'}`, () => {
const f = fixture(), before = structuredClone(f.g);
const event = f.g.decision!.kind === 'moritaniExtortion' ? f.g.decision.event : '';
assert.ok(event); assert.equal(viewGame(f.g,'ecaz').extortion.pending?.canPay,false);
assert.ok(viewGame(f.g,'emperor').emperorExtortionGift);
for (const id of ['ecaz','atreides','guild','moritani']) assert.equal(viewGame(f.g,id).emperorExtortionGift,null);
let g = act(f.g,'emperor',{type:'emperorGift',amount:1});
assert.equal(g.response?.kind,'emperorGift');
g = cancel ? act(g,'guild',{type:'card',mode:'cancel',card:f.karama}) : passResponse(g);
assert.deepEqual(g.decision,before.decision); assert.deepEqual(g.moritaniExtortion,before.moritaniExtortion);
assert.equal(seat(g,'ecaz').spice,cancel ? 2 : 3);
assert.equal(seat(g,'emperor').spice,seat(before,'emperor').spice - (cancel ? 0 : 1));
assert.equal(g.sandtrout,true);
g = act(g,'ecaz',{type:'decision',event,pay:!cancel});
assert.equal(g.moritaniTerror!.tokens.find(row => row.id === f.token)?.status,cancel ? 'extortion' : 'removed');
assert.deepEqual(cards(g),f.inventory);
});
void test('a bot Ecaz waits for the human Emperor during Extortion while Sandtrout waits', () => {
const f = fixture();
assert.ok(f.g.decision?.kind === 'moritaniExtortion');
const event = f.g.decision.event;
for (const difficulty of DIFFICULTIES) {
let g = structuredClone(f.g); seat(g,'ecaz').bot = difficulty;
assert.deepEqual(viewGame(g,'emperor').emperorExtortionPriority,{event,recipient:'ecaz',canContinue:true});
assert.ok(!botActions(viewGame(g,'ecaz')).some(action => action.type === 'decision' && action.event === event));
const waiting = runBots(g,2); assert.equal(waiting.decision?.kind,'moritaniExtortion');
g = act(g,'emperor',{type:'emperorExtortionContinue',event});
const action = botActions(viewGame(g,'ecaz')).find(row => row.type === 'decision' && row.event === event);
assert.ok(action,difficulty); assert.doesNotThrow(() => act(g,'ecaz',action));
}
});
@@ -0,0 +1,133 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards';
import { actTruthMovementNativeEarly as act, nextTruthMovementNativeEarlyStep } from './fixture-truth-movement-native-early';
import { truthMovementInventory as inventory } from './fixture-truth-movement';
const richese = 'richese', choam = 'choam', atreides = 'atreides';
function seat(game: Game, id: string) {
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
}
const clean = (g: Game) => !g.response && !g.decision && !g.phaseOpening &&
!g.truthtrance && !g.pendingRevival && !g.pendingTreacheryDiscard;
function next(game: Game) {
if (game.turn === 1 && game.phase === 5 && game.active === richese && clean(game)) {
const player = seat(game, richese);
if (!player.shipped) {
const token = player.noField!.tokens.find(row => row.value === 3); assert.ok(token);
return { actor:richese, action:{ type:'ship', noField:token.id, event:player.noFieldEvent,
territory:'polar_sink', sector:0, allyPayment:0 } satisfies Action };
}
return { actor:richese, action:{type:'endMovement'} satisfies Action };
}
if (game.phase === 5 && game.active && clean(game))
return { actor:game.active, action:{type:'endMovement'} satisfies Action };
return nextTruthMovementNativeEarlyStep(game, { position:'first', method:'onceAround', direction:'clockwise' });
}
function reach(game: Game, until: (state: Game) => boolean) {
for (let i = 0; i < 2400; i++) {
if (until(game)) return game;
assert.notEqual(game.status, 'finished');
const step = next(game); assert.ok(step, `Original action missing at ${game.turn}/${game.phase}/${game.decision?.kind}`);
game = act(game, step.actor, step.action);
}
throw Error('Native game did not reach the requested Revival control');
}
/** Genuine Basic Ix/CHOAM public setup, paid marker and actual Sandtrout draw.
* Only unopened Spice order, physical prior casualties/board placement, and a
* physical La La La card location are staged. */
function source() {
let game = createGame('REVEALSANDTROUT', newPlayer(richese, 'Richese', 'richese'), false, ['ix', 'choam']);
joinGame(game, newPlayer(choam, 'CHOAM', 'choam'));
joinGame(game, newPlayer(atreides, 'Atreides', 'atreides'));
game = act(game, richese, {type:'moduleOption', module:'kullPreview', enabled:false});
for (const player of game.players) game = act(game, player.id, {type:'ready'});
game = act(game, richese, {type:'start'});
game = reach(game, state => state.status === 'playing');
game = reach(game, beforeIxSpiceDraw);
orderIxSpiceCards(game, ['land', 'land']);
game = reach(game, state => state.turn === 2 && beforeIxSpiceDraw(state));
assert.ok(seat(game, richese).noField?.deployed, 'The marker was shipped in the original first turn');
orderIxSpiceCards(game, ['sandtrout', 'land']);
game = reach(game, state => state.turn === 2 && state.phase === 4 && clean(state));
assert.equal(game.sandtrout, true, 'The original Sandtrout draw remains waiting');
const owner = seat(game, richese), marker = owner.noField?.deployed, event = owner.noFieldEvent;
assert.ok(marker); assert.ok(event);
assert.ok(owner.reserves >= 3);
owner.reserves -= 3; owner.tanks += 3;
const moved = owner.reserves - 1; assert.ok(moved >= 0);
owner.reserves -= moved; owner.forces['polar_sink:0'] = (owner.forces['polar_sink:0'] ?? 0) + moved;
const physical = inventory(game);
const c = seat(game, choam);
if (!c.hand.some(card => card.name === 'La La La')) {
let index = game.deck.findIndex(card => card.name === 'La La La');
if (index >= 0) c.hand.push(game.deck.splice(index, 1)[0]);
else {
const holder = game.players.find(player => player.hand.some(card => card.name === 'La La La'));
if (holder) {
index = holder.hand.findIndex(card => card.name === 'La La La');
c.hand.push(holder.hand.splice(index, 1)[0]);
} else {
index = game.discard.findIndex(card => card.name === 'La La La'); assert.ok(index >= 0);
c.hand.push(game.discard.splice(index, 1)[0]);
}
}
}
assert.deepEqual(inventory(game), physical);
game = act(game, richese, {type:'revive', amount:2, elite:0});
assert.ok(game.decision?.kind === 'choamFreeRevival');
assert.equal(game.decision.recipient, richese);
return {game, token:marker.tokenId, event, physical};
}
for (const deny of [false, true]) void test(
`Richese reveals its marker with waiting Sandtrout before CHOAM ${deny ? 'prevents' : 'allows'} its free return`, () => {
const f = source(), before = structuredClone(f.game), p = seat(f.game, richese);
const field = p.forces['polar_sink:0'] ?? 0, tanks = p.tanks, revived = p.revived;
const forceCount = (g: Game) => {
const owner = seat(g, richese);
return owner.reserves + owner.tanks + Object.values(owner.forces).reduce((sum, amount) => sum + amount, 0);
};
assert.equal(p.reserves, 1); assert.equal(forceCount(f.game), 20);
const ownerView = viewGame(f.game, richese);
assert.equal(ownerView.richeseNoField?.canReveal, true);
let game = act(f.game, richese, {type:'revealNoField', token:f.token, event:f.event});
assert.deepEqual(f.game, before);
assert.deepEqual(game.decision, before.decision);
assert.deepEqual(game.pendingRevival, before.pendingRevival);
assert.equal(game.sandtrout, true);
assert.equal(seat(game, richese).reserves, 0);
assert.equal(seat(game, richese).forces['polar_sink:0'], field + 1);
assert.equal(forceCount(game), 20);
for (const difficulty of DIFFICULTIES) {
const view = viewGame(game, choam); view.players.find(row => row.id === choam)!.bot = difficulty;
const action = botActions(view)[0]; assert.ok(action, difficulty);
assert.doesNotThrow(() => act(game, choam, action), difficulty);
}
if (deny) {
const card = seat(game, choam).hand.find(row => row.name === 'La La La'); assert.ok(card);
game = act(game, choam, {type:'card', mode:'choam', card:card.id});
} else game = act(game, choam, {type:'decision', decline:true});
for (let i = 0; (game.response || game.pendingTreacheryDiscard) && i < 40; i++) {
if (game.pendingTreacheryDiscard?.reaction) {
const reaction = game.pendingTreacheryDiscard.reaction; assert.ok(reaction.stage === 'offer');
const player = game.players.find(row => !reaction.passed.includes(row.id)); assert.ok(player);
game = act(game, player.id, {type:'semutaPass', event:game.pendingTreacheryDiscard.batch.event});
} else if (game.response) {
const player = game.players.find(row => !game.response!.passed.includes(row.id)); assert.ok(player);
game = act(game, player.id, {type:'passResponse'});
} else break;
}
assert.equal(game.pendingRevival, null);
assert.equal(seat(game, richese).tanks, tanks - (deny ? 0 : 2));
assert.equal(seat(game, richese).reserves, deny ? 0 : 2);
assert.equal(seat(game, richese).revived, revived + (deny ? 0 : 2));
assert.equal(seat(game, richese).forces['polar_sink:0'], field + 1);
assert.equal(game.sandtrout, true); assert.equal(forceCount(game), 20);
assert.deepEqual(inventory(game), f.physical);
},
);