Implement the five 7 October pending rule rulings

The user answered five recorded questions; each ruling is indexed in
RULE_DECISIONS.md and implemented with a focused regression.

- CHOAM opening income counts as a qualifying collection, so low-population
  Tupile adds its bank increment under the Inflation multiplier. The engine
  guard is removed and the projection/notice expose the added bonus.
- An exhausted Richese cache is legal and restores one ordinary lot; the
  canceled/prevented compulsory cache auction branch restores the reduction
  before the ordinary pool runs and the cache offer is skipped when no cache
  lot can run. The pure continuation quote mirrors the count.
- Suk-rescued casualties count toward Advanced Atreides' seven Kwisatz
  Haderach losses: the battle-loss counter gains the full dialed allocation in
  both rescue paths, and the earlier Suk availability restriction is removed.
- The Guild Nexus Secret Ally reserve return overrides the Arrakis-to-native-
  Homeworld restriction for the holder's own reserves and deposits through the
  shared native-reserve pipeline (generalized from the revival deposit).
- Interior passengers count as entering the territories a relocated Ixian HMS
  points into, so Sandmaster collects there before the native collection.

Full offline suite 7804/7804, types and lint pass. Historical evidence and
superseded test expectations are updated to the ruled behaviour; preserved
combined Homeworld/Nexus, occupation and Richese captures are unblocked but
not re-run here. No existing game, seat or saved state was changed.
This commit is contained in:
Quintine committed 2026-10-07 21:56:17 +11:00
1 parent e0101a937b
commit 7e3bec2721
41 files changed
+525 -234

No files matched your search

