Enable paired Ecaz and Moritani Discovery preview
Verify and publish checkpoint container / container (push) Successful in 10m37s

This commit is contained in:
Quintine committed 2026-10-29 20:05:34 +11:00
1 parent 2ad7f127ec
commit 9ca68c9ff8
11 files changed
+212 -11

No files matched your search

+30 -2
View File
@@ -13,15 +13,22 @@ function lobby(roster: FactionId[], expansions: string[], advanced = true): Game
return game;
}
void test('Discovery requires the selected native family and does not admit paired or mixed E3', () => {
void test('Discovery requires the selected native family and does not admit unsupported mixed E3', () => {
const unsupported = [
lobby(['ixians', 'guild'], []),
lobby(['richese', 'guild'], ['ix']),
lobby(['ecaz', 'moritani', 'guild'], ['ecaz']),
lobby(['ecaz', 'ixians', 'guild'], ['ecaz', 'ix']),
lobby(['moritani', 'harkonnen', 'guild'], ['ecaz']),
];
for (const game of unsupported) assert.throws(() => initializeDiscoveryGameForAudit(game), RuleError);
for (const advanced of [false, true]) {
const paired = initializeDiscoveryGameForAudit(lobby(['ecaz', 'moritani', 'guild'], ['ecaz'], advanced));
assert.equal(paired.discoveries?.tokens.length, 8);
assert.equal(paired.status, 'setup');
assert.deepEqual(paired.players.map(player => player.faction), ['ecaz', 'moritani', 'guild']);
assert.equal(paired.nexusCards, undefined);
assert.equal(paired.ecazTreachery, undefined);
}
// The Advanced Moritani/Harkonnen restriction is not a new Basic restriction.
const basic = initializeDiscoveryGameForAudit(lobby(['moritani', 'harkonnen', 'guild'], ['ecaz'], false));
assert.equal(basic.moritaniAssassinatePreview, undefined);
@@ -41,6 +48,27 @@ void test('Discovery Tech requires three seats and untouched physical tokens', (
assert.equal(initialized.discoveryEnabled, true);
});
void test('paired E3 Discovery keeps the original optional-module seat and rules limits', () => {
const factions: FactionId[] = ['ecaz', 'moritani', 'guild', 'atreides', 'emperor', 'beneGesserit'];
for (const advanced of [false, true]) for (const count of [2, 3, 6]) {
const game = lobby(factions.slice(0, count), ['ecaz'], advanced);
if (count >= 3) game.techTokens = createTechTokens();
if (advanced) game.strongholdCards = createStrongholdCards();
const started = initializeDiscoveryGameForAudit(game);
assert.equal(started.discoveries?.tokens.length, 8);
assert.equal(!!started.techTokens, count >= 3);
assert.equal(!!started.strongholdCards, advanced);
}
const twoWithTech = lobby(factions.slice(0, 2), ['ecaz']);
twoWithTech.techTokens = createTechTokens();
assert.throws(() => initializeDiscoveryGameForAudit(twoWithTech), RuleError);
const basicStrongholds = lobby(factions.slice(0, 3), ['ecaz'], false);
basicStrongholds.strongholdCards = createStrongholdCards();
assert.throws(() => initializeDiscoveryGameForAudit(basicStrongholds), RuleError);
assert.throws(() => initializeDiscoveryGameForAudit(lobby(['ecaz','moritani','harkonnen'], ['ecaz'], true)), RuleError);
assert.ok(initializeDiscoveryGameForAudit(lobby(['ecaz','moritani','harkonnen'], ['ecaz'], false)).discoveries);
});
void test('Discovery cannot redeal started components or silently remove another module', () => {
const initial = lobby(['ixians', 'tleilaxu', 'guild'], ['ix']);
const started = initializeDiscoveryGameForAudit(initial);
@@ -72,6 +72,9 @@ export function nextDiscoveryNativeE1SkillsStep(game: Game): DiscoveryNativeE1Sk
}
if (d?.kind === 'battleLosses') return { actor: d.player, action: { type: 'decision',
choice: d.options.findIndex(o => o.elite === Math.max(...d.options.map(c => c.elite))) } };
if (game.status === 'playing' && game.phase === 2 && game.charityOrder?.remaining[0] &&
!game.phaseOpening && !game.response && !game.decision && !game.pendingTreacheryDiscard)
return { actor: game.charityOrder.remaining[0], action: { type: 'ready' } };
return nextSkillsTechBattleStep(game);
}
export function stepDiscoveryNativeE1Skills(game: Game, step = nextDiscoveryNativeE1SkillsStep(game)): Game {
+4 -1
View File
@@ -19,7 +19,10 @@ export function nativeTypedPlayer(game: Game, id: string): Player {
return player;
}
export function nativeTypedStep(game: Game): Game {
const next = game.decision?.kind === 'discoveryEntry'
const next = game.status === 'playing' && game.phase === 2 && game.charityOrder?.remaining[0] &&
!game.phaseOpening && !game.response && !game.decision && !game.pendingTreacheryDiscard
? { actor: game.charityOrder.remaining[0], action: { type: 'ready' } }
: game.decision?.kind === 'discoveryEntry'
? { actor: game.decision.player, action: { type: 'decision', accept: false, event: game.decision.event } }
: game.decision?.kind === 'ixSubstitution'
? { actor: game.decision.player, action: { type: 'decision', decline: true } }
+52
View File
@@ -0,0 +1,52 @@
import assert from 'node:assert/strict';
import { createGame, joinGame, newPlayer, type Action, type Game } from '../game/engine';
import { placeAmbassador } from '../game/ecaz-ambassadors';
import { placeTerror } from '../game/moritani-terror';
import { actBasicSemutaAmbassador, advanceBasicSemutaAmbassador,
basicSemutaAmbassadorClean, basicSemutaAmbassadorPlayer } from './fixture-basic-semuta-ambassador';
export const act = actBasicSemutaAmbassador;
export const player = basicSemutaAmbassadorPlayer;
/** Fresh public lobby/setup and real turn-one Guild shipment. Existing Ecaz and
* Moritani tokens are selected and placed at the clean movement boundary by
* their native helpers. The first unopened ordinary or Discovery Spice cards are selected;
* no player force, purse, order, pending reaction or receipt is staged. */
export function pairedE3DiscoveryOnlyFixture(advanced: boolean, discoveryBlow = false) {
let game = createGame('PAIREDE3DISCOVERY', newPlayer('ecaz', 'Ecaz', 'ecaz'), advanced, ['ecaz']);
for (const faction of ['moritani', 'atreides', 'guild'] as const)
joinGame(game, newPlayer(faction, faction, faction));
game = act(game, 'ecaz', {type:'moduleOption', module:'discoveries', enabled:true});
for (const seat of game.players) game = act(game, seat.id, {type:'ready'});
const lobby = structuredClone(game);
game = act(game, 'ecaz', {type:'start', ...(advanced ? {advancedPreview:true} : {})});
const setup = structuredClone(game);
game = advanceBasicSemutaAmbassador(game, state => state.status === 'playing');
assert.equal(game.advanced, advanced);
assert.ok(game.discoveries && game.ecazAmbassadors && game.moritaniTerror);
assert.ok(!game.nexusCards && !game.ecazTreachery && !game.leaderSkills);
for (const position of advanced ? [0,1] : [0]) {
const index = game.spiceDeck.findIndex((card, i) => i >= position && 'territory' in card &&
(position === 0 && discoveryBlow ? card.discovery === 'discovery-hagga-basin' : !card.discovery));
assert.ok(index >= position);
[game.spiceDeck[position], game.spiceDeck[index]] = [game.spiceDeck[index], game.spiceDeck[position]];
}
game = advanceBasicSemutaAmbassador(game, state => state.turn === 1 && state.phase === 5 &&
state.active === 'guild' && basicSemutaAmbassadorClean(state));
const beforeMarkers = structuredClone(game);
const token = game.ecazAmbassadors!.tokens.find(row => row.effect === 'ecaz' && row.zone === 'supply');
const terror = game.moritaniTerror!.tokens.find(row => row.kind === 'robbery' && row.status === 'available');
assert.ok(token && terror);
const destination = 'habbanya_ridge_sietch', sector = 17;
game.ecazAmbassadors = placeAmbassador(game.ecazAmbassadors!, token.id, {
turn:game.turn, availableSpice:player(game,'ecaz').spice,
destination:{id:destination,stronghold:true,inStorm:false,allowed:true},
}).state;
game.moritaniTerror = placeTerror(game.moritaniTerror!, terror.id, destination, game.turn);
const shipment: Action = {type:'ship', territory:destination, sector, amount:1, elite:0, allyPayment:0};
return {game, lobby, setup, beforeMarkers, destination, sector, token:token.id, terror:terror.id, shipment};
}
export function reachPairedE3Entry(state: Game, until: (game: Game) => boolean): Game {
return advanceBasicSemutaAmbassador(state, until);
}
@@ -0,0 +1,72 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { viewGame } from '../game/engine';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { reserveShipmentCost } from '../game/shipment-price';
import { act, pairedE3DiscoveryOnlyFixture, player, reachPairedE3Entry } from './fixture-paired-e3-discovery-only';
for (const advanced of [false, true]) void test(
`${advanced ? 'Advanced' : 'Basic'} paired Ecaz/Moritani Discovery-only public setup preserves the original entry`, () => {
const f = pairedE3DiscoveryOnlyFixture(advanced);
assert.equal(f.lobby.discoveryEnabled, true);
assert.equal(f.setup.discoveryEnabled, true);
assert.ok(f.setup.discoveries);
assert.equal(f.setup.discoveries!.tokens.length, 8);
assert.equal(f.setup.spiceDeck.filter(card => 'discovery' in card && card.discovery).length, 6);
assert.ok(!f.setup.nexusCards && !f.setup.ecazTreachery);
const price = reserveShipmentCost({faction:'guild', halfRate:true}, 'stronghold', 1);
const originalSpice = player(f.game, 'guild').spice;
const originalMoritaniSpice = player(f.game, 'moritani').spice;
const stolen = Math.ceil((originalSpice - price) / 2);
const originalDuke = structuredClone(f.game.dukeVidal!.leader);
let game = act(f.game, 'guild', f.shipment);
game = reachPairedE3Entry(game, state => !!state.pendingArrivalOverlap);
assert.equal(player(game, 'guild').spice, originalSpice - price);
assert.equal(player(game, 'guild').forces[`${f.destination}:${f.sector}`], 1);
const first = game.pendingArrivalOverlap!.first;
const responder = first === 'ambassador' ? 'ecaz' : 'moritani';
for (const difficulty of DIFFICULTIES) {
const view = viewGame(game, responder);
view.players.find(row => row.id === responder)!.bot = difficulty;
const choice = botActions(view)[0]; assert.ok(choice, difficulty);
assert.doesNotThrow(() => act(game, responder, choice), difficulty);
}
if (first === 'ambassador') {
const entry = game.pendingAmbassador; assert.ok(entry);
assert.equal(entry.token, f.token);
game = act(game, 'ecaz', {type:'decision', event:entry.event, trigger:true, beneficiary:'ecaz', choice:'duke'});
assert.equal(game.pendingTerrorEntry?.token, f.terror);
game = act(game, 'moritani', {type:'decision', reveal:true});
assert.equal(game.pendingTerrorEntry?.stage, 'robbery');
game = act(game, 'moritani', {type:'decision', choice:'spice'});
} else {
assert.equal(game.pendingTerrorEntry?.token, f.terror);
game = act(game, 'moritani', {type:'decision', reveal:true});
assert.equal(game.pendingTerrorEntry?.stage, 'robbery');
game = act(game, 'moritani', {type:'decision', choice:'spice'});
const entry = game.pendingAmbassador; assert.ok(entry);
assert.equal(entry.token, f.token);
game = act(game, 'ecaz', {type:'decision', event:entry.event, trigger:true, beneficiary:'ecaz', choice:'duke'});
}
assert.equal(game.pendingArrivalOverlap ?? null, null);
assert.equal(game.pendingAmbassador ?? null, null);
assert.equal(game.pendingTerrorEntry ?? null, null);
assert.equal(player(game, 'guild').spice, originalSpice - price - stolen);
assert.equal(player(game, 'moritani').spice, originalMoritaniSpice + stolen);
assert.equal(player(game, 'guild').forces[`${f.destination}:${f.sector}`], 1);
assert.equal(game.moritaniTerror!.tokens.find(row => row.id === f.terror)?.status, 'removed');
assert.equal(game.ecazAmbassadors!.tokens.find(row => row.id === f.token)?.zone, 'supply');
assert.deepEqual([game.dukeVidal?.controller, game.dukeVidal?.source], ['ecaz', 'ecaz']);
assert.deepEqual(game.dukeVidal?.leader, originalDuke);
});
for (const advanced of [false, true]) void test(
`${advanced ? 'Advanced' : 'Basic'} paired Discovery-only table resolves a real Discovery Spice Blow`, () => {
const f = pairedE3DiscoveryOnlyFixture(advanced, true);
assert.ok(f.beforeMarkers.spiceDiscard.flat().some(card =>
'territory' in card && card.discovery === 'discovery-hagga-basin'));
assert.equal(f.beforeMarkers.discoveries!.tokens.filter(token => token.status === 'placed').length, 1);
assert.equal(f.beforeMarkers.phase, 5);
assert.ok(!f.beforeMarkers.nexusCards && !f.beforeMarkers.ecazTreachery);
});