Allow Richese special purchase at Ix openings
Verify and publish checkpoint container / container (push) Successful in 10m34s
Verify and publish checkpoint container / container (push) Successful in 10m34s
This commit is contained in:
1 parent
d169740adf
commit
53780c11d8
10 files changed
+395
-5
No files matched your search
@@ -17,6 +17,16 @@ open mode gates.
|
||||
|
||||
## Current checkpoint and work
|
||||
|
||||
**Advanced Richese special purchase during Ix phase openings — 16 November.
|
||||
Prototyped / Partial.** A clean opening retains its existing passes while the
|
||||
original once-game purchase and any Emperor income response complete. Semuta
|
||||
may claim or pass the spent Karama before the purchase continues; the human
|
||||
control and minimal legal bot continuation are connected. Existing saved
|
||||
income continuations retain their previous format. Eleven related offline
|
||||
files pass 73 cases; the production build passes. Other timing, optional
|
||||
combinations and deployed acceptance remain open.
|
||||
[Scope](RICHESE_ACQUISITION_RULES.md#ix-phase-opening-purchase--16-november-2026).
|
||||
|
||||
**Richese reveal with public agreements — 16 November. Prototyped / Partial.**
|
||||
An active deal no longer independently blocks a supported before-Battle
|
||||
No-Field reveal. Current-turn travel and other binding promise guards remain;
|
||||
|
||||
@@ -13,6 +13,28 @@ Targeted searches found discussion titles concerning full hands and alliance can
|
||||
|
||||
## 1. Advanced special Karama purchase
|
||||
|
||||
### Ix phase-opening purchase — 16 November 2026
|
||||
|
||||
**Prototyped / Partial.** The user-authorized revised rulebook physical p. 20
|
||||
lists the Advanced Richese purchase at any time. Richese may now use the
|
||||
existing private purchase control during a clean Ix phase opening, including
|
||||
after earlier players have passed. With an Emperor, the original opening is
|
||||
suspended while the separate income response resolves; allowing or canceling
|
||||
that income restores the exact passes and initialization. With no Emperor,
|
||||
the bank purchase leaves the opening in place. The cost, acquisition, once-use
|
||||
and original optional responses remain native; existing saved income records
|
||||
without an opening retain their old shape. Nested Ixian Nexus replacement
|
||||
during the Bidding opening and other unsupported parent windows remain guarded.
|
||||
The ordering is an online interpretation of the printed timing, not a separate
|
||||
publisher priority ruling. Complete module and deployed acceptance remain open.
|
||||
|
||||
[Native runtime](../tests/richese-special-opening-runtime.test.ts) exercises
|
||||
both income outcomes, no Emperor, physical custody and prior passes. [Controls](../tests/richese-special-opening-controls.test.tsx)
|
||||
exercise the private button and legal bot continuation. [Semuta cases](../tests/richese-special-opening-semuta.test.ts)
|
||||
cover claiming or passing the spent Karama before the original purchase
|
||||
continues, and [receipt cases](../tests/richese-special-opening-receipt.test.ts)
|
||||
cover the opening and older income shapes.
|
||||
|
||||
### Richese Nexus pre-cost response — 25 October 2026
|
||||
|
||||
The supported Richese Betrayal preview now offers neutral acknowledgements
|
||||
|
||||
+15
-2
@@ -2728,7 +2728,10 @@ export type Game = {
|
||||
owner: string;
|
||||
turn: number;
|
||||
phase: number;
|
||||
resume: Pick<Game, 'response' | 'decision' | 'pendingKarama'>;
|
||||
resume: Pick<Game, 'response' | 'decision' | 'pendingKarama'> & {
|
||||
/** Present only when a newer purchase suspended an Ix phase opening. */
|
||||
phaseOpening?: Game['phaseOpening'];
|
||||
};
|
||||
} | null;
|
||||
pendingKarama?: {
|
||||
owner: string;
|
||||
@@ -27398,6 +27401,7 @@ function runOccupiedPercentageSuffix(g: Game, suffix: OccupiedPercentageSuffix)
|
||||
else if (suffix.kind === 'richesePurchase') {
|
||||
g.pendingRichesePurchaseIncome = null;
|
||||
g.response = suffix.resume.response; g.decision = suffix.resume.decision; g.pendingKarama = suffix.resume.pendingKarama;
|
||||
if (Object.hasOwn(suffix.resume, 'phaseOpening')) g.phaseOpening = suffix.resume.phaseOpening;
|
||||
} else if (suffix.kind === 'none') {
|
||||
g.decision = suffix.decision;
|
||||
}
|
||||
@@ -40066,6 +40070,7 @@ function finishResponse(g: Game, canceled: boolean, settlement?: BureaucratSettl
|
||||
g.response = resume.response;
|
||||
g.decision = resume.decision;
|
||||
g.pendingKarama = resume.pendingKarama;
|
||||
if (Object.hasOwn(resume, 'phaseOpening')) g.phaseOpening = resume.phaseOpening;
|
||||
} else if (response.kind === 'emperorIncome') {
|
||||
if (!canceled) {
|
||||
const owner = getPlayer(g, response.owner);
|
||||
@@ -42936,7 +42941,9 @@ export function prepareSpecialKaramaIntent(
|
||||
requireRule(!g.truthtrance, 'Resolve the current Truthtrance first.');
|
||||
if (p.faction !== 'choam') {
|
||||
requireRule(
|
||||
!g.phaseOpening,
|
||||
!g.phaseOpening || p.faction === 'richese' && g.expansions.includes('ix') &&
|
||||
!g.response && !g.decision && !g.pendingKarama && !g.pendingKull && !g.pendingTreacheryDiscard &&
|
||||
!(g.phase === 3 && g.nexusIxianReplacementPreview),
|
||||
'Play Amal or pass the phase opening before taking other actions.',
|
||||
);
|
||||
requireRule(
|
||||
@@ -43400,10 +43407,12 @@ function resolveSpecialKaramaEffect(g: Game, p: Player, card: Card, intent: Spec
|
||||
response: g.response,
|
||||
decision: g.decision,
|
||||
pendingKarama: g.pendingKarama ?? null,
|
||||
...(g.phaseOpening ? {phaseOpening: structuredClone(g.phaseOpening)} : {}),
|
||||
},
|
||||
};
|
||||
g.decision = null;
|
||||
g.pendingKarama = null;
|
||||
if (g.phaseOpening) g.phaseOpening = null;
|
||||
g.response = {
|
||||
kind: 'richesePurchaseIncome',
|
||||
owner: emperor.id,
|
||||
@@ -45412,6 +45421,10 @@ function applyActionInner(
|
||||
specialKarama(g, p, action);
|
||||
return g;
|
||||
}
|
||||
if (t === 'card' && action.mode === 'special' && p.faction === 'richese' && g.phaseOpening) {
|
||||
specialKarama(g, p, action);
|
||||
return g;
|
||||
}
|
||||
if (t === 'card' && choamSaleGholaTiming(g) &&
|
||||
p.hand.some((card) => card.id === action.card && card.effect === 'ghola')) {
|
||||
playMarketGhola(g, p, action);
|
||||
|
||||
@@ -622,6 +622,7 @@ export const RULE_TOPICS: RuleTopic[] = [
|
||||
'Spend a held Karama once per game to buy one private cache card for three own spice. An eligible Emperor Nexus joint option proves and retains that price while spending both cards at native purchase commit.',
|
||||
steps: [
|
||||
'In advanced development tables, Richese can use its special Karama once per game. Select an available Karama in your hand and one eligible card from your own cache. The activating Karama is discarded; the chosen card enters your hand secretly.',
|
||||
'In a supported clean Ix phase opening, this purchase can occur without abandoning earlier passes. If the Emperor is present, the opening waits while the separate income response is resolved; its existing passes then resume. Some optional-module combinations remain guarded.',
|
||||
'This is a purchase for Richese itself. Pay three of your available spice to Emperor when present, otherwise the bank. The general Emperor purchase-income rule supplies this payment destination. An ally receives no Harkonnen bonus or Ixian replacement from this direct cache acquisition.',
|
||||
'With Emperor absent, an actual unallied Emperor Nexus holder may use the private joint option after proving three own uncommitted spice. Original Karama and Nexus both spend at purchase commit, one exact cache card enters your hand and native once-use/capacity/reservations remain. No bank money, reimbursement, ally bonus or fake auction is created. The separate Betrayal preview may pause before those costs. This purchase composition is visibly provisional; ordinary paid use remains available.',
|
||||
'A Karama cannot cancel the special purchase itself. Emperor income has a separate response: canceling that income does not undo the purchase or restore the spent special power.',
|
||||
|
||||
@@ -174,6 +174,7 @@ export type RicheseCancellationContext = Pick<
|
||||
| 'turn'
|
||||
| 'phase'
|
||||
| 'advanced'
|
||||
| 'expansions'
|
||||
| 'players'
|
||||
| 'pendingRicheseGift'
|
||||
| 'richeseGiftBlocked'
|
||||
@@ -304,6 +305,10 @@ function calculate(
|
||||
g.players.some((p) => p.faction === 'richese'),
|
||||
'The canceled purchase income needs its original Emperor and three-spice receipt.',
|
||||
);
|
||||
if (object(value.resume) && Object.hasOwn(value.resume, 'phaseOpening'))
|
||||
requireRichese(g.expansions.includes('ix') && object(value.resume.phaseOpening) &&
|
||||
value.resume.response == null && value.resume.decision == null && value.resume.pendingKarama == null,
|
||||
'The suspended Richese purchase opening lost its original clean Ix window.');
|
||||
}
|
||||
};
|
||||
receipt(response, pending);
|
||||
@@ -349,7 +354,7 @@ function calculate(
|
||||
receipt(r, parent);
|
||||
const nested = new Set(nextPath);
|
||||
nested.add(parent);
|
||||
controls(parent.resume, r.kind === 'richeseGift', nested);
|
||||
controls(parent.resume, true, nested);
|
||||
}
|
||||
};
|
||||
followResponse(value.response);
|
||||
@@ -424,7 +429,7 @@ function calculate(
|
||||
'The suspended BG response has no conversion declaration.',
|
||||
);
|
||||
};
|
||||
controls(pending.resume, response.kind === 'richeseGift', new Set([pending]));
|
||||
controls(pending.resume, true, new Set([pending]));
|
||||
if (response.kind === 'richeseGift') {
|
||||
const gift = g.pendingRicheseGift!;
|
||||
const current =
|
||||
|
||||
@@ -92,11 +92,14 @@ void test('original Richese Nexus profiles compose, but unsupported full overlay
|
||||
independent.g.ecazTreachery = true;
|
||||
assert.equal(quoteEmperorNexusSpecialPurchase(independent.g, 'r').blocked, null,
|
||||
'The selected E1/E2 independent-card profile already supports native purchases.');
|
||||
const selected = original();
|
||||
selected.g.expansions = ['choam', 'ix', 'ecaz'];
|
||||
assert.equal(quoteEmperorNexusSpecialPurchase(selected.g, 'r').blocked, null,
|
||||
'Selected decks with the supported native roster retain the existing Nexus quote.');
|
||||
for (const change of [
|
||||
(g: Game) => { g.advancedPreview = true; },
|
||||
(g: Game) => { g.sandtrout = true; },
|
||||
(g: Game) => { g.nexusCards = undefined; },
|
||||
(g: Game) => { g.expansions = ['choam', 'ix', 'ecaz']; },
|
||||
]) {
|
||||
const { g, activation, acquire } = original();
|
||||
change(g);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
import { isValidElement, type ReactElement, type ReactNode } from 'react';
|
||||
import * as jsxRuntime from 'react/jsx-runtime';
|
||||
import ts from 'typescript';
|
||||
import { applyAction, createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { nextStrongholdFactionsNativeStep } from './fixture-stronghold-factions';
|
||||
import type { RicheseSpecialKarama } from '../components/richese-special-karama';
|
||||
|
||||
type Element = ReactElement<{children?:ReactNode; [key:string]:unknown}>;
|
||||
function elements(node:ReactNode): Element[] {
|
||||
if (Array.isArray(node)) return node.flatMap(elements);
|
||||
if (!isValidElement<{children?:ReactNode; [key:string]:unknown}>(node)) return [];
|
||||
return [node, ...elements(node.props.children)];
|
||||
}
|
||||
|
||||
/** Genuine Advanced native setup to the original Ix opening. A single held
|
||||
* card is exchanged with an existing physical Karama solely to exercise its
|
||||
* control; card inventory and all phase-opening state remain intact. */
|
||||
function opening(): Game {
|
||||
let game = createGame('RICHOPENCONTROL',newPlayer('r','Richese','richese'),true,['ix','choam']);
|
||||
joinGame(game,newPlayer('i','Ixians','ixians'));
|
||||
joinGame(game,newPlayer('e','Emperor','emperor'));
|
||||
for (const player of game.players) game = applyAction(game,player.id,{type:'ready'});
|
||||
game = applyAction(game,'r',{type:'start',advancedPreview:true});
|
||||
for (let count = 0; game.status === 'setup' && count < 200; count++) {
|
||||
const step = nextStrongholdFactionsNativeStep(game); assert.ok(step);
|
||||
game = applyAction(game,step.actor,step.action);
|
||||
}
|
||||
assert.equal(game.status,'playing'); assert.ok(game.phaseOpening);
|
||||
const owner = game.players.find(player => player.id === 'r')!;
|
||||
if (!owner.hand.some(card => card.effect === 'karama')) {
|
||||
const source = [game.deck,...game.players.filter(player => player.id !== owner.id).map(player => player.hand)]
|
||||
.find(cards => cards.some(card => card.effect === 'karama'));
|
||||
assert.ok(source); const index = source.findIndex(card => card.effect === 'karama');
|
||||
assert.ok(owner.hand.length); [owner.hand[0],source[index]] = [source[index],owner.hand[0]];
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
/** Render the actual stateful component with hooks isolated in a small test
|
||||
* harness, then invoke its original button callback. */
|
||||
function control(game: ReturnType<typeof viewGame>, busy = false) {
|
||||
const states:unknown[] = [], sent:Action[] = [];
|
||||
let cursor = 0;
|
||||
const exported:{RicheseSpecialKarama?:typeof RicheseSpecialKarama} = {};
|
||||
runInNewContext(ts.transpileModule(readFileSync(new URL('../components/richese-special-karama.tsx',import.meta.url),'utf8'), {
|
||||
compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,jsx:ts.JsxEmit.ReactJSX},
|
||||
}).outputText,{exports:exported,require(name:string) {
|
||||
if (name === 'react/jsx-runtime') return jsxRuntime;
|
||||
if (name === 'react') return {useId:() => 'test',useState(initial:unknown) {
|
||||
const index = cursor++; if (!(index in states)) states[index] = initial;
|
||||
return [states[index],(next:unknown) => {states[index] = next;}];
|
||||
}};
|
||||
if (name === './ui/button') return {Button:'button'};
|
||||
if (name === './card-inspector') return {CardInspector:'span',CardRules:'span'};
|
||||
throw Error(`Unexpected import ${name}`);
|
||||
}});
|
||||
assert.ok(exported.RicheseSpecialKarama);
|
||||
const render = () => {cursor = 0; return elements(exported.RicheseSpecialKarama!({game,busy,act(action) {sent.push(action);}}));};
|
||||
return {render,sent};
|
||||
}
|
||||
|
||||
void test('Richese sees and can submit the private special purchase during the original Ix opening', () => {
|
||||
const game = opening(), view = viewGame(game,'r'), original = structuredClone(game.phaseOpening);
|
||||
const quote = view.richeseSpecialKarama; assert.ok(quote && !quote.blocked);
|
||||
assert.ok(quote.karamas.length && quote.cards.length);
|
||||
const ui = control(view), button = ui.render().find(row => row.type === 'button');
|
||||
assert.ok(button); assert.equal(button.props.disabled,false);
|
||||
(button.props.onClick as () => void)();
|
||||
assert.deepEqual(JSON.parse(JSON.stringify(ui.sent)), [{type:'card',mode:'special',
|
||||
card:quote.karamas[0].id, acquire:quote.cards[0].id}]);
|
||||
const after = applyAction(game,'r',ui.sent[0]);
|
||||
assert.equal(after.players.find(player => player.id === 'r')!.specialKaramaUsed,true);
|
||||
assert.ok(after.response || after.phaseOpening);
|
||||
assert.deepEqual(after.response ? after.pendingRichesePurchaseIncome?.resume.phaseOpening : after.phaseOpening,original);
|
||||
assert.equal(viewGame(game,'i').richeseSpecialKarama,null);
|
||||
const locked = control(view,true).render().find(row => row.type === 'button');
|
||||
assert.ok(locked); assert.equal(locked.props.disabled,true);
|
||||
});
|
||||
|
||||
void test('each AI difficulty can continue the original opening without a strategic purchase', () => {
|
||||
const game = opening();
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(game,'r');
|
||||
view.players.find(player => player.id === 'r')!.bot = difficulty;
|
||||
const action = botActions(view)[0]; assert.deepEqual(action,{type:'ready'},difficulty);
|
||||
const after = applyAction(game,'r',action);
|
||||
assert.ok(after.phaseOpening?.passed.includes('r'));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, type Game, type ResponseWindow } from '../game/engine';
|
||||
import { quoteRicheseCancellation, RicheseCancellationError } from '../game/richese-cancellation';
|
||||
|
||||
/** Staged cancellation envelopes exercise the pure receipt validator only;
|
||||
* native purchase and cancel execution have their own gameplay cases. */
|
||||
function source(withOpening: boolean): {game: Game; response: ResponseWindow} {
|
||||
const game = createGame('RICHOPENRECEIPT',newPlayer('r','Richese','richese'),true,
|
||||
withOpening ? ['choam','ix'] : ['choam']);
|
||||
joinGame(game,newPlayer('e','Emperor','emperor'));
|
||||
joinGame(game,newPlayer('a','Atreides','atreides'));
|
||||
game.status = 'playing'; game.turn = 2; game.phase = 3;
|
||||
const response: ResponseWindow = {kind:'richesePurchaseIncome',owner:'e',amount:3,passed:['a']};
|
||||
game.response = response;
|
||||
game.pendingRichesePurchaseIncome = {owner:'e',turn:game.turn,phase:game.phase,
|
||||
resume:{response:null,decision:null,pendingKarama:null,
|
||||
...(withOpening ? {phaseOpening:{initialize:true,passed:['a']}} : {})}};
|
||||
return {game,response};
|
||||
}
|
||||
|
||||
void test('a parked clean Ix opening is returned unchanged by the purchase-income cancellation quote', () => {
|
||||
const {game,response} = source(true), before = structuredClone(game);
|
||||
const quote = quoteRicheseCancellation(game,response);
|
||||
assert.equal(quote?.kind,'richesePurchaseIncome');
|
||||
assert.deepEqual(quote?.resume,game.pendingRichesePurchaseIncome!.resume);
|
||||
assert.deepEqual(quote?.resume.phaseOpening,{initialize:true,passed:['a']});
|
||||
assert.deepEqual(game,before);
|
||||
const saved = JSON.parse(JSON.stringify(game)) as Game;
|
||||
assert.deepEqual(quoteRicheseCancellation(saved,saved.response!),quote);
|
||||
});
|
||||
|
||||
void test('legacy income receipts without a parked opening retain the original quoted shape', () => {
|
||||
const {game,response} = source(false), before = structuredClone(game);
|
||||
const quote = quoteRicheseCancellation(game,response);
|
||||
assert.equal(quote?.kind,'richesePurchaseIncome');
|
||||
assert.deepEqual(quote?.resume,{response:null,decision:null,pendingKarama:null});
|
||||
assert.equal(Object.hasOwn(quote!.resume,'phaseOpening'),false);
|
||||
assert.deepEqual(game,before);
|
||||
});
|
||||
|
||||
void test('invalid parked openings and mixed parent controls reject without changing the receipt', () => {
|
||||
const mutations: Array<(game: Game) => void> = [
|
||||
game => {game.expansions = ['choam'];},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.phaseOpening = null;},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.phaseOpening = {initialize:true,passed:['a','a']};},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.phaseOpening = {initialize:true,passed:['not-seated']};},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.phaseOpening = {initialize:'yes',passed:[]} as never;},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.response = {kind:'choamCharity',owner:'r',passed:[]};},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.decision = {kind:'auctionPayment',player:'a'};},
|
||||
game => {game.pendingRichesePurchaseIncome!.resume.pendingKarama = {owner:'a',use:{kind:'shipment',recipient:'a'}};},
|
||||
];
|
||||
for (const mutate of mutations) {
|
||||
const {game,response} = source(true); mutate(game);
|
||||
const before = structuredClone(game);
|
||||
assert.throws(() => quoteRicheseCancellation(game,response),RicheseCancellationError);
|
||||
assert.deepEqual(game,before);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Action, type Game } from '../game/engine';
|
||||
import { actTruthMovementNativeEarly as act, nextTruthMovementNativeEarlyStep } from './fixture-truth-movement-native-early';
|
||||
import { truthMovementInventory } from './fixture-truth-movement';
|
||||
|
||||
const player = (game:Game, id:string) => {
|
||||
const result = game.players.find(seat => seat.id === id); assert.ok(result); return result;
|
||||
};
|
||||
function advance(game:Game, until:(game:Game)=>boolean):Game {
|
||||
for (let n = 0; n < 500; n++) {
|
||||
if (until(game)) return game;
|
||||
const next = nextTruthMovementNativeEarlyStep(game); assert.ok(next);
|
||||
game = act(game,next.actor,next.action);
|
||||
}
|
||||
throw Error('The original native game did not reach its opening.');
|
||||
}
|
||||
|
||||
/** Native Advanced Richese/Ix setup. Select only original unopened starting
|
||||
* cards; after setup, swap conserved held cards if needed so Richese and a
|
||||
* non-Emperor responder hold the two actual Karama cards. */
|
||||
function source(emperor:boolean) {
|
||||
let game = createGame('RICHOPEN',newPlayer('r','Richese','richese'),true,['choam','ix']);
|
||||
joinGame(game,newPlayer('i','Ixians','ixians'));
|
||||
joinGame(game,newPlayer('a','Atreides','atreides'));
|
||||
if (emperor) joinGame(game,newPlayer('e','Emperor','emperor'));
|
||||
for (const seat of game.players) game = act(game,seat.id,{type:'ready'});
|
||||
game = act(game,'r',{type:'start',advancedPreview:true});
|
||||
const shield = game.deck.find(card => card.kind === 'shield'); assert.ok(shield);
|
||||
const karamas = game.deck.filter(card => card.effect === 'karama'); assert.ok(karamas.length >= 2);
|
||||
const ordinary = game.deck.find(card => card.kind === 'projectile'); assert.ok(ordinary);
|
||||
const initial = [shield,karamas[0],karamas[1],ordinary].slice(0,game.players.length);
|
||||
for (const [position,card] of initial.entries()) {
|
||||
const from = game.deck.findIndex(candidate => candidate.id === card.id); assert.ok(from >= position);
|
||||
[game.deck[position],game.deck[from]] = [game.deck[from],game.deck[position]];
|
||||
}
|
||||
game = advance(game,state => state.status === 'playing' && !!state.phaseOpening &&
|
||||
state.amalWindowOpen === true && !state.response && !state.decision);
|
||||
const held = (id:string) => player(game,id).hand;
|
||||
const assignKarama = (id:string, protectedSeat?:string) => {
|
||||
if (held(id).some(card => card.effect === 'karama')) return;
|
||||
const donor = game.players.find(seat => seat.id !== id && seat.id !== protectedSeat &&
|
||||
seat.hand.some(card => card.effect === 'karama')); assert.ok(donor);
|
||||
const from = donor.hand.findIndex(card => card.effect === 'karama');
|
||||
assert.ok(held(id).length > 0);
|
||||
[held(id)[0],donor.hand[from]] = [donor.hand[from],held(id)[0]];
|
||||
};
|
||||
assignKarama('r'); assignKarama('a','r');
|
||||
assert.ok(player(game,'r').spice >= 3);
|
||||
const card = held('r').find(row => row.effect === 'karama'); assert.ok(card);
|
||||
const acquire = game.richeseCache?.[0]; assert.ok(acquire);
|
||||
const canceledBy = held('a').find(row => row.effect === 'karama'); assert.ok(canceledBy);
|
||||
return {game,card:card.id,acquire:acquire.id,canceledBy:canceledBy.id};
|
||||
}
|
||||
const cached = new Map<boolean,ReturnType<typeof source>>();
|
||||
const fixture = (emperor:boolean) => {
|
||||
let item = cached.get(emperor); if (!item) {item = source(emperor); cached.set(emperor,item);}
|
||||
return {...item,game:structuredClone(item.game)};
|
||||
};
|
||||
const purchase = (card:string,acquire:string):Action =>
|
||||
({type:'card',mode:'special',card,acquire});
|
||||
|
||||
for (const emperor of [false,true]) void test(`Advanced Richese special purchase retains the Ix opening with Emperor ${emperor ? 'present' : 'absent'}`, () => {
|
||||
const f = fixture(emperor);
|
||||
const before = act(f.game,'i',{type:'ready'});
|
||||
const opening = structuredClone(before.phaseOpening), inventory = truthMovementInventory(before);
|
||||
const spice = player(before,'r').spice, emperorSpice = emperor ? player(before,'e').spice : 0;
|
||||
assert.ok(opening);
|
||||
assert.ok(opening.passed.includes('i'));
|
||||
assert.equal(viewGame(before,'r').richeseSpecialKarama?.blocked,null);
|
||||
let after = act(before,'r',purchase(f.card,f.acquire));
|
||||
assert.equal(player(after,'r').spice,spice - 3);
|
||||
assert.equal(player(after,'r').specialKaramaUsed,true);
|
||||
assert.ok(player(after,'r').hand.some(card => card.id === f.acquire));
|
||||
assert.ok(!after.richeseCache?.some(card => card.id === f.acquire));
|
||||
assert.deepEqual(truthMovementInventory(after),inventory);
|
||||
if (emperor) {
|
||||
assert.equal(after.response?.kind,'richesePurchaseIncome');
|
||||
after = advance(after,state => !!state.phaseOpening && !state.response && !state.decision);
|
||||
assert.equal(player(after,'e').spice,emperorSpice + 3);
|
||||
}
|
||||
assert.deepEqual(after.phaseOpening,opening);
|
||||
assert.equal(after.amalWindowOpen,true);
|
||||
assert.equal(viewGame(after,'i').players.find(seat => seat.id === 'r')!.hand,undefined);
|
||||
for (const seat of after.players.filter(seat => !opening.passed.includes(seat.id)))
|
||||
after = act(after,seat.id,{type:'ready'});
|
||||
assert.equal(after.phaseOpening,null);
|
||||
assert.ok(player(after,'r').hand.some(card => card.id === f.acquire));
|
||||
});
|
||||
|
||||
void test('preventing Emperor income preserves the purchased card and the exact Ix opening', () => {
|
||||
const f = fixture(true);
|
||||
const before = act(f.game,'i',{type:'ready'}), opening = structuredClone(before.phaseOpening);
|
||||
const richeseSpice = player(before,'r').spice, emperorSpice = player(before,'e').spice;
|
||||
let game = act(before,'r',purchase(f.card,f.acquire));
|
||||
assert.equal(game.response?.kind,'richesePurchaseIncome');
|
||||
game = act(game,'a',{type:'card',mode:'cancel',card:f.canceledBy});
|
||||
game = advance(game,state => !!state.phaseOpening && !state.response && !state.decision);
|
||||
assert.deepEqual(game.phaseOpening,opening);
|
||||
assert.equal(player(game,'r').spice,richeseSpice - 3);
|
||||
assert.equal(player(game,'e').spice,emperorSpice);
|
||||
assert.equal(player(game,'r').specialKaramaUsed,true);
|
||||
assert.ok(player(game,'r').hand.some(card => card.id === f.acquire));
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, initializeSemutaGameForAudit, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { nextStrongholdFactionsNativeStep } from './fixture-stronghold-factions';
|
||||
import { actTruthMovementNativeEarly as act, nextTruthMovementNativeEarlyStep } from './fixture-truth-movement-native-early';
|
||||
import { truthMovementInventory } from './fixture-truth-movement';
|
||||
import { moveSemutaEmperorCard, semutaEmperorCardId } from './fixture-semuta-emperor-share';
|
||||
import { reactSemutaSpecial } from './fixture-semuta-special-karama';
|
||||
|
||||
const player = (game:Game, id:string) => {
|
||||
const result = game.players.find(seat => seat.id === id); assert.ok(result); return result;
|
||||
};
|
||||
function advance(game:Game, until:(state:Game) => boolean):Game {
|
||||
for (let count = 0; count < 500; count++) {
|
||||
if (until(game)) return game;
|
||||
const step = nextTruthMovementNativeEarlyStep(game); assert.ok(step);
|
||||
game = act(game,step.actor,step.action);
|
||||
}
|
||||
throw Error('The original game did not return to its Ix opening.');
|
||||
}
|
||||
|
||||
/** Genuine Advanced native Semuta setup and Ix opening. Staging moves the
|
||||
* original Semuta and, if needed, an existing printed Karama between physical
|
||||
* zones to exercise its special discard and reaction. No opening, spice or
|
||||
* force state is installed by the fixture. */
|
||||
function source() {
|
||||
let game = createGame('RICHSEMUTAOPEN',newPlayer('r','Richese','richese'),true,['choam','ix']);
|
||||
joinGame(game,newPlayer('i','Ixians','ixians'));
|
||||
joinGame(game,newPlayer('a','Atreides','atreides'));
|
||||
joinGame(game,newPlayer('e','Emperor','emperor'));
|
||||
for (const seat of game.players) game = act(game,seat.id,{type:'ready'});
|
||||
game = initializeSemutaGameForAudit(game);
|
||||
for (let count = 0; game.status === 'setup' && count < 200; count++) {
|
||||
const step = nextStrongholdFactionsNativeStep(game); assert.ok(step);
|
||||
game = act(game,step.actor,step.action);
|
||||
}
|
||||
assert.equal(game.status,'playing'); assert.equal(game.phase,0);
|
||||
assert.ok(game.phaseOpening && game.amalWindowOpen);
|
||||
moveSemutaEmperorCard(game,SEMUTA_DRUG_ID,'a');
|
||||
let karama = player(game,'r').hand.find(card => card.effect === 'karama');
|
||||
if (!karama) {
|
||||
const id = semutaEmperorCardId(game,card => card.effect === 'karama');
|
||||
moveSemutaEmperorCard(game,id,'r');
|
||||
karama = player(game,'r').hand.find(card => card.id === id);
|
||||
}
|
||||
assert.ok(karama);
|
||||
const acquired = game.richeseCache?.find(card => card.id !== SEMUTA_DRUG_ID); assert.ok(acquired);
|
||||
return {game,karama:karama.id,acquired:acquired.id};
|
||||
}
|
||||
let cached:ReturnType<typeof source> | undefined;
|
||||
const fixture = () => {cached ??= source(); return {...cached,game:structuredClone(cached.game)};};
|
||||
|
||||
for (const claim of [false,true]) void test(`Semuta ${claim ? 'claims' : 'passes'} the Richese cost and restores the same Ix opening after Emperor income`, () => {
|
||||
const {game,karama,acquired} = fixture();
|
||||
const before = act(game,'i',{type:'ready'});
|
||||
const opening = structuredClone(before.phaseOpening), inventory = truthMovementInventory(before);
|
||||
const richeseSpice = player(before,'r').spice, emperorSpice = player(before,'e').spice;
|
||||
assert.ok(opening?.passed.includes('i'));
|
||||
assert.equal(viewGame(before,'r').richeseSpecialKarama?.blocked,null);
|
||||
let next = act(before,'r',{type:'card',mode:'special',card:karama,acquire:acquired});
|
||||
assert.equal(next.pendingTreacheryDiscard?.batch.cause,'specialKarama:richese');
|
||||
assert.deepEqual(next.pendingTreacheryDiscard?.continuation?.kind,'specialKaramaDiscard');
|
||||
assert.equal(next.phaseOpening,null);
|
||||
assert.equal(player(next,'r').spice,richeseSpice);
|
||||
assert.equal(player(next,'r').specialKaramaUsed,undefined);
|
||||
assert.ok(next.richeseCache?.some(card => card.id === acquired));
|
||||
next = reactSemutaSpecial(next,'a',claim);
|
||||
assert.equal(player(next,'r').spice,richeseSpice - 3);
|
||||
assert.equal(player(next,'r').specialKaramaUsed,true);
|
||||
assert.ok(player(next,'r').hand.some(card => card.id === acquired));
|
||||
assert.equal(player(next,'a').hand.some(card => card.id === karama),claim);
|
||||
if (next.response) next = advance(next,state => !!state.phaseOpening && !state.response && !state.decision);
|
||||
assert.deepEqual(next.phaseOpening,opening);
|
||||
assert.equal(next.amalWindowOpen,true);
|
||||
assert.equal(player(next,'e').spice,emperorSpice + 3);
|
||||
assert.deepEqual(truthMovementInventory(next),inventory);
|
||||
});
|
||||
Reference in new issue
Block a user