+7 -5
View File
@@ -351,7 +351,7 @@ void test('original Enemy of My Enemy and ally retention exclude a consumed nati
assert.deepEqual(normalizeAutomaticGame(reload(game)), game);
});
void test('new native admission preserves public, Harkonnen assassination, foreign family/module and Advanced Atreides Suk boundaries', () => {
void test('new native admission preserves public, Harkonnen assassination, foreign family/module and Advanced Atreides Suk assignment', () => {
const make = (faction: 'atreides' | 'harkonnen' | 'ixians' | 'ecaz' = 'atreides', expansions: Game['expansions'] = ['ecaz']) => {
const game = createGame('MORIGATE', newPlayer('original-m', 'Moritani', 'moritani'), true, expansions);
joinGame(game, newPlayer('original-other', faction, faction));
@@ -387,9 +387,11 @@ void test('new native admission preserves public, Harkonnen assassination, forei
const offered = initializeAdvancedNativeSkillsSetup(options);
const actor = player(offered, 'atreides').id, offer = offered.leaderSkills!.offers[actor];
const own = viewGame(offered, actor).leaderSkills!;
reject(offered, actor, { type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader: own.eligibleLeaders[0].id });
const complete = completeAdvancedNativeSkillsSetup(offered, options);
assert.notEqual(trainer(complete, actor).skill, 'suk-graduate');
assert.ok(complete.leaderSkills!.deck.includes('suk-graduate'));
// User ruling 7 October 2026: Suk is available to Advanced Atreides.
const assigned = applyAction(offered, actor, { type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader: own.eligibleLeaders[0].id });
assert.equal(trainer(assigned, actor).skill, 'suk-graduate');
assert.ok(!assigned.leaderSkills!.deck.includes('suk-graduate'));
const complete = completeAdvancedNativeSkillsSetup(assigned, options);
assert.equal(trainer(complete, actor).skill, 'suk-graduate');
custody(complete);
});
+7 -5
View File
@@ -218,17 +218,19 @@ void test('native CHOAM Bureaucrat redirects only another payer while its native
custody(game);
});
void test('Advanced native admission preserves Atreides Suk and rejects a forged Ix-controlled foreign ghola without mutation', () => {
void test('Advanced native admission assigns Atreides Suk and rejects a forged Ix-controlled foreign ghola without mutation', () => {
const options = { family: 'ixians' as const, skillOwner: 'atreides' as const, requestedSkill: 'suk-graduate' as const };
let game = initializeAdvancedNativeSkillsSetup(options);
while (game.decision?.kind === 'ixSetup') game = advancedNativeStep(game);
const actor = player(game, 'atreides').id;
const offer = game.leaderSkills!.offers[actor];
const leader = viewGame(game, actor).leaderSkills!.eligibleLeaders[0].id;
reject(game, actor, { type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader }, /Suk Graduate is unavailable/);
game = completeAdvancedNativeSkillsSetup(game, options);
assert.ok(game.leaderSkills!.deck.includes('suk-graduate'));
assert.notEqual(game.leaderSkills!.assignments.find(a => a.owner === actor)!.skill, 'suk-graduate');
// User ruling 7 October 2026: Suk is no longer withheld from Advanced Atreides.
const assigned = applyAction(game, actor, { type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader });
assert.equal(assigned.leaderSkills!.assignments.find(a => a.owner === actor)!.skill, 'suk-graduate');
assert.ok(!assigned.leaderSkills!.deck.includes('suk-graduate'));
game = completeAdvancedNativeSkillsSetup(assigned, options);
assert.equal(game.leaderSkills!.assignments.find(a => a.owner === actor)!.skill, 'suk-graduate');
custody(game);
// An Ixian cannot control this original foreign disc. Legitimate native
// Tleilaxu revival is covered separately, without fabricating assignments.
+6 -4
View File
@@ -427,16 +427,18 @@ void test('canceling a partial Richese-paid Emperor invoice advances to native H
assert.ok(canceled.next.kind === 'response' && canceled.next.response.kind === 'harkonnenBonus');
assert.deepEqual(g, before);
});
void test('Black Market cache exhaustion is checked only when reaching that declaration boundary; seller balance overflow rejects before credit', () => {
void test('Black Market cache exhaustion is legal at the declaration boundary; seller balance overflow rejects before credit', () => {
const g = richese();
g.richeseCacheCount = 0;
assert.equal(
quoteAuctionContinuation(g, { kind: 'sale', free: false }).next.kind,
'response',
);
assert.throws(
() => quoteAuctionContinuation(g, { kind: 'next' }),
/exhausted/,
// User ruling 7 October 2026: an exhausted cache is legal, so the declaration
// boundary is reached instead of rejecting.
assert.equal(
quoteAuctionContinuation(g, { kind: 'next' }).next.kind,
'richeseEnd',
);
g.richeseCacheCount = 8;
g.players.find((p) => p.id === 'r')!.spice = Number.MAX_SAFE_INTEGER;
+1
View File
@@ -318,6 +318,7 @@ void test('charity projections expose the payer and own entitlement without leak
payer: 'c',
incomePending: false,
incomeCanceled: false,
incomeHomeworld: 0,
});
assert.equal(v.players[0].spice, undefined);
assert.equal(v.players[0].handLimit, 5);
@@ -195,7 +195,9 @@ for (const band of ['normal', 'skilled'] as const) {
assert.equal(player(game, fixture.owner).forces[fixture.key], 7 - physicalLoss + (band === 'skilled' ? 1 : 0));
assert.equal(player(game, fixture.owner).reserves, original.reserves + saved - (band === 'skilled' ? 1 : 0));
assert.equal(player(game, fixture.owner).tanks, original.tanks + physicalLoss - saved);
assert.equal(player(game, fixture.owner).battleLosses, original.battleLosses + physicalLoss - saved);
// User ruling 7 October 2026: rescued counters still count toward the
// seven Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(player(game, fixture.owner).battleLosses, original.battleLosses + physicalLoss);
assert.deepEqual(player(game, fixture.owner).elites, original.elites);
assert.equal(game.pendingSukRescue, null);
assert.equal(game.lastBattleContext!.sukRescue!.completed, true);
@@ -129,7 +129,9 @@ for (const scenario of [
assert.equal(player(game, fixture.owner).forces[fixture.key], 8 - scenario.casualties + 1);
assert.equal(player(game, fixture.owner).reserves, before.reserves + 2);
assert.equal(player(game, fixture.owner).tanks, before.tanks + scenario.casualties - 3);
assert.equal(player(game, fixture.owner).battleLosses, before.battleLosses + scenario.casualties - 3);
// User ruling 7 October 2026: rescued counters still count toward the
// seven Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(player(game, fixture.owner).battleLosses, before.battleLosses + scenario.casualties);
moneyBeforeCleanup(fixture, revealed, game);
reject(game, fixture.owner, action);
});
@@ -92,7 +92,9 @@ void test('held Arrakeen support pays only the actual subsidy while trained phys
assert.equal(player(cleanup, fixture.owner).forces[fixture.key], 4);
assert.equal(player(cleanup, fixture.owner).reserves, original.reserves + 2);
assert.equal(player(cleanup, fixture.owner).tanks, original.tanks + 2);
assert.equal(player(cleanup, fixture.owner).battleLosses, original.battleLosses + 2);
// User ruling 7 October 2026: rescued counters still count toward the seven
// Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(player(cleanup, fixture.owner).battleLosses, original.battleLosses + quote.casualties!.options[0].normal);
assert.equal(ordinaryTotal(cleanup, fixture.owner), ordinaryTotal(revealed, fixture.owner));
assert.equal(cleanup.decision?.kind, 'battleCards');
assert.deepEqual(cleanup.techTokens, revealed.techTokens);
+37
View File
@@ -356,3 +356,40 @@ void test('a paid Nullentropy search preserves the actual BG charity split and r
rejects(reload(g), 'b', { type: 'charity' });
homeworldGameIntegrity(g);
});
void test('low-population Tupile adds its bank bonus to CHOAM opening income under the same Inflation multiplier', () => {
// User ruling 7 October 2026: CHOAM's opening income counts as a qualifying
// collection, so the low-population bank bonus applies (scaled by Inflation).
const run = (lowTupile: boolean, multiplier: number) => {
let g = choam(setup());
g.phase = 1;
g.nexus = true;
g.choamCharity = undefined;
if (lowTupile) low(g, 'c', 5); // Tupile below its 11-reserve high threshold
if (multiplier === 2) {
g.turn = 2;
g.inflation = {
side: 'double',
placedTurn: 1,
updatedTurn: 1,
flipped: false,
};
}
seat(g, 'a').spice = 0;
seat(g, 'b').spice = 0;
const before = seat(g, 'c').spice;
for (const id of ['a', 'b', 'c']) g = applyAction(g, id, { type: 'ready' });
while (g.decision?.kind === 'choamMarket')
g = applyAction(g, 'c', { type: 'decision', done: true });
assert.equal(g.phase, 2);
assert.equal(g.choamCharity?.canceled, false);
assert.equal(viewGame(g, 'a').charity.incomeHomeworld, lowTupile ? 1 : 0);
return seat(g, 'c').spice - before;
};
for (const multiplier of [1, 2]) {
const withLow = run(true, multiplier);
const withoutLow = run(false, multiplier);
assert.equal(withoutLow, 2 * 3 * multiplier, 'Ordinary opening income');
assert.equal(withLow - withoutLow, multiplier, 'Low-population bank bonus');
}
});
+1 -1
View File
@@ -2,7 +2,7 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import {
quoteNativeReserveWithdrawal as withdraw,
quoteNativeRevivalDeposit as revive,
quoteNativeReserveDeposit as revive,
NativeReserveError,
type NativeReserveSelections,
} from '../game/homeworld-native-reserves';
+31 -29
View File
@@ -224,36 +224,38 @@ function blackMarketOpportunity(winner: 'a' | 'b' | 'e' = 'a') {
}
for (const form of ['printed', 'worthless'] as const)
void test(`${form} Black Market cancellation rejects an exhausted-cache saved continuation before cost`, (t) => {
const { g: initial, worthless, printed } = blackMarketOpportunity();
const g = reload(initial);
// A constructed corruption boundary: a real offered Black Market retains
// its response while its cache has been exhausted. Preserve all card IDs.
g.richeseRemoved!.push(...g.richeseCache!);
g.richeseCache = [];
const before = structuredClone(g);
const physical = inventory(g);
const random = t.mock.method(crypto, 'getRandomValues', () => {
throw Error('Preflight must not draw randomness.');
});
const uuid = t.mock.method(crypto, 'randomUUID', () => {
throw Error('Preflight must not allocate a declaration event.');
});
assert.throws(
() =>
applyAction(g, form === 'printed' ? 'e' : 'b', {
type: 'card',
card: form === 'printed' ? printed : worthless,
mode: 'cancel',
}),
/exhausted Richese cache.*ruling/i,
void test(`${form} Black Market cancellation with an exhausted cache continues and restores the ordinary lot`, () => {
// User ruling 7 October 2026: an exhausted cache is legal, so a canceled
// Black Market settles and the round declares the ordinary pool with the
// cache's one-lot reduction restored.
const counts: number[] = [];
for (const exhausted of [false, true]) {
const { g: initial, worthless, printed } = blackMarketOpportunity();
const g = reload(initial);
// A real offered Black Market keeps its response while its cache is
// exhausted; every physical card ID is preserved.
if (exhausted) {
g.richeseRemoved!.push(...g.richeseCache!);
g.richeseCache = [];
}
const physical = inventory(g);
let canceled = applyAction(g, form === 'printed' ? 'e' : 'b', {
type: 'card',
card: form === 'printed' ? printed : worthless,
mode: 'cancel',
});
// The Worthless card opens its own conversion response before settling.
canceled = passKind(canceled, 'worthlessKarama');
assert.equal(canceled.decision?.kind, 'richeseDeclaration');
assert.ok(!canceled.pendingKarama);
assert.deepEqual(inventory(canceled), physical);
counts.push(canceled.richeseBidding!.normalCount!);
}
assert.equal(
counts[1],
counts[0] + 1,
'The exhausted cache restores exactly one ordinary lot',
);
assert.deepEqual(g, before);
assert.deepEqual(inventory(g), physical);
assert.equal(g.pendingKarama, undefined);
assert.equal(g.discard.length, 0);
assert.equal(random.mock.callCount(), 0);
assert.equal(uuid.mock.callCount(), 0);
});
function passKind(initial: Game, kind: NonNullable<Game['response']>['kind']) {
+1 -1
View File
@@ -134,7 +134,7 @@ void test('a private setup offer renders only its two physical cards and eligibl
});
void test('an unavailable offered skill remains inspectable while the other card is selected', () => {
const reason = 'Advanced Atreides awaits the Kwisatz Haderach loss-count ruling.';
const reason = 'This Leader Skill is unavailable in the current profile.';
const html = markup(view({
offer: { event: 'guarded-offer', cards: ['suk-graduate', 'warmaster'], leader: null },
eligibleLeaders: [leaders[0]],
@@ -192,7 +192,7 @@ void test('borrowed cross and return quotes preserve typed physical groups; no n
}
});
void test('Homeworld selection discounts independently legal typed custody; own world and Arrakis return remain unavailable', () => {
void test('Homeworld selection discounts independently legal typed custody; own world stays unavailable but the reserve return is granted', () => {
const f = nexusGuildSecretAllyFixture({
ownerFaction: 'emperor',
advanced: true,
@@ -243,7 +243,10 @@ void test('Homeworld selection discounts independently legal typed custody; own
).action,
null,
);
assert.equal(nexusGuildSecretAllyQuote(v, 'reserves', 5), null);
// User ruling 7 October 2026: the grant overrides the Arrakis-to-native-
// Homeworld restriction for the holder's own reserves, but not own-world
// or foreign-world destination shipments.
assert.ok(nexusGuildSecretAllyQuote(v, 'reserves', 5));
assert.equal(
nexusGuildSecretAllyAction(v, v.nexusGuildSecretAlly!.event, {
type: 'guildHomeworldShip',
@@ -16,6 +16,9 @@ import {
nexusGuildSecretAllianceFixture,
} from './fixture-nexus-guild-secret-ally';
import { nexusAllow } from './fixture-nexus-cards';
import { homeworldContext } from '../game/homeworld-game';
import { quoteNativeReserveWithdrawal } from '../game/homeworld-native-reserves';
import { observeHomeworldOccupation } from '../game/homeworld-occupation-history';
function rejected(g: Game, owner: string, action: Action) {
const before = structuredClone(g);
assert.throws(() => applyAction(g, owner, action));
@@ -304,3 +307,53 @@ void test('a genuine Moritani arrival alliance preserves completed Guild Secret
assert.notEqual(g.active, f.owner);
stable(g);
});
void test('Guild Secret Ally returns typed counters to the holder own native Homeworld reserves under Homeworlds', () => {
const f = nexusGuildSecretAllyFixture({
ownerFaction: 'emperor',
advanced: true,
homeworlds: true,
});
const p = f.g.players[0];
// Withdraw the staged board group through the real native-reserve pipeline so
// Homeworld custody stays conserved; the Emperor splits normal/Sardaukar.
const withdrawal = quoteNativeReserveWithdrawal(
homeworldContext(f.g),
f.g.homeworlds!.custody!,
p.id,
{ normal: 3, elite: 2 },
);
const seat = withdrawal.players.find((s) => s.id === p.id)!;
p.reserves = seat.reserves;
p.elites!.reserves = seat.eliteReserves;
f.g.homeworlds!.custody = withdrawal.state;
// Mirror the engine's observeOccupation so the qualification history stays
// consistent with the staged custody change.
if (f.g.homeworlds!.historyVersion === 1 && f.g.homeworldOccupationHistory)
f.g.homeworldOccupationHistory = observeHomeworldOccupation(
f.g.homeworldOccupationHistory,
homeworldContext(f.g),
f.g.homeworlds!.custody!,
f.g.turn,
'change',
`homeworld-change-${f.g.homeworldOccupationHistory.sources[0].event}-${f.g.homeworldOccupationHistory.sources.length}`,
);
p.forces['arrakeen:10'] = 5;
p.elites!.forces['arrakeen:10'] = 2;
stable(f.g);
const action = nexusGuildSecretAllyRequest(f.g, f.owner, {
type: 'guildShip',
from: 'arrakeen:10',
territory: 'reserves',
sector: 0,
amount: 5,
elite: 2,
});
const g = applyAction(f.g, f.owner, action);
assert.equal(g.players[0].spice, 17);
assert.equal(g.players[0].reserves, 20);
assert.equal(g.players[0].elites!.reserves, 5);
assert.equal(g.players[0].forces['arrakeen:10'], undefined);
rejected(g, f.owner, action);
stable(g);
});
+14 -10
View File
@@ -241,15 +241,19 @@ void test('Richese can fund its buyer from escrow with no unpledged spice, with
}
});
void test('an exhausted cache rejects a Black Market closing bid before saving an unfinishable Harkonnen acknowledgement', () => {
let before: Game | null = null, serialized = '';
assert.throws(() => createRicheseBetrayalFixture('sale',{source:'blackMarket',beforeFinalBid(g) {
void test('an exhausted cache no longer blocks a Black Market closing bid or its betrayal receipt', () => {
let emptied = false;
const fixture = createRicheseBetrayalFixture('sale',{source:'blackMarket',beforeFinalBid(g) {
(g.richeseRemoved ??= []).push(...g.richeseCache!.splice(0));
before = g;serialized = JSON.stringify(g);
}}), /cache/i);
assert.ok(before);
assert.equal(JSON.stringify(before),serialized);
assert.equal((before as Game).pendingRicheseBetrayal,null);
assert.equal((before as Game).richeseBetrayal!.current,null);
assert.equal((before as Game).richeseAuction!.outcome,null);
emptied = true;
}});
assert.ok(emptied);
const g = fixture.game;
// User ruling 7 October 2026: an exhausted cache is legal, so the closing bid
// completes and reaches its betrayal receipt with the physical cache preserved.
assert.equal(g.richeseCache?.length ?? 0,0);
assert.equal(g.richeseRemoved?.length,10);
assert.ok(g.pendingRicheseBetrayal);
assert.equal(g.pendingRicheseBetrayal.receipt.invoice.kind,'sale');
assert.equal(g.richeseBidding!.cacheCanceled,false);
});
@@ -166,7 +166,9 @@ for (const band of ['normal', 'skilled'] as const) for (const support of [3, 6])
assert.equal(player(game, fixture.owner).forces[fixture.key], 7 - physicalLoss + kept);
assert.equal(player(game, fixture.owner).reserves, before.reserves + saved - kept);
assert.equal(player(game, fixture.owner).tanks, before.tanks + physicalLoss - saved);
assert.equal(player(game, fixture.owner).battleLosses, before.battleLosses + physicalLoss - saved);
// User ruling 7 October 2026: rescued counters still count toward the
// seven Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(player(game, fixture.owner).battleLosses, before.battleLosses + physicalLoss);
assert.deepEqual(player(game, fixture.owner).elites, before.elites);
assert.equal(game.pendingSukRescue, null);
assert.equal(game.lastBattleContext!.sukRescue!.completed, true);
@@ -174,7 +174,9 @@ for (const mode of MODES) for (const band of ['normal', 'skilled'] as const) {
assert.deepEqual(pending.techTokens, revealed.techTokens, 'Physical rescue/substitution must precede original Tech transfer');
const p = player(pending, f.ixians);
assert.equal(p.tanks, original.tanks + 2); assert.equal(p.elites!.tanks, original.elites!.tanks + 2);
assert.equal(p.battleLosses, original.battleLosses + 2);
// User ruling 7 October 2026: rescued counters still count toward the
// seven Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(p.battleLosses, original.battleLosses + 3);
assert.equal(p.reserves, original.reserves + (band === 'normal' ? 1 : 0));
assert.equal(p.elites!.reserves, original.elites!.reserves + (band === 'normal' ? 1 : 0));
assert.equal(p.forces[f.location], band === 'normal' ? 3 : 4);
+3 -1
View File
@@ -147,7 +147,9 @@ for (const advanced of [false, true]) for (const band of ['normal', 'skilled'] a
assert.equal(pending.decision?.kind, 'ixSubstitution');
const p = player(pending, f.ixians);
assert.equal(p.tanks, original.tanks + 2); assert.equal(p.elites!.tanks, original.elites!.tanks + 2);
assert.equal(p.battleLosses, original.battleLosses + 2);
// User ruling 7 October 2026: rescued counters still count toward the
// seven Kwisatz Haderach losses, so the counter gains every dialed casualty.
assert.equal(p.battleLosses, original.battleLosses + 3);
assert.equal(p.reserves, original.reserves + (band === 'normal' ? 1 : 0));
assert.equal(p.elites!.reserves, original.elites!.reserves + (band === 'normal' ? 1 : 0));
assert.equal(p.forces[f.location], band === 'normal' ? 3 : 4);
+20 -24
View File
@@ -255,12 +255,14 @@ void test('Black Market declaration exhaustion is a separate pure immediate-cont
assert.deepEqual(quoteRicheseSettlement(value), {
kind: 'retainBlackMarket',
});
for (const count of [undefined, 0, -1, 0.5, Infinity, NaN])
// User ruling 7 October 2026: an exhausted cache (count 0) is legal; only a
// malformed or negative count is rejected.
for (const count of [undefined, -1, 0.5, Infinity, NaN])
assert.throws(
() => requireRicheseDeclarationCache(count),
RicheseSettlementError,
);
for (const count of [1, 2, 10])
for (const count of [0, 1, 2, 10])
assert.doesNotThrow(() => requireRicheseDeclarationCache(count));
assert.deepEqual(value, before);
// A sold lot can first suspend for replacement/bonus; quote is not phase advancement.
@@ -417,32 +419,26 @@ void test('quotes agree with real sold settlement debits, transfer and deferred
assert.equal(g.currentAuctionSale?.origin, source);
}
});
void test('a canceled unbid Black Market has the same exhausted-cache boundary as live continuation', () => {
void test('an exhausted cache is legal and restores one ordinary lot in the Richese declaration', () => {
// User ruling 7 October 2026: when no cache lot can run (exhausted cache, or
// a canceled/prevented cache auction) the cache's one-lot reduction is not
// applied, so the ordinary pool runs one more lot.
const counts: number[] = [];
for (const exhausted of [false, true]) {
const g = engineFixture('blackMarket');
g.richeseAuction!.outcome = { kind: 'unbid' };
if (exhausted) g.richeseCache = [];
requireRicheseDeclarationCache(g.richeseCache?.length);
const before = structuredClone(g);
assert.equal(
quoteRicheseSettlement(engineInput(g)).kind,
'retainBlackMarket',
);
if (exhausted) {
assert.throws(
() => requireRicheseDeclarationCache(g.richeseCache?.length),
/exhausted Richese cache/,
);
assert.throws(
() => observed.settleRicheseLot!(structuredClone(g)),
/exhausted Richese cache/,
);
assert.deepEqual(g, before);
} else {
requireRicheseDeclarationCache(g.richeseCache?.length);
observed.settleRicheseLot!(g);
assert.equal(g.decision?.kind, 'richeseDeclaration');
assert.equal(g.richeseBidding!.blackMarketSold, false);
assert.deepEqual(g.players, before.players);
}
observed.settleRicheseLot!(g);
assert.equal(g.decision?.kind, 'richeseDeclaration');
assert.equal(g.richeseBidding!.blackMarketSold, false);
assert.deepEqual(g.players, before.players);
counts.push(g.richeseBidding!.normalCount!);
}
assert.equal(
counts[1],
counts[0] + 1,
'The exhausted cache restores exactly one ordinary lot',
);
});
+38 -1
View File
@@ -12,13 +12,14 @@ import {
sandmasterDefaultChoice,
type SandmasterChoice,
} from '../game/sandmaster-movement';
import { splitLocation, territory } from '../game/board';
import { splitLocation, territory, mobileRoutes, mobileRouteDistance, MOBILE_LOCATION as INSIDE } from '../game/board';
import {
sandmasterMove,
sandmasterMovementGame,
} from './sandmaster-movement-fixture';
import { createTechTokens } from '../game/tech-tokens';
import { placeFixtureHand } from './fixture-hand';
import { smugglerShipmentGame } from './smuggler-shipment-fixture';
const restored = (g: Game): Game => JSON.parse(JSON.stringify(g));
function unchanged(
@@ -288,3 +289,39 @@ void test('A separate Hajr movement can collect again and only a later re-entry
assert.equal(next.players[0].moved, 2);
conserved(next, g);
});
void test('interior passengers count as entering the territories the relocated stronghold points into', () => {
// User ruling 7 October 2026: a relocated HMS interior counts as entering the
// outside territories, so the Sandmaster skill collects there. Compare the
// identical relocation with and without the assigned skill.
const run = (skill: 'sandmaster' | 'smuggler') => {
let g = smugglerShipmentGame('ixians', false, skill, undefined, ['ix']);
g.players[0].forces = { [INSIDE]: 6 };
g.players[0].reserves = 14;
if (g.players[0].elites) g.players[0].elites.forces = { [INSIDE]: 3 };
g.mobileStronghold = { location: 'polar_sink:0' };
g.spice = {};
g.phase = 8;
g.active = null;
for (const p of g.players) g = applyAction(g, p.id, { type: 'ready' });
for (const p of g.players) g = applyAction(g, p.id, { type: 'ready' });
assert.equal(g.decision?.kind, 'mobileStronghold');
const route = mobileRoutes(g, 3).find((r) => mobileRouteDistance(r) === 3)!;
const end = route.at(-1)!;
g.spice[end] = 100;
const before = g.players[0].spice;
g = applyAction(g, 'p', { type: 'decision', route, collect: true });
while (g.response)
g = applyAction(
g,
g.players.find((p) => !g.response!.passed.includes(p.id))!.id,
{ type: 'passResponse' },
);
assert.equal(g.mobileStronghold!.location, end);
return { spice: g.players[0].spice - before, pile: g.spice[end] ?? 0 };
};
const without = run('smuggler');
const with_ = run('sandmaster');
assert.equal(with_.spice, without.spice + 1, 'Sandmaster collects one extra spice');
assert.equal(with_.pile, without.pile - 1);
});
+8 -1
View File
@@ -70,7 +70,14 @@ for (const advanced of [false, true]) for (const band of ['normal', 'skilled'] a
assert.equal(rescued.forces[fixture.key], band === 'skilled' ? 5 : 4);
assert.equal(rescued.reserves, ownerBefore.reserves + (band === 'skilled' ? 2 : 1));
assert.equal(rescued.tanks, ownerBefore.tanks + (band === 'skilled' ? 1 : 3));
assert.equal(rescued.battleLosses, ownerBefore.battleLosses + (band === 'skilled' ? 1 : 3));
// User ruling 7 October 2026: rescued counters still count toward the seven
// Kwisatz Haderach losses, so the counter gains the full dialed allocation.
assert.equal(
rescued.battleLosses,
ownerBefore.battleLosses +
(rescued.tanks - ownerBefore.tanks) +
(band === 'skilled' ? 3 : 1),
);
assert.equal(game.lastBattleContext!.sukRescue!.completed, true);
assert.equal(game.pendingSukRescue, null);
assert.equal(game.decision?.kind, 'battleCards');
+10 -2
View File
@@ -19,8 +19,9 @@ export function smugglerShipmentGame(
advanced = false,
skill: 'smuggler' | 'sandmaster' = 'smuggler',
opponentFaction?: FactionId,
expansions: readonly string[] = [],
): Game {
let g = createGame('SMUGSHIP', newPlayer('p', 'Smuggler', faction), advanced);
let g = createGame('SMUGSHIP', newPlayer('p', 'Smuggler', faction), advanced, [...expansions]);
joinGame(
g,
newPlayer('h', 'Opponent', opponentFaction ?? (faction === 'guild' ? 'emperor' : 'guild')),
@@ -43,7 +44,14 @@ export function smugglerShipmentGame(
const view = viewGame(g, p.id);
const skills = view.leaderSkills!;
const options =
g.setupStage === 'leaderSkills' && skills.offer
g.decision?.kind === 'ixSetup'
? [
{
type: 'decision',
card: viewGame(g, g.decision.player).ixTechnology!.setup![0].id,
},
]
: g.setupStage === 'leaderSkills' && skills.offer
? [
{
type: 'leaderSkill',
+42 -33
View File
@@ -3,6 +3,7 @@ import test from 'node:test';
import { applyAction, normalizeAutomaticGame, viewGame, type Action, type Game } from '../game/engine';
import { sukGraduateSkill, sukRescueOptions, quoteSukRescue } from '../game/suk-graduate';
import { validateLeaderSkills } from '../game/leader-skills';
import type { LeaderSkillId } from '../game/leader-skill-cards';
import { botActions } from '../game/bots';
import { DIFFICULTIES } from '../game/bot-profiles';
import { advancedAtreidesSukOffer, sukBattle, resolveSuk } from './suk-graduate-fixture';
@@ -37,57 +38,54 @@ void test('Suk entitlement distinguishes public, selected, bluff, killed and cap
assert.equal(sukGraduateSkill([{ ...assignment, captured: true }], { id: 'skilled', dead: false }, true)?.mode, 'skilled');
});
void test('new Advanced Atreides setup and revival keep the physical Suk offer private but reject its assignment immutably', () => {
void test('new Advanced Atreides setup and revival can assign the physical Suk offer', () => {
const game = advancedAtreidesSukOffer();
const ownerView = viewGame(game, 'a');
const otherView = viewGame(game, 'd');
const offer = ownerView.leaderSkills!.offer!;
assert.equal(offer.cards.length, 2);
assert.ok(offer.cards.includes('suk-graduate'));
assert.match(
ownerView.leaderSkills!.unavailableSkills?.['suk-graduate'] ?? '',
/Kwisatz Haderach loss-count ruling is pending/,
);
assert.equal(otherView.leaderSkills?.unavailableSkills, undefined);
const leader = ownerView.leaderSkills!.eligibleLeaders[0].id;
const available = offer.cards.find((skill) => skill !== 'suk-graduate')!;
const blockedAction: Action = {
type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader: 'atreides-0',
// User ruling 7 October 2026: Suk is available to Advanced Atreides.
const action: Action = {
type: 'leaderSkill', event: offer.event, skill: 'suk-graduate', leader,
};
const before = JSON.stringify(game);
assert.throws(() => applyAction(game, 'a', blockedAction), /Suk Graduate is unavailable/);
assert.equal(JSON.stringify(game), before);
validateLeaderSkills(game.leaderSkills!, game.players);
const assigned = applyAction(game, 'a', { ...blockedAction, skill: available });
assert.equal(assigned.leaderSkills!.assignments.find((a) => a.owner === 'a')?.skill, available);
assert.ok(assigned.leaderSkills!.deck.includes('suk-graduate'));
const assigned = applyAction(game, 'a', action);
assert.equal(
assigned.leaderSkills!.assignments.find((a) => a.owner === 'a')?.skill,
'suk-graduate',
);
assert.ok(!assigned.leaderSkills!.deck.includes('suk-graduate'));
validateLeaderSkills(assigned.leaderSkills!, assigned.players);
const revival = structuredClone(game);
revival.status = 'playing';
revival.setupStage = undefined;
revival.leaderSkills!.offers.a.leader = 'atreides-0';
revival.leaderSkills!.offers.a.leader = leader;
revival.decision = { kind: 'leaderSkillRevival', player: 'a', event: offer.event };
const revivalBefore = JSON.stringify(revival);
assert.throws(() => applyAction(revival, 'a', blockedAction), /Suk Graduate is unavailable/);
assert.equal(JSON.stringify(revival), revivalBefore);
validateLeaderSkills(revival.leaderSkills!, revival.players);
const revived = applyAction(revival, 'a', action);
assert.equal(
revived.leaderSkills!.assignments.find((a) => a.owner === 'a')?.skill,
'suk-graduate',
);
validateLeaderSkills(revived.leaderSkills!, revived.players);
});
void test('all four Advanced Atreides bots choose the available other skill', () => {
void test('all four Advanced Atreides bots assign an offered skill', () => {
for (const difficulty of DIFFICULTIES) {
const game = advancedAtreidesSukOffer();
const view = viewGame(game, 'a');
view.players.find((player) => player.id === 'a')!.bot = difficulty;
const offer = view.leaderSkills!.offer!;
const available = offer.cards.find((skill) => skill !== 'suk-graduate')!;
const action = botActions(view)[0];
assert.equal(action?.type, 'leaderSkill', difficulty);
assert.equal(action?.skill, available, difficulty);
const chosen = action!.skill as LeaderSkillId;
assert.ok(offer.cards.includes(chosen), difficulty);
const assigned = applyAction(game, 'a', action);
assert.equal(assigned.leaderSkills!.assignments.find((a) => a.owner === 'a')?.skill, available);
assert.equal(
assigned.leaderSkills!.assignments.find((a) => a.owner === 'a')?.skill,
chosen,
);
validateLeaderSkills(assigned.leaderSkills!, assigned.players);
}
});
@@ -275,11 +273,22 @@ void test('Advanced normal rescue offers the actual casualty types and returns t
conserved(game);
});
void test('Advanced Atreides pending ruling rejects before the final traitor vote; Basic rescue remains playable', () => {
const blocked = sukBattle({ advanced: true, atreides: true });
const before = JSON.stringify(blocked);
assert.throws(() => resolveSuk(blocked), /Kwisatz Haderach loss-count ruling/);
assert.equal(JSON.stringify(blocked), before);
void test('Advanced Atreides rescue proceeds and rescued casualties count toward the Kwisatz Haderach threshold', () => {
const advanced = resolveSuk(sukBattle({ advanced: true, atreides: true }));
const decision = advanced.decision;
assert.equal(decision?.kind, 'sukRescue');
if (decision?.kind !== 'sukRescue') throw new Error('Missing rescue');
const owner = advanced.players.find((p) => p.id === 'a')!;
const lossesBefore = owner.battleLosses;
const tanksBefore = owner.tanks;
// User ruling 7 October 2026: rescued counters still count as battle losses,
// so the counter gains the rescued three as well as the Tank-bound counters.
const rescued = chooseRescue(advanced, 3);
const after = rescued.players.find((p) => p.id === 'a')!;
const tanksDelta = after.tanks - tanksBefore;
assert.equal(after.battleLosses - lossesBefore, tanksDelta + 3);
assert.ok(tanksDelta > 0, 'Some dialed casualties still reach the Tanks');
conserved(rescued);
const basic = resolveSuk(sukBattle({ atreides: true }));
assert.equal(basic.decision?.kind, 'sukRescue');
conserved(chooseRescue(basic, 3));