Connect Nexus Skills and Advanced Ambassador markers
Verify and publish checkpoint container / container (push) Successful in 10m45s

This commit is contained in:
Quintine committed 2026-11-16 16:23:53 +11:00
1 parent 2660b10af0
commit 4270b36be7
14 files changed
+578 -41

No files matched your search

+12
View File
@@ -46,6 +46,12 @@ export type NexusModulePaymentsFixture = {
/** Use the existing original continuation policy, never a fixture phase jump. */
export function nextNexusModulePaymentsNativeStep(game: Game): NexusModulePaymentStep | null {
if (game.phase === 2 && game.charityOrder && !game.phaseOpening && !game.response &&
!game.decision && !game.truthtrance && !game.pendingTreacheryDiscard) {
const actor = game.charityOrder.remaining[0];
assert.ok(actor, 'An open ordered Charity needs its current actor.');
return { actor, action: { type: 'ready' } };
}
if (game.nexusCards?.phase?.stage === 'drawing' && !game.response && !game.decision) {
const phase = game.nexusCards.phase;
const actor = phase.eligible.find(id => !phase.done.includes(id));
@@ -236,6 +242,12 @@ export function createNexusModulePaymentsFixture(options: NexusModulePaymentsOpt
const event = kind === 'guild-shipment' ? view.nexusGuildSecretAlly!.event : view.nexusRichese!.event;
paymentAction = { type: 'ship', ...target, amount, nexus: event };
} else {
// Advanced Revival belongs to each seat in order. Finish preceding
// opportunities through their real controls before staging casualties.
for (let n = 0; game.revivalOrder && game.revivalOrder.remaining[0] !== actor && n < 30; n++)
game = step(game, actions);
assert.equal(game.phase, 4);
assert.ok(!game.revivalOrder || game.revivalOrder.remaining[0] === actor);
const player = game.players.find(p => p.id === actor)!;
const tanks = options.tanks ?? 6, elite = options.eliteTanks ?? 0;
assert.ok(tanks <= player.reserves && elite <= (player.elites?.reserves ?? 0));
+10 -15
View File
@@ -76,22 +76,14 @@ export function nexusRicheseFixture(
'RICHESENEXUS',
newPlayer(owner, ownerFaction, ownerFaction),
options.advanced ?? false,
ownerFaction === 'ixians' || opponentFaction === 'ixians'
? ['ix']
: ownerFaction === 'richese' ? ['choam'] : [],
[
...(ownerFaction === 'ixians' || opponentFaction === 'ixians' ? ['ix' as const] : []),
...(ownerFaction === 'richese' ? ['choam' as const] : []),
...(opponentFaction === 'moritani' ? ['ecaz' as const] : []),
],
);
// The unfinished E3 public deck gate is separate from native Moritani audit
// setup. Fix the final faction before readiness and genuine initialization.
joinGame(
g,
newPlayer(
target,
opponentFaction,
opponentFaction === 'moritani' ? 'harkonnen' : opponentFaction,
),
);
if (opponentFaction === 'moritani')
g.players[1] = newPlayer(target, opponentFaction, opponentFaction);
// The selected roster and physical decks precede readiness and native setup.
joinGame(g, newPlayer(target, opponentFaction, opponentFaction));
joinGame(g, newPlayer(observer, observerFaction, observerFaction));
if (options.homeworlds)
g = applyAction(g, owner, { type: 'homeworlds', enabled: true });
@@ -155,6 +147,9 @@ export function nexusRicheseFixture(
? holdNexusRicheseCard(g, target, 'karama').id
: undefined;
g.players[0].spice = options.spice ?? 20;
// This focused Movement fixture intentionally jumps over the remaining
// phases; a live Charity turn cannot survive that staged boundary.
delete g.charityOrder;
Object.assign(g, {
phase: 5,
active: owner,
@@ -0,0 +1,208 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { AmbassadorShipment } from '../components/ambassador-shipment';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
import { validateAmbassadors } from '../game/ecaz-ambassadors';
import {
actGuildAmbassadorNoField as act,
advanceGuildAmbassadorNoField as advance,
guildAmbassadorNoFieldClean as clean,
guildAmbassadorNoFieldInventory as inventory,
guildAmbassadorNoFieldPlayer as player,
passGuildAmbassadorNoFieldResponses as pass,
} from './fixture-guild-ambassador-no-field';
/** Genuine public Advanced E2/E3 setup, paid placements, reciprocal alliance
* and paid Harkonnen entry. Only unopened spice order, the selected physical
* Ambassador packet and the cancellation card are staged; all pieces stay in
* their original inventories and no turn, phase or pending choice is assigned. */
function advancedGrant(beneficiary: 'own' | 'allied') {
let g = createGame('ADVANCEDGUILDMARKER', newPlayer('ecaz', 'Ecaz', 'ecaz'), true, ['ecaz', 'choam']);
for (const id of ['richese', 'harkonnen', 'guild'] as const) joinGame(g, newPlayer(id, id, id));
for (const p of g.players) g = act(g, p.id, { type: 'ready' });
g = act(g, 'ecaz', { type: 'start', advancedPreview: true });
g = advance(g, state => state.status === 'playing');
assert.equal(g.advanced, true);
const originalCards = inventory(g);
for (const position of [0, 1]) {
const index = g.spiceDeck.findIndex((card, i) => i >= position && 'territory' in card && !card.discovery);
assert.ok(index >= position);
[g.spiceDeck[position], g.spiceDeck[index]] = [g.spiceDeck[index], g.spiceDeck[position]];
}
g = advance(g, state => state.phase === 4 && !state.response && !state.phaseOpening && state.decision?.kind === 'ecazPlacement');
const markers = g.ecazAmbassadors!;
const guildToken = markers.tokens.find(token => token.effect === 'guild')!;
if (guildToken.zone === 'pool') {
const replaced = markers.tokens.find(token => token.zone === 'supply' && token.effect !== 'ecaz')!;
const index = markers.cohort.indexOf(replaced.id); assert.ok(index >= 0);
markers.cohort[index] = guildToken.id;
guildToken.zone = 'supply'; replaced.zone = 'pool';
}
validateAmbassadors(markers);
const selfToken = markers.tokens.find(token => token.effect === 'ecaz')!;
g = act(g, 'ecaz', { type: 'decision', token: selfToken.id, territory: 'carthag' });
g = advance(g, state => !state.response && state.decision?.kind === 'ecazPlacement');
g = act(g, 'ecaz', { type: 'decision', token: guildToken.id, territory: 'habbanya_ridge_sietch' });
g = advance(g, state => !state.response && state.decision?.kind === 'ecazPlacement');
g = act(g, 'ecaz', { type: 'decision', decline: true });
g = advance(g, state => state.phase === 5 && state.active === 'ecaz' && clean(state));
g = act(g, 'ecaz', { type: 'ship', amount: 1, territory: 'polar_sink', sector: 0, elite: 0, allyPayment: 0 });
g = advance(g, clean);
g = act(g, 'ecaz', { type: 'endMovement' });
g = advance(g, state => state.active === 'richese' && clean(state));
g = act(g, 'richese', { type: 'ship', amount: 1, territory: 'carthag', sector: 11, elite: 0, allyPayment: 0 });
g = advance(g, state => !state.response && state.pendingAmbassador?.stage === 'offer');
g = act(g, 'ecaz', { type: 'decision', event: g.pendingAmbassador!.event,
trigger: true, beneficiary: 'ecaz', choice: 'alliance' });
assert.equal(g.pendingAmbassador?.stage, 'allianceReply');
g = act(g, 'richese', { type: 'decision', event: g.pendingAmbassador!.event, accept: true });
g = advance(g, clean);
assert.equal(player(g, 'ecaz').ally, 'richese');
assert.equal(player(g, 'richese').ally, 'ecaz');
g = act(g, 'richese', { type: 'endMovement' });
g = advance(g, state => state.active === 'harkonnen' && clean(state));
g = act(g, 'harkonnen', { type: 'ship', amount: 1, territory: 'habbanya_ridge_sietch', sector: 17,
elite: 0, allyPayment: 0 });
g = advance(g, state => !state.response && state.pendingAmbassador?.stage === 'offer');
const beforeTrigger = structuredClone(g);
const recipient = beneficiary === 'own' ? 'richese' : 'ecaz';
g = act(g, 'ecaz', { type: 'decision', event: g.pendingAmbassador!.event, trigger: true, beneficiary: recipient });
assert.equal(g.pendingAmbassador?.stage, 'ship');
assert.equal(g.pendingAmbassador.effect, 'guild');
assert.equal(g.decision?.player, recipient);
assert.equal(g.active, 'harkonnen');
assert.deepEqual(inventory(g), originalCards);
return { g, event: g.pendingAmbassador.event, recipient, originalCards, beforeTrigger };
}
function addHeldKarama(g: Game, id = 'harkonnen') {
const holder = player(g, id);
const existing = holder.hand.find(card => card.effect === 'karama');
if (existing) return existing.id;
const index = g.deck.findIndex(card => card.effect === 'karama'); assert.ok(index >= 0);
const card = g.deck.splice(index, 1)[0]; holder.hand.push(card); return card.id;
}
function nativeMarker(g: Game, event: string) {
const richese = player(g, 'richese');
const token = richese.noField!.tokens.find(token => token.value === 3)!;
return { type: 'decision' as const, event, amount: 1, noField: token.id,
noFieldEvent: richese.noFieldEvent!, territory: 'sietch_tabr', sector: 14 };
}
function allowances(g: Game) {
return { active: g.active, remaining: g.movementRemaining,
players: g.players.map(p => ({ id: p.id, shipped: p.shipped, moved: p.moved })) };
}
void test('Advanced native Guild grant offers and commits Richese marker without spending the ordinary shipment', () => {
const f = advancedGrant('own'), before = structuredClone(f.g);
const view = viewGame(f.g, 'richese');
assert.equal(view.ambassadorEntry?.noField?.stage, 'own');
assert.ok(view.ambassadorEntry.noField.options.some(option => option.action.noField === nativeMarker(f.g, f.event).noField));
assert.equal(viewGame(f.g, 'harkonnen').ambassadorEntry?.noField ?? null, null);
const html = renderToStaticMarkup(createElement(AmbassadorShipment, { game: view, busy: false, act() {} }));
assert.match(html, /Ambassador No-Field shipment/);
for (const difficulty of DIFFICULTIES) {
const botView = viewGame(f.g, 'richese'); botView.players.find(p => p.id === 'richese')!.bot = difficulty;
const action = botActions(botView)[0]; assert.ok(action, difficulty);
assert.doesNotThrow(() => act(f.g, 'richese', action), difficulty);
}
let g = act(f.g, 'richese', nativeMarker(f.g, f.event));
g = pass(g);
assert.equal(g.decision?.kind, 'guildShipment');
assert.equal(g.decision.player, 'guild');
assert.equal(player(g, 'richese').noField!.deployed, null);
g = act(g, 'guild', { type: 'decision', allow: true });
assert.equal(player(g, 'richese').noField!.deployed?.tokenId, nativeMarker(f.g, f.event).noField);
assert.equal(player(g, 'richese').reserves, player(before, 'richese').reserves);
assert.equal(player(g, 'richese').spice, player(before, 'richese').spice);
assert.deepEqual(allowances(g), allowances(before));
assert.deepEqual(inventory(g), f.originalCards);
assert.equal(viewGame(g, 'harkonnen').players.find(p => p.id === 'richese')!.noField!.deployed!.effectiveForces, 1);
g = advance(g, clean);
assert.equal(g.pendingAmbassador, null);
assert.equal(g.active, 'harkonnen');
});
for (const value of [0, 3] as const) void test(`Advanced allied Guild grant requests consent and materializes the ${value} marker with its fee`, () => {
const f = advancedGrant('allied'), before = structuredClone(f.g);
assert.equal(viewGame(f.g, 'ecaz').ambassadorEntry?.noField?.stage, 'request');
let g = act(f.g, 'ecaz', { type: 'decision', event: f.event, requestNoField: true, territory: 'sietch_tabr', sector: 14 });
assert.equal(viewGame(g, 'richese').ambassadorEntry?.noField?.stage, 'supply');
const richese = player(g, 'richese'), token = richese.noField!.tokens.find(row => row.value === value)!;
g = act(g, 'richese', { type: 'decision', event: f.event, offerNoField: token.id, noFieldEvent: richese.noFieldEvent!, payer: 'ecaz', elite: 0 });
assert.equal(viewGame(g, 'ecaz').ambassadorEntry?.noField?.stage, 'consent');
assert.equal(player(g, 'ecaz').reserves, player(before, 'ecaz').reserves);
g = act(g, 'ecaz', { type: 'decision', event: f.event, acceptNoField: true });
g = pass(g);
assert.equal(g.decision?.kind, 'guildShipment');
assert.equal(g.decision.player, 'guild');
assert.equal(player(g, 'ecaz').forces['sietch_tabr:14'] ?? 0, 0);
g = act(g, 'guild', { type: 'decision', allow: true });
g = pass(g);
assert.equal(player(g, 'ecaz').forces['sietch_tabr:14'] ?? 0, value);
assert.equal(player(g, 'ecaz').reserves, player(before, 'ecaz').reserves - value);
assert.equal(player(g, 'ecaz').spice, player(before, 'ecaz').spice - 1);
assert.equal(player(g, 'guild').spice, player(before, 'guild').spice + 1);
assert.equal(player(g, 'richese').noField!.lastShipped, token.id);
assert.deepEqual(allowances(g), allowances(before));
assert.deepEqual(inventory(g), f.originalCards);
g = advance(g, clean);
assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen');
});
void test('Advanced Karama prevents only the Guild marker and preserves the physical shipment fallback', () => {
const f = advancedGrant('own'), g0 = structuredClone(f.g);
const karama = addHeldKarama(g0), before = structuredClone(g0);
assert.deepEqual(inventory(g0), f.originalCards);
let g = act(g0, 'richese', nativeMarker(g0, f.event));
assert.equal(g.response?.kind, 'richeseNoField');
g = act(g, 'harkonnen', { type: 'card', mode: 'cancel', card: karama });
g = advance(g, state => !state.response && !state.pendingTreacheryDiscard);
assert.equal(g.pendingAmbassador?.stage, 'ship');
assert.equal(g.pendingAmbassador.event, f.event);
assert.equal(player(g, 'richese').noField!.deployed, null);
assert.equal(player(g, 'richese').noFieldBlockedTurn, player(before, 'richese').noFieldBlockedTurn);
assert.equal(player(g, 'richese').reserves, player(before, 'richese').reserves);
assert.deepEqual(allowances(g), allowances(before));
assert.equal(g.discard.filter(card => card.id === karama).length, 1);
g = act(g, 'richese', { type: 'decision', event: f.event, amount: 1, territory: 'sietch_tabr', sector: 14, elite: 0 });
g = advance(g, clean);
assert.equal(player(g, 'richese').forces['sietch_tabr:14'], 1);
assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen');
assert.deepEqual(inventory(g), f.originalCards);
});
for (const beneficiary of ['own', 'allied'] as const) void test(`Advanced Guild special stops the ${beneficiary} marker shipment without charging or consuming it`, () => {
const f = advancedGrant(beneficiary), source = structuredClone(f.g);
const karama = addHeldKarama(source, 'guild'), before = structuredClone(source);
let g = source;
if (beneficiary === 'own') g = act(g, 'richese', nativeMarker(g, f.event));
else {
g = act(g, 'ecaz', { type: 'decision', event: f.event, requestNoField: true,
territory: 'sietch_tabr', sector: 14 });
const richese = player(g, 'richese'), token = richese.noField!.tokens.find(row => row.value === 3)!;
g = act(g, 'richese', { type: 'decision', event: f.event, offerNoField: token.id,
noFieldEvent: richese.noFieldEvent!, payer: 'ecaz', elite: 0 });
g = act(g, 'ecaz', { type: 'decision', event: f.event, acceptNoField: true });
}
g = pass(g);
assert.equal(g.decision?.kind, 'guildShipment');
assert.equal(g.decision.player, 'guild');
g = act(g, 'guild', { type: 'card', mode: 'special', card: karama });
g = advance(g, clean);
assert.equal(player(g, 'guild').specialKaramaUsed, true);
assert.equal(g.discard.filter(card => card.id === karama).length, 1);
assert.equal(player(g, 'richese').noField!.deployed, null);
assert.equal(player(g, 'richese').noField!.lastShipped, player(before, 'richese').noField!.lastShipped);
for (const id of ['richese', 'ecaz', 'guild']) {
assert.equal(player(g, id).spice, player(before, id).spice);
assert.equal(player(g, id).reserves, player(before, id).reserves);
}
assert.deepEqual(allowances(g), allowances(before));
assert.deepEqual(inventory(g), f.originalCards);
assert.equal(g.pendingAmbassador, null); assert.equal(g.active, 'harkonnen');
});
+148
View File
@@ -0,0 +1,148 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
applyAction, createGame, joinGame, newPlayer, normalizeAutomaticGame, viewGame,
type Action, type Game,
} from '../game/engine';
import { LEADER_SKILL_CARDS } from '../game/leader-skill-cards';
import { validateLeaderSkills } from '../game/leader-skills';
import { validateNexusCards } from '../game/nexus-cards';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
import { takeKullCard } from './fixture-choam-kull';
import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards';
import {
advanceSemutaNexusTrade, swapSemutaNexusTradeIdentity,
type SemutaNexusTradeStep,
} from './fixture-semuta-nexus-trade';
const act = (game: Game, actor: string, action: Action) => applyAction(game, actor, action);
const seat = (game: Game, id: string) => {
const player = game.players.find(candidate => candidate.id === id);
assert.ok(player); return player;
};
const clean = (game: Game) => !game.phaseOpening && !game.response && !game.decision && !game.truthtrance;
const physical = (game: Game) => [
...game.deck, ...game.discard, ...(game.auction?.cards.slice(game.auction.index) ?? []),
...(game.richeseCache ?? []), ...(game.richeseRemoved ?? []),
...(game.ixAuction?.cards ?? []), ...game.players.flatMap(player => player.hand),
].map(card => card.id).sort();
function skills(game: Game) {
assert.ok(game.leaderSkills);
validateLeaderSkills(game.leaderSkills, game.players);
const state = game.leaderSkills;
assert.deepEqual([...state.deck, ...Object.values(state.offers).flatMap(offer => offer.cards),
...state.assignments.map(assignment => assignment.skill)].sort(),
LEADER_SKILL_CARDS.map(card => card.id).sort());
}
/** Public selected-module start, real skill training and a real earned Nexus.
* Only unopened Spice order, the identity of an earned card, and conserved
* board/hand pieces are staged, matching the existing public Kull fixture. */
function fixture(independent: boolean, richese = false) {
let game = createGame('NEXUSKULLSKILLS', newPlayer('c', 'CHOAM', 'choam'), false, ['ix', 'choam', 'ecaz']);
for (const [id, faction] of [['a', 'atreides'], ['g', 'guild'], ['h', 'harkonnen']] as const)
joinGame(game, newPlayer(id, faction, faction));
if (richese) joinGame(game, newPlayer('r', 'Richese', 'richese'));
for (const moduleName of [...(independent ? ['ecazTreachery'] : []), 'nexusCards', 'leaderSkills', 'kullPreview'])
game = act(game, 'c', { type: 'moduleOption', module: moduleName, enabled: true });
const selected = viewGame(game, 'c').lobbyModules!;
assert.equal(selected.nexusCards, true); assert.equal(selected.leaderSkills, true);
assert.equal(selected.kullPreview, true);
if (independent) assert.equal(selected.ecazTreachery, true);
for (const player of game.players) game = act(game, player.id, { type: 'ready' });
game = act(game, 'c', { type: 'start' });
assert.equal(game.kullPreview, true); assert.equal(game.nexusKullPreview, true);
if (richese) { assert.equal(game.semutaPreview, true); assert.ok(game.richeseCache?.length); }
assert.ok(game.leaderSkills); assert.ok(game.nexusCards);
assert.equal(game.ecazTreachery === true, independent);
const setupActions: SemutaNexusTradeStep[] = [];
game = advanceSemutaNexusTrade(game, state => state.status === 'playing', setupActions);
assert.equal(setupActions.filter(row => row.action.type === 'leaderSkill').length, game.players.length);
assert.equal(game.leaderSkills!.assignments.length, game.players.length);
skills(game); validateNexusCards(game.nexusCards!.cards!, game.players);
const inventory = physical(game);
const originalSkills = structuredClone(game.leaderSkills);
for (const player of game.players) {
player.reserves += Object.values(player.forces).reduce((sum, amount) => sum + amount, 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 && clean(state));
game = act(game, 'a', { type: 'alliance', target: 'h' });
game = act(game, 'h', { type: 'alliance', target: 'a' });
game = advanceSemutaNexusTrade(game, state => state.nexusCards?.phase?.stage === 'drawing' && clean(state));
assert.ok(game.nexusCards!.phase!.eligible.includes('c'));
game = act(game, 'c', { type: 'nexusCardChoice', turn: game.turn, card: null, choice: 'draw', ownRedraws: 0 });
swapSemutaNexusTradeIdentity(game, 'c', 'choam');
game = advanceSemutaNexusTrade(game, state => state.phase === 5 && state.active === 'g' && clean(state));
assert.equal(game.nexusCards!.cards!.hands.c, 'choam');
for (const player of game.players) game.deck.push(...player.hand.splice(0));
const fuel = takeKullCard(game, 'ix-hunter-seeker'); seat(game, 'c').hand.push(fuel);
const original = takeKullCard(game, 'karama'); seat(game, 'g').hand.push(original);
if (richese) seat(game, 'r').hand.push(takeKullCard(game, SEMUTA_DRUG_ID));
assert.deepEqual(physical(game), inventory);
assert.deepEqual(game.leaderSkills, originalSkills);
game = act(game, 'g', { type: 'card', mode: 'shipment', card: original.id, target: 'g' });
assert.ok(game.pendingKull);
assert.deepEqual(game.leaderSkills, originalSkills);
return { game, fuel: fuel.id, original: original.id, event: game.pendingKull.event, inventory, originalSkills };
}
for (const independent of [false, true]) void test(
`Basic public Nexus Kull keeps trained Leader Skills${independent ? ' with independent Ecaz cards' : ''}`, () => {
const f = fixture(independent);
for (const difficulty of DIFFICULTIES) {
const view = viewGame(f.game, 'c'); view.players.find(player => player.id === 'c')!.bot = difficulty;
const choice = botActions(view).find(action => action.type === 'kullDecision');
assert.ok(choice); assert.doesNotThrow(() => act(f.game, 'c', choice));
}
assert.ok(viewGame(f.game, 'c').kullReaction?.plays.some(play => play.source === 'nexus' && play.card.id === f.fuel));
let game = act(f.game, 'c', { type: 'kullDecision', event: f.event, source: 'nexus', card: f.fuel });
while (game.pendingKull) {
const responder = game.players.find(player => {
const controls = viewGame(game, player.id).responseControls;
return controls && !controls.hasPassed && controls.cancelCards.length > 0;
});
game = responder ? act(game, responder.id, { type: 'passResponse' }) : normalizeAutomaticGame(game);
}
assert.equal(game.nexusCards!.cards!.hands.c, null);
assert.equal(game.discard.filter(card => card.id === f.fuel).length, 1);
assert.equal(seat(game, 'g').hand.some(card => card.id === f.original), true);
assert.deepEqual(physical(game), f.inventory);
assert.deepEqual(game.leaderSkills, f.originalSkills);
skills(game); validateNexusCards(game.nexusCards!.cards!, game.players);
},
);
void test('Richese can claim Nexus Kull fuel with Semuta while original Skills and cache remain physical', () => {
const f = fixture(true, true);
assert.ok(viewGame(f.game, 'c').kullReaction?.plays.some(play => play.source === 'nexus' && play.card.id === f.fuel));
let game = act(f.game, 'c', { type: 'kullDecision', event: f.event, source: 'nexus', card: f.fuel });
for (let n = 0; game.pendingKull && n < 20; n++) {
const responder = game.players.find(player => {
const controls = viewGame(game, player.id).responseControls;
return controls && !controls.hasPassed && controls.cancelCards.length > 0;
});
game = responder ? act(game, responder.id, { type: 'passResponse' }) : normalizeAutomaticGame(game);
}
assert.equal(game.pendingKull, null);
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
assert.deepEqual(pending.batch.entries.map(entry => entry.card.id), [f.fuel]);
assert.equal(viewGame(game, 'r').semutaReaction?.canCommit, true);
game = act(game, 'r', { type: 'semutaCommit', event: pending.batch.event });
if (game.pendingTreacheryDiscard?.reaction?.stage === 'select')
game = act(game, 'r', { type: 'semutaSelect', event: pending.batch.event, card: f.fuel });
assert.equal(game.pendingTreacheryDiscard, null);
assert.equal(seat(game, 'r').hand.some(card => card.id === f.fuel), true);
assert.equal(game.discard.some(card => card.id === SEMUTA_DRUG_ID), true);
assert.equal(game.nexusCards!.cards!.hands.c, null);
assert.equal(seat(game, 'g').hand.some(card => card.id === f.original), true);
assert.deepEqual(physical(game), f.inventory);
assert.deepEqual(game.leaderSkills, f.originalSkills);
skills(game); validateNexusCards(game.nexusCards!.cards!, game.players);
});
+68
View File
@@ -0,0 +1,68 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
independentNexusProfile, nexusCoreProfile, nexusKullLeaderSkillsProfile,
type FactionModuleProfile,
} from '../game/faction-module-profile';
import { ordinaryLeaderSkillModeSupported } from '../game/leader-skill-profile';
import { bureaucratPaymentModeSupported, quoteBureaucratPayment } from '../game/bureaucrat-payment';
import { mentatQuestionModeSupported } from '../game/mentat-question';
import { spiceBankerModeSupported } from '../game/spice-banker';
const original: FactionModuleProfile = {
advanced: false,
expansions: ['ix', 'choam', 'ecaz'],
players: [{ faction: 'choam' }, { faction: 'richese' }, { faction: 'ecaz' }],
nexusCards: {},
leaderSkills: {},
ecazTreachery: true,
semutaPreview: true,
};
void test('Basic Nexus, Kull and Skills retain the same public authority before and after Kull stamps', () => {
for (const independent of [false, true]) for (const stamped of [false, true]) {
const game = { ...original, ecazTreachery: independent,
...(stamped ? { kullPreview: true, nexusKullPreview: true } : {}) };
const label = `independent=${independent}, stamped=${stamped}`;
assert.equal(nexusKullLeaderSkillsProfile(game), true, label);
assert.equal(nexusCoreProfile(game), true, label);
assert.equal(independentNexusProfile(game), independent, label);
assert.equal(ordinaryLeaderSkillModeSupported(game), true, label);
assert.equal(mentatQuestionModeSupported(game), true, label);
assert.equal(spiceBankerModeSupported(game), true, label);
assert.equal(bureaucratPaymentModeSupported(game), true, label);
}
});
void test('Bureaucrat keeps its ordinary once-per-phase quote in this supported composition', () => {
const game = { ...original, kullPreview: true, nexusKullPreview: true };
assert.equal(bureaucratPaymentModeSupported(game), true);
const payment = { owner: 'ecaz', payer: 'choam', payee: 'richese', amount: 7,
turn: 2, phase: 3, used: [] };
assert.deepEqual(quoteBureaucratPayment(payment), { redirect: 2, income: 5 });
assert.equal(quoteBureaucratPayment({ ...payment, amount: 4 }), null);
assert.equal(quoteBureaucratPayment({ ...payment,
used: [{ event: 'used', owner: 'ecaz', turn: 2, phase: 3, signature: '' }] }), null);
});
void test('the Kull and Skills profile rejects unmatched stamps and unrelated module overlays', () => {
const invalid: Array<[string, Partial<FactionModuleProfile>]> = [
['Advanced', { advanced: true }],
['missing Nexus', { nexusCards: null }],
['missing Skills', { leaderSkills: null }],
['no CHOAM seat', { players: [{ faction: 'richese' }, { faction: 'ecaz' }] }],
['duplicate faction', { players: [{ faction: 'choam' }, { faction: 'choam' }] }],
['unselected faction', { expansions: ['ix', 'choam'] }],
['duplicate deck', { expansions: ['ix', 'choam', 'ix'] }],
['only Kull stamp', { kullPreview: true }],
['only Nexus Kull stamp', { nexusKullPreview: true }],
['Homeworlds', { homeworlds: {} }],
['Discovery', { discoveryEnabled: true }],
['Tech', { techTokens: {} }],
['Strongholds', { strongholdCards: {} }],
['unrelated betrayal', { richeseBetrayalPreview: true }],
['Semuta without Richese', { players: [{ faction: 'choam' }, { faction: 'ecaz' }] }],
];
for (const [label, patch] of invalid)
assert.equal(nexusKullLeaderSkillsProfile({ ...original, ...patch }), false, label);
});
+22 -5
View File
@@ -209,7 +209,7 @@ for (const kind of ['emperor-revival', 'fremen-revival'] as const) {
});
}
void test('Fremen prior free returns count toward the quota, exhausted improvement is unavailable, and real Truthtrance blocks both grants', () => {
void test('Fremen prior free returns count toward the quota, short returns work, and real Truthtrance blocks both grants', () => {
const f = createNexusModulePaymentsFixture({ kind: 'fremen-revival' });
const late = advanceNexusModulePaymentsToPhase(applyAction(f.game, f.actor, { type: 'revive', amount: 1 }), 4);
const granted = applyAction(late, f.actor, f.paymentAction);
@@ -219,8 +219,19 @@ void test('Fremen prior free returns count toward the quota, exhausted improveme
assert.equal(returned.players.find(p => p.id === f.actor)!.revived, 3);
for (const kind of ['fremen-revival', 'emperor-revival'] as const) {
const short = createNexusModulePaymentsFixture({ kind, tanks: 2 });
if (kind === 'emperor-revival') rejected(short.game, short.actor, short.paymentAction);
else {
if (kind === 'emperor-revival') {
// The later positive-shortage policy returns the available one or two
// forces in addition to the ordinary allowance; it supersedes the
// original full-three-only test expectation.
const before = short.beforePayment.players.find(p => p.id === short.actor)!;
const partial = payNexusModulePaymentsFixture(short);
const after = partial.players.find(p => p.id === short.actor)!;
assert.equal(after.tanks, 0);
assert.equal(after.reserves, before.reserves + 2);
assert.equal(after.revived, before.revived);
assert.equal(after.freeForcesRevived, before.freeForcesRevived);
assert.equal(partial.nexusCards!.cards!.discard.filter(card => card === 'emperor').length, 1);
} else {
const enabled = applyAction(short.game, short.actor, short.paymentAction);
rejected(enabled, short.actor, { type: 'revive', amount: 3 });
const partial = advanceNexusModulePaymentsToPhase(applyAction(enabled, short.actor, { type: 'revive', amount: 2 }), 4);
@@ -266,14 +277,20 @@ void test('new module admission rejects too few Tech seats, Basic Strongholds, u
assert.throws(() => initializeNexusGameForAudit(lobby));
assert.deepEqual(lobby, before);
}
// Selected native-expansion cards/factions are not another path to admission.
// A selected Ix deck with classic factions is now a supported Nexus/Tech
// setup; it retains both original module selections through initialization.
let lobby = createGame('NEXUSMODULEDECK', newPlayer('a', 'Atreides', 'atreides'), false, ['ix']);
joinGame(lobby, newPlayer('h', 'Harkonnen', 'harkonnen'));
joinGame(lobby, newPlayer('e', 'Emperor', 'emperor'));
lobby.nexusCards = { cards: null, phase: null };
lobby.techTokens = createTechTokens();
for (const player of lobby.players) lobby = applyAction(lobby, player.id, { type: 'ready' });
assert.throws(() => initializeNexusGameForAudit(lobby));
const before = structuredClone(lobby);
const initialized = initializeNexusGameForAudit(lobby);
assert.deepEqual(lobby, before);
assert.deepEqual(initialized.expansions, ['ix']);
assert.ok(initialized.techTokens);
assert.ok(initialized.nexusCards);
});
for (const strongholds of [false, true]) {