Connect Semuta in Discovery and Skills games
Verify and publish checkpoint container / container (push) Successful in 11m5s
Verify and publish checkpoint container / container (push) Successful in 11m5s
This commit is contained in:
1 parent
77eb2392eb
commit
528b152f7d
14 files changed
+481
-15
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { TERRITORIES } from '../game/board';
|
||||
import { botGroundMoveAllowed, groundMoveRouteDistance } from '../game/bot-mobility';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { basicSemutaAmbassadorInventory as inventory } from './fixture-basic-semuta-ambassador';
|
||||
import { advanceSelectedIndependentNexus } from './fixture-selected-independent-nexus-cards';
|
||||
import { selectedDiscoverySkillsStart, advanceDiscoverySkillsBlow } from './selected-discovery-skills-fixture';
|
||||
|
||||
function player(game: Game, id: string) {
|
||||
const seat = game.players.find(row => row.id === id); assert.ok(seat); return seat;
|
||||
}
|
||||
const clean = (g: Game) => !g.phaseOpening && !g.response && !g.decision &&
|
||||
!g.truthtrance && !g.pendingTreacheryDiscard;
|
||||
|
||||
/** Public mixed selected-deck start with real training, Discovery blow and
|
||||
* Movement. Only unopened Spice order and conserved card custody are staged. */
|
||||
function fixture(advanced: boolean) {
|
||||
const started = selectedDiscoverySkillsStart({advanced,
|
||||
factions:['richese', 'ecaz', 'ixians', 'atreides']});
|
||||
assert.equal(started.setup.semutaPreview, true);
|
||||
assert.ok(started.game.leaderSkills && started.game.discoveries);
|
||||
let game = advanceDiscoverySkillsBlow(started.game, started.actions);
|
||||
game = advanceSelectedIndependentNexus(game,
|
||||
state => state.phase === 5 && state.active === 'atreides' && clean(state), started.actions);
|
||||
const beforeInventory = inventory(game);
|
||||
const give = (id: string, match: (card: Game['deck'][number]) => boolean) => {
|
||||
const target = player(game, id);
|
||||
const zones = [game.deck, game.discard, game.richeseCache!, ...game.players.map(row => row.hand)];
|
||||
const source = zones.find(zone => zone.some(match)); assert.ok(source);
|
||||
const [card] = source.splice(source.findIndex(match), 1);
|
||||
if (target.hand.length >= 4) source.push(target.hand.pop()!);
|
||||
target.hand.push(card);
|
||||
return card.id;
|
||||
};
|
||||
give('richese', card => card.id === SEMUTA_DRUG_ID);
|
||||
const hajr = give('atreides', card => card.effect === 'hajr');
|
||||
assert.deepEqual(inventory(game), beforeInventory);
|
||||
if (advanced) {
|
||||
// The Advanced face requires an actual shipment followed by movement.
|
||||
game = applyAction(game, 'atreides', {type:'ship', territory:'polar_sink', sector:0,
|
||||
amount:1, elite:0, allyPayment:0});
|
||||
game = advanceSelectedIndependentNexus(game,
|
||||
state => state.phase === 5 && state.active === 'atreides' && clean(state), started.actions);
|
||||
const own = viewGame(game, 'atreides'), seat = own.players.find(row => row.id === 'atreides'); assert.ok(seat);
|
||||
const from = 'polar_sink:0';
|
||||
const destination = TERRITORIES.filter(place => place.type === 'sand' &&
|
||||
!game.players.some(row => Object.keys(row.forces).some(key => key.startsWith(`${place.id}:`))) &&
|
||||
!Object.keys(game.spice).some(key => key.startsWith(`${place.id}:`) && game.spice[key] > 0))
|
||||
.flatMap(place => place.sectors.map(sector => ({territory:place.id, sector})))
|
||||
.find(place => groundMoveRouteDistance(own, seat, from, `${place.territory}:${place.sector}`) === 1 &&
|
||||
botGroundMoveAllowed(own, seat, from, `${place.territory}:${place.sector}`, 0));
|
||||
assert.ok(destination);
|
||||
game = applyAction(game, 'atreides', {type:'move', from, ...destination, amount:1, elite:0});
|
||||
game = advanceSelectedIndependentNexus(game,
|
||||
state => state.phase === 5 && state.active === 'atreides' && clean(state), started.actions);
|
||||
assert.equal(player(game, 'atreides').hajrWindow?.turn, game.turn);
|
||||
}
|
||||
return {game, hajr, beforeInventory};
|
||||
}
|
||||
|
||||
for (const advanced of [false, true]) void test(
|
||||
`${advanced ? 'Advanced' : 'Basic'} mixed Discovery Skills supports an original Hajr Semuta claim or pass`, () => {
|
||||
const f = fixture(advanced);
|
||||
const prior = structuredClone(f.game);
|
||||
const pending = applyAction(prior, 'atreides', {type:'card', card:f.hajr});
|
||||
assert.equal(pending.pendingTreacheryDiscard?.batch.cause, 'ordinary:hajr');
|
||||
assert.equal(pending.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
const event = pending.pendingTreacheryDiscard!.batch.event;
|
||||
const ownerView = viewGame(pending, 'richese');
|
||||
assert.equal(ownerView.semutaReaction?.canCommit, true);
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(pending, 'richese');
|
||||
view.players.find(row => row.id === 'richese')!.bot = difficulty;
|
||||
const action = botActions(view).find(row => row.type === 'semutaCommit' || row.type === 'semutaPass');
|
||||
assert.ok(action, difficulty);
|
||||
assert.doesNotThrow(() => applyAction(pending, 'richese', action), difficulty);
|
||||
}
|
||||
for (const claim of [false, true]) {
|
||||
let next = structuredClone(pending);
|
||||
if (claim) next = applyAction(next, 'richese', {type:'semutaCommit', event});
|
||||
else for (const seat of next.players) next = applyAction(next, seat.id, {type:'semutaPass', event});
|
||||
if (next.pendingTreacheryDiscard?.reaction?.stage === 'select')
|
||||
next = applyAction(next, 'richese', {type:'semutaSelect', event, card:f.hajr});
|
||||
assert.equal(next.pendingTreacheryDiscard, null);
|
||||
assert.equal(next.active, 'atreides');
|
||||
assert.ok(next.hajr.includes('atreides'));
|
||||
assert.equal(player(next, 'richese').hand.some(card => card.id === f.hajr), claim);
|
||||
assert.equal(next.discard.some(card => card.id === SEMUTA_DRUG_ID), claim);
|
||||
assert.deepEqual(inventory(next), f.beforeInventory);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
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';
|
||||
import { nextRicheseStrongholdsNativeStep } from './fixture-richese-strongholds';
|
||||
|
||||
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 semutaDiscoverySkillsOverlapFixture(advanced: boolean) {
|
||||
let game = createGame('SEMUTADISCOVERYSKILLSOVERLAP', newPlayer('ecaz', 'Ecaz', 'ecaz'), advanced,
|
||||
['ecaz', 'ix', 'choam']);
|
||||
for (const faction of ['moritani', 'ixians', 'richese', 'guild'] as const)
|
||||
joinGame(game, newPlayer(faction, faction, faction));
|
||||
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) : !state.response && !state.phaseOpening &&
|
||||
state.decision?.kind === 'richeseCache'
|
||||
? nextRicheseStrongholdsNativeStep(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.equal(game.semutaPreview, true);
|
||||
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};
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 { act, player, semutaDiscoverySkillsOverlapFixture } from './semuta-discovery-skills-overlap-fixture';
|
||||
|
||||
for (const advanced of [false, true]) void test(
|
||||
`${advanced ? 'Advanced' : 'Basic'} mixed Semuta, Discovery and Skills retain the original Ecaz/Moritani arrival`, () => {
|
||||
const f = semutaDiscoverySkillsOverlapFixture(advanced);
|
||||
assert.equal(f.lobby.discoveryEnabled, true);
|
||||
assert.ok(f.setup.discoveries && f.setup.leaderSkills && f.setup.semutaPreview);
|
||||
assert.equal(f.game.leaderSkills!.assignments.length, f.game.players.length);
|
||||
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(!f.game.nexusCards && !f.game.ecazTreachery);
|
||||
assert.equal(f.game.semutaPreview, true);
|
||||
const moritaniSpice = player(f.game, 'moritani').spice;
|
||||
const duke = structuredClone(f.game.dukeVidal!.leader);
|
||||
let game = act(f.game, 'guild', f.shipment);
|
||||
game = f.advance(game, state => !!state.pendingArrivalOverlap);
|
||||
const afterShipment = player(game, 'guild').spice;
|
||||
const stolen = Math.ceil(afterShipment / 2);
|
||||
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);
|
||||
}
|
||||
const 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'});
|
||||
};
|
||||
const robbery = () => {
|
||||
assert.equal(game.pendingTerrorEntry?.token, f.terror);
|
||||
game = act(game, 'moritani', {type:'decision', reveal:true});
|
||||
game = act(game, 'moritani', {type:'decision', choice:'spice'});
|
||||
};
|
||||
if (first === 'ambassador') { ambassador(); robbery(); }
|
||||
else { robbery(); ambassador(); }
|
||||
assert.equal(game.pendingArrivalOverlap ?? null, null);
|
||||
assert.equal(game.pendingAmbassador ?? null, null);
|
||||
assert.equal(game.pendingTerrorEntry ?? null, null);
|
||||
assert.equal(player(game, 'guild').spice, afterShipment - 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);
|
||||
assert.equal(game.leaderSkills!.assignments.length, game.players.length);
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,106 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { DISCOVERY_CARD_PLACEMENTS, validateDiscoveryState } from '../game/discoveries';
|
||||
import { discoveryStormActions } from '../game/discovery-storm-options';
|
||||
import { validateLeaderSkills } from '../game/leader-skills';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { selectedDiscoverySkillsStart } from './selected-discovery-skills-fixture';
|
||||
import { advanceTestingStationContest } from './fixture-testing-station-contest';
|
||||
import { moveSemutaEmperorCard } from './fixture-semuta-emperor-share';
|
||||
import { reactSemutaSpecial } from './fixture-semuta-special-karama';
|
||||
|
||||
const SAPHO = 'richese-juice-of-sapho';
|
||||
const STATION = 'ecological-testing-station';
|
||||
const cards = (game: Game) => [...game.deck, ...game.discard, ...(game.richeseCache ?? []),
|
||||
...(game.richeseRemoved ?? []), ...game.players.flatMap(player => player.hand)].map(card => card.id).sort();
|
||||
function player(game: Game, id: string) {
|
||||
const seat = game.players.find(candidate => candidate.id === id);
|
||||
assert.ok(seat); return seat;
|
||||
}
|
||||
|
||||
/** Public lobby, original native setup and all14 training. The rare revealed
|
||||
* Station, physical occupants and the two singleton cards are staged by
|
||||
* conserved transfers; the ordinary first Storm opens the real priority. */
|
||||
function fixture(advanced: boolean, mixed: boolean) {
|
||||
const started = selectedDiscoverySkillsStart({advanced,
|
||||
factions: mixed ? ['richese', 'ixians', 'atreides', 'emperor'] : ['richese', 'atreides', 'emperor'],
|
||||
expansions: mixed ? ['choam', 'ix', 'ecaz'] : ['choam']});
|
||||
let game = started.game;
|
||||
assert.equal(game.semutaPreview, true, 'The public Discovery/Skills start must enable the connected Semuta reaction');
|
||||
assert.equal(game.leaderSkills!.assignments.length, game.players.length);
|
||||
validateLeaderSkills(game.leaderSkills!, game.players);
|
||||
assert.ok(!game.nexusCards && !game.ecazTreachery);
|
||||
const inventory = cards(game);
|
||||
for (const seat of game.players) game.deck.push(...seat.hand.splice(0));
|
||||
const token = game.discoveries!.tokens.find(candidate => candidate.face === STATION);
|
||||
assert.ok(token && token.status === 'supply');
|
||||
const position = Object.values(DISCOVERY_CARD_PLACEMENTS).find(candidate => candidate.type === token.type);
|
||||
assert.ok(position);
|
||||
Object.assign(token, {status:'placed', territory:position.territory, sector:position.sector, revealedTurn:game.turn});
|
||||
validateDiscoveryState(game.discoveries!);
|
||||
for (const id of ['atreides', 'emperor']) {
|
||||
const seat = player(game, id); assert.ok(seat.reserves > 0);
|
||||
seat.reserves--; seat.forces[`${STATION}:0`] = (seat.forces[`${STATION}:0`] ?? 0) + 1;
|
||||
}
|
||||
moveSemutaEmperorCard(game, SEMUTA_DRUG_ID, 'richese');
|
||||
game = advanceTestingStationContest(game, state => !!state.saphoStationPriority &&
|
||||
state.decision?.kind === 'ecologicalStorm');
|
||||
const order = game.ecologicalStorm!.queue!.order;
|
||||
assert.equal(order.length, 2);
|
||||
const holder = order[1];
|
||||
moveSemutaEmperorCard(game, SAPHO, holder);
|
||||
assert.deepEqual(cards(game), inventory);
|
||||
return {game, holder, first:order[0], order:[...order], inventory};
|
||||
}
|
||||
|
||||
for (const advanced of [false, true]) for (const mixed of [false, true])
|
||||
for (const claim of [false, true]) void test(
|
||||
`${advanced ? 'Advanced' : 'Basic'} ${mixed ? 'mixed' : 'CHOAM'} Discovery/Skills restores Station after Semuta ${claim ? 'claim' : 'pass'}`, () => {
|
||||
const f = fixture(advanced, mixed);
|
||||
let game = f.game;
|
||||
const priority = game.saphoStationPriority!;
|
||||
game = applyAction(game, f.first, {type:'saphoStationPass', event:priority.event});
|
||||
const option = viewGame(game, f.holder).saphoOptions.find(row => row.scope === 'testingStation' && row.mode === 'first');
|
||||
assert.ok(option);
|
||||
game = applyAction(game, f.holder, {type:'card', card:SAPHO, scope:option.scope, event:option.event, mode:option.mode});
|
||||
assert.ok(!game.saphoStationPriority);
|
||||
assert.equal(game.pendingTreacheryDiscard?.batch.cause, 'sapho:station');
|
||||
assert.equal(game.pendingTreacheryDiscard?.continuation.kind, 'saphoStationDiscard');
|
||||
assert.deepEqual(game.ecologicalStorm?.queue?.order, [...f.order].reverse());
|
||||
assert.equal(game.ecologicalStorm?.queue?.choices.length, 0);
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(game, 'richese');
|
||||
view.players.find(seat => seat.id === 'richese')!.bot = difficulty;
|
||||
const action = botActions(view).find(row => row.type === 'semutaCommit' || row.type === 'semutaPass');
|
||||
assert.ok(action, difficulty);
|
||||
assert.doesNotThrow(() => applyAction(game, 'richese', action));
|
||||
}
|
||||
game = reactSemutaSpecial(game, 'richese', claim);
|
||||
assert.equal(game.pendingTreacheryDiscard, null);
|
||||
assert.equal(game.decision?.kind, 'ecologicalStorm');
|
||||
assert.equal(game.decision?.player, f.holder);
|
||||
assert.equal(player(game, 'richese').hand.some(card => card.id === SAPHO), claim);
|
||||
assert.equal(player(game, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const owner = game.ecologicalStorm!.owner;
|
||||
const action = discoveryStormActions(viewGame(game, owner)).find(choice => choice.delta === 0);
|
||||
assert.ok(action);
|
||||
game = applyAction(game, owner, action);
|
||||
}
|
||||
assert.equal(game.ecologicalStorm?.stage, 'complete');
|
||||
assert.equal(game.ecologicalStorm.queue?.choices.length, 2);
|
||||
if (mixed) {
|
||||
// A real first Storm with Ixians must place the HMS before Spice Blow.
|
||||
const decision = game.decision;
|
||||
assert.ok(decision?.kind === 'mobileStronghold' && decision.placement);
|
||||
game = applyAction(game, decision.player, {type:'decision', location:'polar_sink:0'});
|
||||
assert.equal(game.mobileStronghold?.location, 'polar_sink:0');
|
||||
}
|
||||
assert.equal(game.phase, 1);
|
||||
assert.deepEqual(cards(game), f.inventory);
|
||||
validateLeaderSkills(game.leaderSkills!, game.players);
|
||||
validateDiscoveryState(game.discoveries!);
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { applyAction, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { semutaSkillsInventory } from './fixture-semuta-skills';
|
||||
import { finishOriginalTruthQuestions, finishTruthOrder } from './fixture-sapho-truth-order';
|
||||
import { selectedDiscoverySkillsStart, advanceDiscoverySkillsBlow } from './selected-discovery-skills-fixture';
|
||||
|
||||
const SAPHO = 'richese-juice-of-sapho';
|
||||
const seat = (game: Game, id: string) => {
|
||||
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
|
||||
};
|
||||
|
||||
/** Real public mixed-deck setup, training and Discovery blow. Reorder only
|
||||
* unopened Spice Cards and conserve every physical Treachery Card while
|
||||
* staging the two simultaneous question holders and Sapho/Semuta custody. */
|
||||
function fixture(advanced: boolean) {
|
||||
const started = selectedDiscoverySkillsStart({advanced,
|
||||
factions:['richese', 'ecaz', 'atreides', 'emperor']});
|
||||
assert.equal(started.setup.semutaPreview, true);
|
||||
assert.ok(started.game.leaderSkills && started.game.discoveries);
|
||||
let game = advanceDiscoverySkillsBlow(started.game, started.actions);
|
||||
const inventory = semutaSkillsInventory(game);
|
||||
for (const player of game.players) game.deck.push(...player.hand.splice(0));
|
||||
const give = (id: string, identity: string) => {
|
||||
const zones = [game.deck, game.discard, game.richeseCache!, ...game.players.map(row => row.hand)];
|
||||
const source = zones.find(zone => zone.some(card => card.id === identity || card.effect === identity));
|
||||
assert.ok(source, `Missing original ${identity}`);
|
||||
const [card] = source.splice(source.findIndex(row => row.id === identity || row.effect === identity), 1);
|
||||
seat(game, id).hand.push(card);
|
||||
return card.id;
|
||||
};
|
||||
const ordered = game.order.filter(id => id === 'atreides' || id === 'emperor');
|
||||
assert.equal(ordered.length, 2);
|
||||
const [other, holder] = ordered;
|
||||
give('richese', SEMUTA_DRUG_ID);
|
||||
give(holder, SAPHO);
|
||||
const truth = give(holder, 'truthtrance'), otherTruth = give(other, 'truthtrance');
|
||||
assert.deepEqual(semutaSkillsInventory(game), inventory);
|
||||
const parent = {turn:game.turn, phase:game.phase, active:game.active,
|
||||
order:[...game.order], movementRemaining:structuredClone(game.movementRemaining)};
|
||||
for (const [id, card] of [[holder, truth], [other, otherTruth]])
|
||||
game = applyAction(game, id, {type:'card', card});
|
||||
while (game.truthtrance?.stage === 'priority') {
|
||||
const actor = game.players.find(row => !game.truthtrance!.passed.includes(row.id)); assert.ok(actor);
|
||||
game = applyAction(game, actor.id, {type:'truthPass'});
|
||||
}
|
||||
assert.equal(game.truthtrance?.stage, 'order');
|
||||
return {game, holder, parent, inventory};
|
||||
}
|
||||
|
||||
for (const advanced of [false, true]) void test(
|
||||
`${advanced ? 'Advanced' : 'Basic'} mixed Discovery Skills preserves Sapho Truth-order through Semuta`, () => {
|
||||
const f = fixture(advanced), frame = f.game.truthtrance!.order!;
|
||||
assert.ok(viewGame(f.game, f.holder).saphoTruthOrderChoices.some(choice => choice.card === SAPHO && choice.mode === 'first'));
|
||||
const pending = applyAction(f.game, f.holder, {type:'saphoTruthOrder', event:frame.event,
|
||||
revision:frame.revision, card:SAPHO, mode:'first'});
|
||||
assert.equal(pending.pendingTreacheryDiscard?.continuation.kind, 'saphoTruthOrderDiscard');
|
||||
assert.equal(pending.pendingTreacheryDiscard?.reaction?.stage, 'offer');
|
||||
assert.equal(pending.truthtrance, null);
|
||||
const event = pending.pendingTreacheryDiscard!.batch.event;
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(pending, 'richese');
|
||||
view.players.find(row => row.id === 'richese')!.bot = difficulty;
|
||||
const action = botActions(view).find(row => row.type === 'semutaCommit' || row.type === 'semutaPass');
|
||||
assert.ok(action, difficulty);
|
||||
assert.doesNotThrow(() => applyAction(pending, 'richese', action), difficulty);
|
||||
}
|
||||
for (const claim of [false, true]) {
|
||||
let game = structuredClone(pending);
|
||||
if (claim) game = applyAction(game, 'richese', {type:'semutaCommit', event});
|
||||
else for (const player of game.players) game = applyAction(game, player.id, {type:'semutaPass', event});
|
||||
if (game.pendingTreacheryDiscard?.reaction?.stage === 'select')
|
||||
game = applyAction(game, 'richese', {type:'semutaSelect', event, card:SAPHO});
|
||||
assert.equal(game.pendingTreacheryDiscard, null);
|
||||
assert.equal(seat(game, 'richese').hand.some(card => card.id === SAPHO), claim);
|
||||
assert.equal(seat(game, 'richese').hand.some(card => card.id === SEMUTA_DRUG_ID), !claim);
|
||||
game = finishTruthOrder(game);
|
||||
assert.equal(game.truthtrance!.queue[0].player, f.holder);
|
||||
assert.deepEqual(game.order, f.parent.order);
|
||||
assert.equal(game.turn, f.parent.turn); assert.equal(game.phase, f.parent.phase);
|
||||
assert.equal(game.active, f.parent.active);
|
||||
assert.deepEqual(game.movementRemaining, f.parent.movementRemaining);
|
||||
game = finishOriginalTruthQuestions(game);
|
||||
assert.equal(game.truthtrance, null);
|
||||
assert.deepEqual(semutaSkillsInventory(game), f.inventory);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user