Files
Dune/tests/selected-discovery-skills-overlap-fixture.ts
T
Quintine 77eb2392eb
Verify and publish checkpoint container / container (push) Canceled after 0s
Support mixed Discovery decks with Leader Skills
2026-10-30 17:49:26 +11:00

62 lines
3.8 KiB
TypeScript

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 as act, basicSemutaAmbassadorClean as clean,
basicSemutaAmbassadorPlayer as player, nextBasicSemutaAmbassadorStep } from './fixture-basic-semuta-ambassador';
import { nextPairedChoamSkillsStep } from './fixture-paired-choam-nexus-skills';
export { act, clean, player };
/** Real public mixed-family setup and skills training. Only unopened Spice
* order and original Ambassador/Terror placements are controlled. */
export function selectedDiscoverySkillsOverlapFixture(advanced: boolean) {
let game = createGame('DISCOVERYSKILLSOVERLAP', 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});
game = act(game, 'ecaz', {type:'moduleOption', module:'leaderSkills', 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);
const advance = (initial: Game, until: (state: Game) => boolean) => {
let state = initial;
for (let count = 0; count < 1800; count++) {
if (until(state)) return state;
assert.notEqual(state.status, 'finished');
const step = state.status === 'setup' && state.setupStage === 'leaderSkills'
? nextPairedChoamSkillsStep(state) : nextBasicSemutaAmbassadorStep(state);
assert.ok(step, `No original continuation at ${state.status}/${state.phase}/${state.decision?.kind}`);
state = act(state, step.actor, step.action);
}
throw Error('The mixed Discovery/Skills game did not reach its requested boundary');
};
game = advance(game, state => state.status === 'playing');
assert.equal(game.leaderSkills?.assignments.length, game.players.length);
assert.ok(game.discoveries && game.ecazAmbassadors && game.moritaniTerror);
assert.ok(!game.nexusCards && !game.ecazTreachery);
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 === 'guild' && clean(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, advance};
}