Enable mixed selected-deck Discovery previews
Verify and publish checkpoint container / container (push) Failing after 11m29s

This commit is contained in:
Quintine committed 2026-10-29 20:14:11 +11:00
1 parent 26d45ecf25
commit c8dbd44975
9 files changed
+195 -11

No files matched your search

+16 -1
View File
@@ -17,7 +17,7 @@ void test('Discovery requires the selected native family and does not admit unsu
const unsupported = [
lobby(['ixians', 'guild'], []),
lobby(['richese', 'guild'], ['ix']),
lobby(['ecaz', 'ixians', 'guild'], ['ecaz', 'ix']),
lobby(['ixians', 'guild'], ['ecaz']),
lobby(['moritani', 'harkonnen', 'guild'], ['ecaz']),
];
for (const game of unsupported) assert.throws(() => initializeDiscoveryGameForAudit(game), RuleError);
@@ -35,6 +35,21 @@ void test('Discovery requires the selected native family and does not admit unsu
assert.equal(basic.discoveries?.tokens.length, 8);
});
void test('Discovery accepts mixed selected decks without requiring a native seat from each', () => {
for (const advanced of [false, true]) for (const expansions of [
['ecaz','ix'], ['ecaz','choam'], ['ecaz','ix','choam'],
]) {
const game = lobby(['ecaz','moritani','guild'], expansions, advanced);
const started = initializeDiscoveryGameForAudit(game);
assert.equal(started.discoveries?.tokens.length, 8);
assert.equal(started.nexusCards, undefined);
assert.equal(started.ecazTreachery, undefined);
assert.ok(initializeDiscoveryGameForAudit(lobby(['guild','atreides'], expansions, advanced)).discoveries);
}
assert.throws(() => initializeDiscoveryGameForAudit(
lobby(['ecaz','moritani','harkonnen'], ['ecaz','ix'], true)), RuleError);
});
void test('Discovery Tech requires three seats and untouched physical tokens', () => {
const two = lobby(['ixians', 'tleilaxu'], ['ix']); two.techTokens = createTechTokens();
assert.throws(() => initializeDiscoveryGameForAudit(two), RuleError);
+49
View File
@@ -0,0 +1,49 @@
import assert from 'node:assert/strict';
import { createGame, joinGame, newPlayer, type Action } 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;
export const advance = advanceBasicSemutaAmbassador;
/** Public mixed-family lobby and native setup. Only the unopened Spice order
* and the original Ambassador/Terror token placements are controlled; no
* resources, force positions, decision or phase are staged. */
export function mixedDiscoveryOnlyFixture(advanced: boolean, active: 'guild' | 'ixians') {
let game = createGame('MIXEDDISCOVERY', newPlayer('ecaz', 'Ecaz', 'ecaz'), advanced, ['ecaz', 'ix', 'choam']);
for (const faction of ['moritani', 'ixians', 'choam', 'guild'] as const)
joinGame(game, newPlayer(faction, faction, faction));
game = act(game, 'ecaz', {type:'moduleOption', module:'kullPreview', enabled:false});
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 = advance(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 ? card.discovery === 'discovery-hagga-basin' : !card.discovery));
assert.ok(index >= position);
[game.spiceDeck[position], game.spiceDeck[index]] = [game.spiceDeck[index], game.spiceDeck[position]];
}
game = advance(game, state => state.turn === 1 && state.phase === 5 &&
state.active === active && 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};
}
@@ -0,0 +1,82 @@
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, advance, mixedDiscoveryOnlyFixture, player } from './fixture-mixed-discovery-only';
for (const advanced of [false, true]) void test(
`${advanced ? 'Advanced' : 'Basic'} selected E3, Ix and CHOAM Discovery opens its native paired entry`, () => {
const f = mixedDiscoveryOnlyFixture(advanced, 'guild');
assert.equal(f.lobby.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);
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.ok(player(f.game, 'ixians').hand.length > 0, 'The native Ixian setup dealt its original card');
assert.ok(f.game.mobileStronghold, 'The original Ixian mobile stronghold exists');
assert.ok(player(f.game, 'choam'), 'CHOAM remains a real native faction in this configuration');
const price = reserveShipmentCost({faction:'guild', halfRate:true}, 'stronghold', 1);
const originalSpice = player(f.game, 'guild').spice;
const moritaniSpice = player(f.game, 'moritani').spice;
const stolen = Math.ceil((originalSpice - price) / 2);
const duke = structuredClone(f.game.dukeVidal!.leader);
let game = act(f.game, 'guild', f.shipment);
game = advance(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});
game = act(game, 'moritani', {type:'decision', choice:'spice'});
} else {
assert.equal(game.pendingTerrorEntry?.token, f.terror);
game = act(game, 'moritani', {type:'decision', reveal:true});
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, moritaniSpice + 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, duke);
});
for (const advanced of [false, true]) void test(
`${advanced ? 'Advanced' : 'Basic'} mixed Discovery retains an actual Ixian shipment`, () => {
const f = mixedDiscoveryOnlyFixture(advanced, 'ixians');
const before = player(f.game, 'ixians');
const spice = before.spice, reserves = before.reserves;
const eliteReserves = before.elites?.reserves ?? 0;
let game = act(f.game, 'ixians', {type:'ship', territory:'polar_sink', sector:0, amount:1,
elite:eliteReserves > 0 ? 1 : 0});
game = advance(game, state => !state.response && !state.decision && !state.phaseOpening);
assert.equal(player(game, 'ixians').reserves, reserves - 1);
assert.equal(player(game, 'ixians').spice, spice - 2);
assert.equal(player(game, 'ixians').forces['polar_sink:0'], 1);
if (eliteReserves > 0) assert.equal(player(game, 'ixians').elites!.reserves, eliteReserves - 1);
assert.ok(game.discoveries && game.mobileStronghold);
assert.ok(!game.nexusCards && !game.ecazTreachery);
});