Connect Advanced Black Market gifts and BG arrivals
Verify and publish checkpoint container / container (push) Successful in 11m32s

This commit is contained in:
Quintine committed 2026-11-16 18:33:50 +11:00
1 parent 28700389dc
commit 1f3bc349ba
9 files changed
+274 -25

No files matched your search

+14 -4
View File
@@ -17,22 +17,32 @@ open mode gates.
## Current checkpoint and work
**Advanced Black Market gifts and Bene Gesserit arrivals — 16 November.
Prototyped / Partial.** Supported Black Market sales now permit the Emperor's
allied gift for Normal, Once Around and Silent auctions, including provisional
paid self-retention, while preserving the original card and funded split.
Richese may also reveal its No-Field during a supported Bene Gesserit movement
into the same CHOAM-occupied destination; the declared stance and movement
remain intact. Twenty-two related unit files pass 119 cases. Other modules, nested arrivals, full games and deployed
acceptance remain open. [Auction scope](EMPEROR_ALLIANCE_TIMING.md#advanced-selected-deck-allied-auction-gifts--16-november-2026),
[movement scope](RICHESE_NO_FIELD_RULES.md#advanced-foreign-movement-reveal--16-november-2026).
**Advanced Emperor auction gifts with expansion factions — 16 November.
Prototyped / Partial.** Supported selected-deck ordinary and Richese cache
auctions now retain the original winning lot and Advanced bank/seller payment
split through an allied gift or Continue. A live Truthtrance funding Yes can
be fulfilled at the opportunity; supported Advanced Semuta and printed Kull
can react to its cancellation. Genuine public-start journeys include waiting
Sandtrout and ordinary/cache auction pledges; 27 related unit files pass 147 cases. Black
Market, broader optional combinations, complete games and deployed acceptance
Sandtrout and ordinary/cache auction pledges; 27 related unit files pass 147 cases.
Further Black Market interactions, optional combinations, complete games and deployed acceptance
remain open. [Scope](EMPEROR_ALLIANCE_TIMING.md#advanced-selected-deck-allied-auction-gifts--16-november-2026).
**Advanced No-Field reveal during foreign movement — 16 November. Prototyped /
Partial.** Supported foreign Fremen and Ixian movement responses and CHOAM
movement decisions retain their original physical move while Richese reveals.
Genuine Advanced journeys cover zero/three markers, response cancellation and
legal bots; five related unit files pass 41 cases. A Bene Gesserit destination
stance case, other nested arrivals, modules, complete games and deployed
legal bots; five related unit files pass 41 cases. Other nested arrivals,
modules, complete games and deployed
acceptance remain open. The existing Basic bribe profile remains unchanged.
[Scope](RICHESE_NO_FIELD_RULES.md#advanced-foreign-movement-reveal--16-november-2026).
+8 -4
View File
@@ -3,8 +3,9 @@
## Advanced selected-deck allied auction gifts — 16 November 2026
**Prototyped / Partial.** Supported Advanced selected-deck games now offer the
Emperor's allied gift before an ordinary auction payment or a Richese Once
Around/Silent cache sale. Continue retains the original winning card, price and
Emperor's allied gift before an ordinary auction payment, a Richese Once
Around/Silent cache sale, or an Advanced Black Market sale using any of its
three auction methods. Continue retains the original winning card, price and
funding split. A direct gift becomes the buyer's own spice; the Emperor's
separately pledged contribution follows the Advanced bank route. Allowing or
canceling the gift leaves the original purchase intact. A waiting Sandtrout does
@@ -26,13 +27,16 @@ allied transfers at any time; physical p. 15 / printed p. 13 distinguishes
direct gifts from the Emperor's bank-paid auction contributions. Public-start
[ordinary](../tests/emperor-auction-gift-advanced-native.test.ts),
[cache](../tests/emperor-richese-cache-gift-advanced-public.test.ts),
[Black Market](../tests/emperor-richese-black-market-gift-advanced.test.ts),
[Sandtrout](../tests/emperor-auction-gift-advanced-waiting-sandtrout.test.ts),
[pledge](../tests/emperor-auction-gift-advanced-pledge.test.ts),
[Semuta](../tests/emperor-auction-gift-advanced-semuta.test.ts) and
[Kull](../tests/emperor-auction-gift-advanced-kull.test.ts) journeys use
actual alliances and sales with disclosed staging of cards, wallets, forces or
unopened Spice order. Black Market, optional modules, broader combinations,
complete games and deployed acceptance remain open.
unopened Spice order. Black Market paid self-retention follows the separately
documented provisional policy; unbid and canceled lots do not become paid
sales. Optional modules, broader combinations, complete games and deployed
acceptance remain open.
## Advanced Emperor gift at a Guild rate response — 16 November 2026
+7 -5
View File
@@ -12,11 +12,13 @@ from the movement destination without repeating the move. The shared movement
classifier requires an explicit Advanced opt-in, so Basic-only bribe behavior
is unchanged.
An Advanced Bene Gesserit move into the marker's own territory remains guarded
for all concealed values: revealing zero could change the destination presence
used to select the already committed advisor/fighter stance. This is a
software boundary, not a new publisher restriction. Other arrival parents,
modules, commitments, complete games and deployed acceptance remain open.
An Advanced Bene Gesserit move into the marker's territory can also continue
through the supported CHOAM movement decision. That decision requires CHOAM's
own presence at the destination, so even a zero marker disappearing does not
leave the arriving Bene Gesserit alone or alter the committed stance.
[Advisor and fighter journeys](../tests/richese-reveal-advanced-bg-destination.test.ts)
cover zero and three markers with conserved staged positions. Other arrival
parents, modules, commitments, complete games and deployed acceptance remain open.
[Public-start journeys](../tests/richese-reveal-advanced-foreign-movement.test.ts)
use original movement actions, selected unopened Spice order and conserved
staged force/card placement. The revised Advanced rules physical p. 5 /
+3 -3
View File
@@ -3,7 +3,7 @@
## Advanced selected-deck Emperor auction gifts — 16 November 2026
The existing provisional prepayment gift extends to supported Advanced
selected-deck ordinary and Richese cache auctions. Native split routing stays
selected-deck ordinary, Richese cache and Advanced Black Market auctions. Native split routing stays
unchanged; an outstanding funding Yes can be completed before Continue.
[Scope](EMPEROR_ALLIANCE_TIMING.md#advanced-selected-deck-allied-auction-gifts--16-november-2026).
@@ -11,8 +11,8 @@ unchanged; an outstanding funding Yes can be completed before Continue.
The existing provisional reveal ordering extends to supported Advanced foreign
Fremen/Ixian moves and CHOAM movement decisions, preserving original physical
movement. A Bene Gesserit arrival-stance case remains guarded for every marker
value. [Scope](RICHESE_NO_FIELD_RULES.md#advanced-foreign-movement-reveal--16-november-2026).
movement, including the supported Bene Gesserit arrival at a CHOAM-occupied
destination. [Scope](RICHESE_NO_FIELD_RULES.md#advanced-foreign-movement-reveal--16-november-2026).
## Advanced No-Field reveal interruptions — 16 November 2026
+4 -2
View File
@@ -19241,7 +19241,8 @@ function emperorAuctionGiftSignature(g: Game): string {
return JSON.stringify([g.turn, g.phase, g.active, g.decision ?? emperorAuctionGiftParked(g)?.decision, g.order, g.auction, g.aid]);
}
function beginEmperorRicheseAuctionGift(g: Game, quote: Extract<RicheseSettlementQuote,{kind:'sold'}>, bank = false): boolean {
if (g.status !== 'playing' || g.phase !== 3 || g.richeseAuction?.source !== 'cache' ||
if (g.status !== 'playing' || g.phase !== 3 ||
!(g.richeseAuction?.source === 'cache' || g.advanced && g.richeseAuction?.source === 'blackMarket') ||
g.techTokens || g.strongholdCards || g.leaderSkills || g.homeworlds ||
(g.advanced && g.nexusCards) || g.discoveryEnabled || g.coalitionState || g.ecazTreachery ||
g.pendingEmperorAuctionGift || g.response || g.decision || g.phaseOpening || g.truthtrance ||
@@ -19291,7 +19292,8 @@ function emperorAuctionGiftIntegrity(g: Game) {
typeof pending.event === 'string' && !!pending.event && owner?.faction === 'emperor' && recipient &&
owner.ally === recipient.id && recipient.ally === owner.id &&
(pending.source === 'richese'
? (pending.bank === undefined || pending.bank === true) && !decision && !g.auction && g.richeseAuction?.source === 'cache' && !!pending.quote &&
? (pending.bank === undefined || pending.bank === true) && !decision && !g.auction &&
(g.richeseAuction?.source === 'cache' || g.advanced && g.richeseAuction?.source === 'blackMarket') && !!pending.quote &&
pending.quote.winner === recipient.id && JSON.stringify(pending.quote) === JSON.stringify(richeseSettlementQuote(g)) &&
(!pending.bank || !!g.richeseBetrayalPreview && !!g.richeseBetrayal?.completed.some(receipt =>
receipt.stage === 'used' && receipt.invoice.kind === 'sale' && receipt.lot === g.richeseAuction!.event &&
+2 -1
View File
@@ -298,7 +298,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'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 supported Basic phase openings, auction payments, Richese cache sales and Extortion decisions, a waiting Sandtrout does not prevent the Emperor gifting spice to an ally formed after the Sandtrout draw.',
'In supported Advanced selected-deck auctions, the Emperor may gift spice before an allied ordinary purchase or Richese cache sale. The original split remains: direct gifts are the buyer’s spice, while the Emperor’s pledged share goes to the bank. A promised funding update can be completed before continuing.',
'In supported Advanced selected-deck auctions, the Emperor may gift spice before an allied ordinary purchase, Richese cache sale or Black Market sale. The original split remains: direct gifts are the buyer’s spice, while the Emperor’s pledged share goes to the bank. A promised funding update can be completed before continuing.',
'In supported classic Advanced games, the Emperor may share spice before a pending Guild shipment-rate response continues. Allowing or canceling the gift returns to the same rate decision and shipment.',
'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.',
@@ -1138,6 +1138,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'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 Advanced games, the same before-Battle reveal is available during the connected auction, Revival, inspection and other independent response windows. Your actual reserves determine how many forces appear; the original decision or response continues.',
'When CHOAM is deciding a supported Bene Gesserit move into its territory, Richese may reveal a No-Field there. The declared movement and advisor or fighter stance continue.',
'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 auctions, reveal can also occur during the Emperor’s allied gift opportunity or its response. The original lot, pledged funds and gift continue unchanged.',
+3 -6
View File
@@ -13,11 +13,8 @@ export function richeseRevealForeignMovementPending(g: Game): MovementPending |
if (!richese || !deployed || deployed.controller !== richese.id ||
!deployed.location || !('territory' in deployed.location)) return null;
const movement = basicPendingMovement(g, {allowAdvanced:true});
// A zero marker can remove the only other faction at a BG destination.
// Preserve the already selected Advanced arrival stance for all hidden
// marker values until that special continuation can be re-quoted.
if (g.advanced && movement?.key === 'pendingChoamMove' &&
g.players.find(player => player.id === movement.player)?.faction === 'beneGesserit' &&
g.pendingChoamMove?.to === deployed.location.territory) return null;
// A CHOAM decision requires CHOAM's own presence at the destination.
// Thus a zero marker disappearing cannot leave a BG arrival alone or
// change its already declared advisor/fighter stance.
return movement && movement.player !== richese.id ? movement.key : null;
}
@@ -0,0 +1,134 @@
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 {botActions} from '../game/bots';
import {DIFFICULTIES} from '../game/bot-profiles';
import {takeKullCard} from './fixture-choam-kull';
import {advanceSemutaNexusTrade, nextSemutaNexusTradeNativeStep} from './fixture-semuta-nexus-trade';
import {beforeIxSpiceDraw, orderIxSpiceCards} from './fixture-ix-spice-cards';
const act=(game:Game,id:string,action:Action)=>applyAction(game,id,action);
const seat=(game:Game,id:string)=>{const player=game.players.find(row=>row.id===id);assert.ok(player);return player;};
const quiet=(game:Game)=>!game.phaseOpening&&!game.response&&!game.decision&&!game.truthtrance&&!game.pendingTreacheryDiscard;
function inventory(game:Game) {
const cards=[...game.deck,...game.discard,...(game.richeseCache??[]),...(game.richeseRemoved??[]),
...(game.auction?.cards.slice(game.auction.index+Number(game.currentAuctionSale?.origin==='normal'))??[]),
...(game.ixAuction?.cards??[]),...game.players.flatMap(player=>player.hand)].map(card=>card.id).sort();
assert.equal(new Set(cards).size,cards.length);return cards;
}
function finishResponses(game:Game):Game {
for(let n=0;game.response&&n<20;n++) {
const actor=game.players.find(player=>!game.response!.passed.includes(player.id));assert.ok(actor);
game=act(game,actor.id,{type:'passResponse'});
}
return game;
}
function finishDiscardOffers(game:Game):Game {
for(let n=0;game.pendingTreacheryDiscard?.reaction?.stage==='offer'&&n<20;n++) {
const pending=game.pendingTreacheryDiscard,reaction=pending.reaction;
assert.ok(reaction&&reaction.stage==='offer');
const actor=game.players.find(player=>!reaction.passed.includes(player.id));assert.ok(actor);
game=act(game,actor.id,{type:'semutaPass',event:pending.batch.event});
}
return game;
}
/** Original Advanced setup, natural second-turn worm and actual mutual alliance.
* The unopened Spice order, conserved board positions, hands and purses are staged. */
function fixture(method:'normal'|'onceAround'|'silent', self=false) {
let game=createGame('ADVBLACKGIFT',newPlayer('e','Emperor','emperor'),true,['choam','ix']);
for(const [id,faction] of [['g','guild'],['c','choam'],['r','richese'],['a','atreides']] as const)
joinGame(game,newPlayer(id,faction,faction));
for(const player of game.players)game=act(game,player.id,{type:'ready'});
game=act(game,'e',{type:'start',advancedPreview:true});
game=advanceSemutaNexusTrade(game,state=>state.status==='playing');
for(const player of game.players){player.reserves+=Object.values(player.forces).reduce((sum,n)=>sum+n,0);player.forces={};}
game=advanceSemutaNexusTrade(game,beforeIxSpiceDraw);orderIxSpiceCards(game,['land','land']);
game=advanceSemutaNexusTrade(game,state=>state.turn===2&&beforeIxSpiceDraw(state));
orderIxSpiceCards(game,['worm','land','land']);
game=advanceSemutaNexusTrade(game,state=>!!state.nexus&&!state.spiceWindow&&quiet(state));
const buyer=self?'r':'g';
game=act(game,'e',{type:'alliance',target:buyer});game=act(game,buyer,{type:'alliance',target:'e'});
game=advanceSemutaNexusTrade(game,state=>state.phase===3&&state.phaseOpening?.initialize===true);
for(const player of game.players)game.deck.push(...player.hand.splice(0));
const karama=takeKullCard(game,'karama');seat(game,'a').hand.push(karama);
const card=game.deck.shift();assert.ok(card);seat(game,'r').hand.push(card);
seat(game,buyer).spice=7;seat(game,'e').spice=8;
game=advanceSemutaNexusTrade(game,state=>state.decision?.kind==='richeseBlackMarket');
const physical=inventory(game), originalHand=seat(game,'r').hand.map(row=>row.id);
game=act(game,'r',{type:'decision',event:game.richeseBidding!.event,card:card.id,method,
...(method==='onceAround'?{direction:'clockwise'}:{})});
game=finishResponses(game);
assert.equal(game.richeseAuction?.source,'blackMarket');
game=act(game,'e',{type:'pledgeAid',amount:1});
let bid=false, opening=false;
for(let n=0;!game.pendingEmperorAuctionGift&&n<300;n++) {
const lot=game.richeseAuction;
if(lot&&!lot.outcome&&!game.response&&!game.decision&&lot.method!=='silent'&&lot.active) {
const actor=lot.active, winning=actor===buyer&&!bid;
const prebid=self&&method==='onceAround'&&actor!==buyer&&!opening;
game=act(game,actor,{type:'richeseBid',event:lot.event,amount:winning?3:prebid?1:null,
...(winning?{allyPayment:1}:{})});
if(winning)bid=true;
if(prebid)opening=true;
} else if(lot&&!lot.outcome&&!game.response&&!game.decision&&lot.method==='silent') {
const actor=lot.eligible.find(id=>!Object.hasOwn(lot.sealed,id));assert.ok(actor);
const winning=actor===buyer&&!bid;
game=act(game,actor,{type:'richeseBid',event:lot.event,amount:winning?3:0,...(winning?{allyPayment:1}:{})});
if(winning)bid=true;
} else {
const next=nextSemutaNexusTradeNativeStep(game);game=act(game,next.actor,next.action);
}
}
assert.equal(bid,true);assert.ok(game.pendingEmperorAuctionGift,'Emperor receives the original Black Market purchase opportunity');
assert.equal(game.richeseAuction?.outcome?.kind,'sold');assert.equal(game.currentAuctionSale??null,null);
assert.equal(viewGame(game,'e').emperorAuctionGift?.recipient,buyer);
return {game,buyer,card:card.id,karama:karama.id,physical,originalHand};
}
for(const method of ['normal','onceAround','silent'] as const) for(const mode of ['continue','allow','cancel'] as const) void test(
`Advanced ${method} Black Market sale retains seller custody and split after Emperor ${mode}`,()=>{
const f=fixture(method),before=structuredClone(f.game),lot=structuredClone(f.game.richeseAuction);
const funding=structuredClone(f.game.richeseFunding),aid=structuredClone(f.game.aid);
const offer=viewGame(f.game,'e').emperorAuctionGift;assert.ok(offer);
for(const difficulty of DIFFICULTIES) {
const view=viewGame(f.game,'e');view.players.find(player=>player.id==='e')!.bot=difficulty;
const action=botActions(view).find(row=>row.type==='emperorAuctionGiftContinue');assert.ok(action,difficulty);
assert.doesNotThrow(()=>act(f.game,'e',action),difficulty);
}
let game=f.game;
if(mode!=='continue') {
game=act(game,'e',{type:'emperorGift',amount:2});assert.equal(game.response?.kind,'emperorGift');
if(mode==='cancel')game=finishDiscardOffers(act(game,'a',{type:'card',mode:'cancel',card:f.karama}));
else game=finishResponses(game);
}
assert.deepEqual(game.richeseAuction,lot);assert.deepEqual(game.richeseFunding,funding);assert.deepEqual(game.aid,aid);
assert.equal(game.pendingEmperorAuctionGift?.event,offer.event);
assert.ok(seat(game,'r').hand.some(row=>row.id===f.card),'Seller retains the physical card before settlement');
assert.equal(seat(game,'e').spice,seat(before,'e').spice-(mode==='allow'?2:0));
assert.equal(seat(game,f.buyer).spice,seat(before,f.buyer).spice+(mode==='allow'?2:0));
game=act(game,'e',{type:'emperorAuctionGiftContinue',event:offer.event});
game=finishResponses(game);
assert.ok(seat(game,f.buyer).hand.some(row=>row.id===f.card));
assert.ok(!seat(game,'r').hand.some(row=>row.id===f.card));
assert.equal(seat(game,f.buyer).spice,seat(before,f.buyer).spice+(mode==='allow'?2:0)-2);
assert.equal(seat(game,'e').spice,seat(before,'e').spice-(mode==='allow'?2:0));
assert.equal(game.aid.e?.amount??0,0);
assert.equal(seat(game,'r').spice,seat(before,'r').spice+2,'Emperor-funded one goes to the bank, buyer-funded two to Richese');
assert.deepEqual(inventory(game),f.physical);
});
for(const method of ['normal','onceAround','silent'] as const) void test(
`Advanced ${method} Black Market seller retains its own card after an Emperor gift`,()=>{
const f=fixture(method,true),before=structuredClone(f.game);
const offer=viewGame(f.game,'e').emperorAuctionGift;assert.ok(offer);
let game=act(f.game,'e',{type:'emperorGift',amount:2});game=finishResponses(game);
assert.deepEqual(seat(game,'r').hand.map(row=>row.id),f.originalHand);
game=act(game,'e',{type:'emperorAuctionGiftContinue',event:offer.event});
game=finishResponses(game);
assert.deepEqual(seat(game,'r').hand.map(row=>row.id),f.originalHand,'Paid self-retention does not reacquire or reorder the card');
assert.equal(seat(game,'r').spice,seat(before,'r').spice,'Gift two less buyer-funded two');
assert.equal(seat(game,'e').spice,seat(before,'e').spice,'Gift two less Emperor-funded bank one plus buyer-funded income two');
assert.equal(game.aid.e?.amount??0,0);
assert.deepEqual(inventory(game),f.physical);
});
@@ -0,0 +1,99 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
import { TERRITORIES, gameDistance, location, splitLocation } from '../game/board';
import { presenceAt } from '../game/force-presence';
import { actTruthMovementNativeEarly as act, nextTruthMovementNativeEarlyStep } from './fixture-truth-movement-native-early';
const seat = (g: Game, id: string) => { const p = g.players.find(p => p.id === id); assert.ok(p); return p; };
const clean = (g: Game) => !g.response && !g.decision && !g.phaseOpening && !g.truthtrance && !g.pendingTreacheryDiscard;
/** Start and play an actual Advanced preview through Richese's paid marker
* shipment. Only unopened Spice order and the conserved position/stance for
* this isolated CHOAM reaction are staged. */
function fixture(value: 0 | 3, source: 'advisor' | 'fighter', fighters = false) {
let g = createGame(`ADV-BG-REVEAL-${value}-${source}`, newPlayer('richese', 'Richese', 'richese'), true, ['choam']);
joinGame(g, newPlayer('choam', 'CHOAM', 'choam'));
joinGame(g, newPlayer('bg', 'Bene Gesserit', 'beneGesserit'));
for (const p of g.players) g = act(g, p.id, {type:'ready'});
g = act(g, g.host, {type:'start', advancedPreview:true});
const next = (state: Game) => {
if (state.phase === 5 && state.active === 'richese' && clean(state) && !seat(state,'richese').shipped &&
!seat(state,'richese').noField?.deployed) {
const owner = seat(state,'richese'), marker = owner.noField!.tokens.find(t => t.value === value);
assert.ok(marker && owner.noFieldEvent);
return {actor:'richese',action:{type:'ship',noField:marker.id,event:owner.noFieldEvent,
territory:'polar_sink',sector:0,allyPayment:0} satisfies Action};
}
const step = nextTruthMovementNativeEarlyStep(state);
assert.ok(step, `Missing native continuation ${state.status}/${state.turn}/${state.phase}/${state.decision?.kind}`);
if (step.action.type === 'stormDial' && state.turn === 1)
return {...step, action:{...step.action, amount:0}};
return step;
};
const reach = (until: (s: Game) => boolean) => {
for (let n = 0; n < 2400 && !until(g); n++) {
assert.notEqual(g.status, 'finished');
const step = next(g); g = act(g, step.actor, step.action);
}
assert.ok(until(g), 'The real game reached the requested boundary');
};
reach(state => state.status === 'playing');
for (let pos = 0; pos < 4; pos++) {
const at = g.spiceDeck.findIndex((card, index) => index >= pos && 'territory' in card && !card.discovery);
assert.ok(at >= pos); [g.spiceDeck[pos], g.spiceDeck[at]] = [g.spiceDeck[at], g.spiceDeck[pos]];
}
reach(state => state.turn === 2 && state.phase === 5 && state.active === 'bg' && clean(state) &&
!!seat(state,'richese').noField?.deployed);
const richese = seat(g,'richese'), marker = richese.noField!.deployed!.tokenId, event = richese.noFieldEvent;
assert.ok(event);
const bg = seat(g,'bg'), choam = seat(g,'choam');
// Return only these factions' current board counters to their reserves, then
// place one counter each at the source and one CHOAM counter at destination.
for (const player of [bg,choam]) {
player.reserves += Object.values(player.forces).reduce((sum, n) => sum + n, 0);
player.forces = {};
}
const origin = TERRITORIES.filter(t => t.type === 'sand').flatMap(t => t.sectors.map(s => location(t.id,s)))
.find(key => splitLocation(key).sector !== g.storm &&
gameDistance(g,key,'polar_sink:0',k => splitLocation(k).sector === g.storm) === 1);
assert.ok(origin);
bg.reserves--; bg.forces[origin] = 1;
choam.reserves -= 2; choam.forces[origin] = 1; choam.forces['polar_sink:0'] = 1;
bg.advisors = source === 'advisor' ? {[splitLocation(origin).territory]:{}} : {};
const beforeMove = structuredClone(g);
g = act(g,'bg',{type:'move',forces:{[origin]:1},territory:'polar_sink',sector:0,
...(fighters ? {fighters:true} : {})});
assert.equal(g.decision?.kind,'choamMovement');
assert.deepEqual(seat(g,'bg').forces,seat(beforeMove,'bg').forces);
return {game:g,beforeMove,origin,marker,event,value,source,fighters};
}
function finish(g: Game) {
for (let n = 0; n < 40 && !clean(g); n++) {
const step = nextTruthMovementNativeEarlyStep(g);
assert.ok(step); g = act(g,step.actor,step.action);
}
assert.ok(clean(g));
return g;
}
for (const value of [0,3] as const) for (const source of ['advisor','fighter'] as const)
for (const fighters of source === 'advisor' ? [false,true] : [false])
void test(`Advanced BG ${source}${fighters ? ' requesting fighters' : ''} keeps its arrival after No-Field ${value} reveal`, () => {
const f = fixture(value,source,fighters), original = structuredClone(f.game);
assert.equal(presenceAt(seat(original,'richese'),'polar_sink'),1);
assert.equal(presenceAt(seat(original,'choam'),'polar_sink'),1);
assert.equal(viewGame(original,'richese').richeseNoField?.canReveal,true);
const pending = structuredClone(original.pendingChoamMove), decision = structuredClone(original.decision);
const after = act(original,'richese',{type:'revealNoField',token:f.marker,event:f.event});
assert.deepEqual(after.pendingChoamMove,pending);
assert.deepEqual(after.decision,decision);
assert.equal(presenceAt(seat(after,'richese'),'polar_sink'),value);
const result = finish(after), control = finish(structuredClone(f.game));
assert.deepEqual(seat(result,'bg'),seat(control,'bg'));
assert.equal(seat(result,'bg').forces[f.origin] ?? 0,0);
assert.equal(seat(result,'bg').forces['polar_sink:0'],1);
assert.equal(seat(result,'bg').moved,seat(f.beforeMove,'bg').moved+1);
assert.equal(!!seat(result,'bg').advisors?.polar_sink,source === 'advisor' && !fighters);
});