Allow Advanced Emperor gifts at Ix openings
Verify and publish checkpoint container / container (push) Successful in 11m25s
Verify and publish checkpoint container / container (push) Successful in 11m25s
This commit is contained in:
1 parent
53780c11d8
commit
181f16d7d7
7 files changed
+290
-4
No files matched your search
@@ -17,6 +17,14 @@ open mode gates.
|
|||||||
|
|
||||||
## Current checkpoint and work
|
## Current checkpoint and work
|
||||||
|
|
||||||
|
**Advanced Emperor gifts during Ix phase openings — 16 November. Prototyped /
|
||||||
|
Partial.** The existing clean-opening gift now also works in supported Advanced
|
||||||
|
games, retaining original passes, native cancellation and the human Emperor's
|
||||||
|
neutral opportunity before a final bot pass. Eight related offline files pass
|
||||||
|
38 cases, including Bene Gesserit's Worthless conversion; the production build
|
||||||
|
passes. Other nested timings and deployed acceptance remain open.
|
||||||
|
[Scope](EMPEROR_ALLIANCE_TIMING.md#advanced-emperor-gifts-at-ix-openings--16-november-2026).
|
||||||
|
|
||||||
**Advanced Richese special purchase during Ix phase openings — 16 November.
|
**Advanced Richese special purchase during Ix phase openings — 16 November.
|
||||||
Prototyped / Partial.** A clean opening retains its existing passes while the
|
Prototyped / Partial.** A clean opening retains its existing passes while the
|
||||||
original once-game purchase and any Emperor income response complete. Semuta
|
original once-game purchase and any Emperor income response complete. Semuta
|
||||||
|
|||||||
@@ -1,5 +1,26 @@
|
|||||||
# Emperor alliance gift timing
|
# Emperor alliance gift timing
|
||||||
|
|
||||||
|
## Advanced Emperor gifts at Ix openings — 16 November 2026
|
||||||
|
|
||||||
|
**Prototyped / Partial.** The user-authorized revised Advanced rules, physical
|
||||||
|
p. 31 / printed p. 29, permit Emperor to transfer spice to an ally at any time.
|
||||||
|
In a supported clean Ix phase opening, the existing gift now works in Advanced
|
||||||
|
games as well as Basic. An Emperor who already passed may still offer it;
|
||||||
|
allowing or canceling the original response restores the exact opening and its
|
||||||
|
passes. The human Emperor's neutral opportunity before a final automated pass
|
||||||
|
remains independent of private spice holdings. Online priority is a provisional
|
||||||
|
interpretation; optional modules and other nested windows remain subject to
|
||||||
|
their existing boundaries.
|
||||||
|
|
||||||
|
[Native cases](../tests/emperor-advanced-opening-gift-runtime.test.ts) cover
|
||||||
|
two different native allies, allowance, cancellation and subsequent Amal;
|
||||||
|
the setup is genuine and the reciprocal alliance and physical cards are staged.
|
||||||
|
[Controls and bots](../tests/emperor-advanced-opening-gift-controls.test.tsx)
|
||||||
|
cover the private gift control and the existing final-pass opportunity. A
|
||||||
|
[Bene Gesserit case](../tests/emperor-advanced-opening-gift-bg.test.ts) uses
|
||||||
|
Worthless to cancel the gift and resumes the same opening.
|
||||||
|
Complete mode and deployed acceptance remain open.
|
||||||
|
|
||||||
## Basic mixed-deck Emperor gifts at Ix openings — 16 November 2026
|
## Basic mixed-deck Emperor gifts at Ix openings — 16 November 2026
|
||||||
|
|
||||||
The existing Basic Ix opening gift and final-bot-pass opportunity now work
|
The existing Basic Ix opening gift and final-bot-pass opportunity now work
|
||||||
|
|||||||
+3
-3
@@ -30779,13 +30779,13 @@ function emperorPhaseOpeningGiftSignature(g: Game, opening: {passed: string[]; i
|
|||||||
return JSON.stringify([g.turn, g.phase, g.active, g.order, g.ready, g.amalWindowOpen ?? false,
|
return JSON.stringify([g.turn, g.phase, g.active, g.order, g.ready, g.amalWindowOpen ?? false,
|
||||||
opening, owner, recipient, amount]);
|
opening, owner, recipient, amount]);
|
||||||
}
|
}
|
||||||
/** Basic selected-deck Ix opening support, with no competing windows. */
|
/** Selected-deck Ix opening support, with no competing windows. */
|
||||||
function emperorPhaseOpeningGiftPublicEligible(g: Game, p: Player): boolean {
|
function emperorPhaseOpeningGiftPublicEligible(g: Game, p: Player): boolean {
|
||||||
if (g.advanced || g.status !== 'playing' || !g.expansions.includes('ix') || !selectedPhaseModuleRoster(g) ||
|
if (g.status !== 'playing' || !g.expansions.includes('ix') || !selectedPhaseModuleRoster(g) ||
|
||||||
g.techTokens || g.strongholdCards || g.leaderSkills || g.homeworlds ||
|
g.techTokens || g.strongholdCards || g.leaderSkills || g.homeworlds ||
|
||||||
g.discoveryEnabled || g.sandtrout || g.coalitionState ||
|
g.discoveryEnabled || g.sandtrout || g.coalitionState ||
|
||||||
!g.phaseOpening || !g.amalWindowOpen ||
|
!g.phaseOpening || !g.amalWindowOpen ||
|
||||||
g.response || g.decision || g.truthtrance || g.pendingKarama || g.pendingTreacheryDiscard || g.battle ||
|
g.response || g.decision || g.truthtrance || g.pendingKarama || g.pendingKull || g.pendingTreacheryDiscard || g.battle ||
|
||||||
g.pendingRicheseGift || g.pendingNullentropy || g.pendingShipment || g.pendingGuildTransport ||
|
g.pendingRicheseGift || g.pendingNullentropy || g.pendingShipment || g.pendingGuildTransport ||
|
||||||
g.pendingArrivalOverlap || g.pendingAmbassador || g.pendingEmperorAuctionGift || g.pendingNexusHarkonnenReplacement ||
|
g.pendingArrivalOverlap || g.pendingAmbassador || g.pendingEmperorAuctionGift || g.pendingNexusHarkonnenReplacement ||
|
||||||
p.faction !== 'emperor' || !p.ally ||
|
p.faction !== 'emperor' || !p.ally ||
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export const FACTION_RULES: Record<
|
|||||||
'Give spice directly to your ally. After the response window it is immediately spendable, unlike a deferred bribe between non-allies.',
|
'Give spice directly to your ally. After the response window it is immediately spendable, unlike a deferred bribe between non-allies.',
|
||||||
'In supported Basic ordinary auctions and Richese cache sales, including Nexus games, you may give your mutual ally spice after they win and before their original payment. Continue preserves the bid and pledged split; a canceled gift transfers nothing.',
|
'In supported Basic ordinary auctions and Richese cache sales, including Nexus games, you may give your mutual ally spice after they win and before their original payment. Continue preserves the bid and pledged split; a canceled gift transfers nothing.',
|
||||||
'In supported Moritani games, including Basic games with other selected faction decks, you may also give spice while your ally is choosing whether to pay Extortion. The original choice resumes after the gift’s Karama response.',
|
'In supported Moritani games, including Basic games with other selected faction decks, you may also give spice while your ally is choosing whether to pay Extortion. The original choice resumes after the gift’s Karama response.',
|
||||||
'In supported Basic games with the Ix deck and selected expansion factions, you may give an ally spice during the Amal phase opening, even after you have passed. The original opening resumes after the gift response. If a final automated pass would close it, a human Emperor may share or continue first.',
|
'In supported Basic and Advanced games with the Ix deck and selected expansion factions, you may give an ally spice during the Amal phase opening, even after you have passed. The original opening resumes after the gift response. If a final automated pass would close it, a human Emperor may share or continue first.',
|
||||||
'During Revival, pay two spice per extra allied force, up to three extra forces per turn. These are separate from the ally’s normal three-force allowance and may be purchased before or after ordinary revivals.',
|
'During Revival, pay two spice per extra allied force, up to three extra forces per turn. These are separate from the ally’s normal three-force allowance and may be purchased before or after ordinary revivals.',
|
||||||
'Spice gifts and extra revival uses have Karama response windows. Canceling a use spends neither the Emperor’s spice nor the extra-revival allowance.',
|
'Spice gifts and extra revival uses have Karama response windows. Canceling a use spends neither the Emperor’s spice nor the extra-revival allowance.',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { createGame, joinGame, newPlayer, type Game } from '../game/engine';
|
||||||
|
import { actTruthMovementNativeEarly as act } from './fixture-truth-movement-native-early';
|
||||||
|
import { nextStrongholdFactionsNativeStep as next } from './fixture-stronghold-factions';
|
||||||
|
import { truthTurnAmalInventory as inventory } from './fixture-truth-turn-amal';
|
||||||
|
|
||||||
|
const seat = (game: Game, id: string) => {
|
||||||
|
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Public Advanced Ix setup reaches its native opening. Only the reciprocal
|
||||||
|
* alliance and conserved original card custody are staged; the gift, BG
|
||||||
|
* conversion, passes, cancellation and opening continuation use real actions. */
|
||||||
|
void test('Advanced BG conversion cancels an opening gift and restores the original passes', () => {
|
||||||
|
let game = createGame('ADVOPENBG',newPlayer('emperor','Emperor','emperor'),true,['ix']);
|
||||||
|
joinGame(game,newPlayer('atreides','Atreides','atreides'));
|
||||||
|
joinGame(game,newPlayer('beneGesserit','Bene Gesserit','beneGesserit'));
|
||||||
|
for (const player of game.players) game = act(game,player.id,{type:'ready'});
|
||||||
|
game = act(game,'emperor',{type:'start',advancedPreview:true});
|
||||||
|
for (let count = 0; game.status === 'setup' && count < 100; count++) {
|
||||||
|
const step = next(game); assert.ok(step); game = act(game,step.actor,step.action);
|
||||||
|
}
|
||||||
|
assert.equal(game.status,'playing'); assert.ok(game.phaseOpening);
|
||||||
|
const original = inventory(game), emperor = seat(game,'emperor'), ally = seat(game,'atreides'), bg = seat(game,'beneGesserit');
|
||||||
|
emperor.ally = ally.id; ally.ally = emperor.id;
|
||||||
|
// Use real unique cards. Return a displaced card to the deck if needed.
|
||||||
|
const obtain = (owner: typeof bg, match: (card: typeof bg.hand[number]) => boolean) => {
|
||||||
|
const held = owner.hand.find(match); if (held) return held;
|
||||||
|
const index = game.deck.findIndex(match); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1);
|
||||||
|
if (owner.hand.length >= 4) game.deck.push(owner.hand.pop()!);
|
||||||
|
owner.hand.push(card); return card;
|
||||||
|
};
|
||||||
|
const worthless = obtain(bg,card => card.kind === 'worthless');
|
||||||
|
obtain(ally,card => card.effect === 'karama');
|
||||||
|
assert.deepEqual(inventory(game),original);
|
||||||
|
game = act(game,'emperor',{type:'ready'});
|
||||||
|
game = act(game,'atreides',{type:'ready'});
|
||||||
|
const opening = structuredClone(game.phaseOpening), emperorSpice = seat(game,'emperor').spice,
|
||||||
|
allySpice = seat(game,'atreides').spice;
|
||||||
|
let pending = act(game,'emperor',{type:'emperorGift',amount:2});
|
||||||
|
assert.equal(pending.response?.kind,'emperorGift');
|
||||||
|
pending = act(pending,'beneGesserit',{type:'card',card:worthless.id,mode:'cancel'});
|
||||||
|
assert.equal(pending.response?.kind,'worthlessKarama');
|
||||||
|
for (let count = 0; pending.response && count < 16; count++) {
|
||||||
|
const player = pending.players.find(row => !pending.response!.passed.includes(row.id)); assert.ok(player);
|
||||||
|
pending = act(pending,player.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(pending.response,null);
|
||||||
|
assert.deepEqual(pending.phaseOpening,opening);
|
||||||
|
assert.equal(seat(pending,'emperor').spice,emperorSpice);
|
||||||
|
assert.equal(seat(pending,'atreides').spice,allySpice);
|
||||||
|
assert.equal(pending.discard.filter(card => card.id === worthless.id).length,1);
|
||||||
|
assert.ok(!seat(pending,'beneGesserit').hand.some(card => card.id === worthless.id));
|
||||||
|
assert.deepEqual(inventory(pending),original);
|
||||||
|
pending = act(pending,'beneGesserit',{type:'ready'});
|
||||||
|
assert.equal(pending.phaseOpening,null);
|
||||||
|
});
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
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, runBots } from '../game/bots';
|
||||||
|
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||||
|
import { EmperorPhaseOpeningPriority } from '../components/emperor-phase-opening-priority';
|
||||||
|
import type { EmperorTimingGift } from '../components/emperor-timing-gift';
|
||||||
|
import { nextStrongholdFactionsNativeStep } from './fixture-stronghold-factions';
|
||||||
|
|
||||||
|
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)];
|
||||||
|
}
|
||||||
|
const act = (game:Game,id:string,action:Action) => applyAction(game,id,action);
|
||||||
|
const seat = (game:Game,id:string) => {
|
||||||
|
const player=game.players.find(row=>row.id===id); assert.ok(player); return player;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Genuine Advanced Ix setup and the original Storm opening. The mutual
|
||||||
|
* alliance is explicitly staged because the first opening precedes Nexus;
|
||||||
|
* moving any held Amal back to its deck conserves that physical card while
|
||||||
|
* making the final automated action deterministic. */
|
||||||
|
function opening(): Game {
|
||||||
|
let game=createGame('ADVOPENUI',newPlayer('e','Emperor','emperor'),true,['ix']);
|
||||||
|
joinGame(game,newPlayer('a','Atreides','atreides'));
|
||||||
|
joinGame(game,newPlayer('i','Ixians','ixians'));
|
||||||
|
for(const player of game.players) game=act(game,player.id,{type:'ready'});
|
||||||
|
game=act(game,'e',{type:'start',advancedPreview:true});
|
||||||
|
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.ok(game.phaseOpening);
|
||||||
|
seat(game,'e').ally='a'; seat(game,'a').ally='e';
|
||||||
|
const ixian=seat(game,'i');
|
||||||
|
for(const card of ixian.hand.filter(card=>card.effect==='amal')) game.deck.push(card);
|
||||||
|
ixian.hand=ixian.hand.filter(card=>card.effect!=='amal');
|
||||||
|
game=act(game,'e',{type:'ready'}); game=act(game,'a',{type:'ready'});
|
||||||
|
seat(game,'i').bot='Easy';
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Execute the actual stateful gift control and its callback using the same
|
||||||
|
* private engine projection as the table. */
|
||||||
|
function giftControl(game: ReturnType<typeof viewGame>, busy=false) {
|
||||||
|
const sent:Action[]=[];
|
||||||
|
const exported:{EmperorTimingGift?:typeof EmperorTimingGift}={};
|
||||||
|
runInNewContext(ts.transpileModule(readFileSync(new URL('../components/emperor-timing-gift.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)=>[initial,()=>{}]};
|
||||||
|
throw Error(`Unexpected import ${name}`);
|
||||||
|
}});
|
||||||
|
assert.ok(exported.EmperorTimingGift);
|
||||||
|
const nodes=elements(exported.EmperorTimingGift({game,busy,act(action) {sent.push(action);}}));
|
||||||
|
return {sent,button:nodes.find(row=>row.type==='button')};
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishGift(game:Game) {
|
||||||
|
for(let count=0;game.response&&count<20;count++) {
|
||||||
|
const responder=game.players.find(player=>!game.response!.passed.includes(player.id)); assert.ok(responder);
|
||||||
|
game=act(game,responder.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.response,null); return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test('Advanced opening offers the owner gift control and retains the final bot turn',()=>{
|
||||||
|
let game=opening(); const original=structuredClone(game.phaseOpening);
|
||||||
|
const view=viewGame(game,'e'), quote=view.emperorPhaseOpeningGift, priority=view.emperorPhaseOpeningPriority;
|
||||||
|
assert.ok(quote); assert.equal(quote.recipient,'a'); assert.ok(priority?.canContinue);
|
||||||
|
assert.equal(viewGame(game,'a').emperorPhaseOpeningGift,null);
|
||||||
|
assert.equal(viewGame(game,'i').emperorPhaseOpeningGift,null);
|
||||||
|
const ui=giftControl(view); assert.ok(ui.button); assert.equal(ui.button.props.disabled,false);
|
||||||
|
(ui.button.props.onClick as ()=>void)(); assert.deepEqual(JSON.parse(JSON.stringify(ui.sent)),[{type:'emperorGift',amount:1}]);
|
||||||
|
const disabled=giftControl(view,true); assert.equal(disabled.button?.props.disabled,true);
|
||||||
|
const priorityActions:Action[]=[];
|
||||||
|
const priorityPanel=EmperorPhaseOpeningPriority({game:view,busy:false,act:action=>priorityActions.push(action)});
|
||||||
|
assert.ok(priorityPanel); const continueButton=elements(priorityPanel).find(row=>row.type==='button'); assert.ok(continueButton);
|
||||||
|
(continueButton.props.onClick as ()=>void)();
|
||||||
|
assert.deepEqual(priorityActions,[{type:'emperorPhaseOpeningContinue',event:priority.event}]);
|
||||||
|
for(const difficulty of DIFFICULTIES) {
|
||||||
|
const projected=viewGame(game,'i'); seat(projected as unknown as Game,'i').bot=difficulty;
|
||||||
|
assert.ok(!botActions(projected).some(action=>action.type==='ready'),difficulty);
|
||||||
|
}
|
||||||
|
assert.deepEqual(runBots(game,4).phaseOpening,original);
|
||||||
|
const emperor=seat(game,'e').spice, ally=seat(game,'a').spice;
|
||||||
|
game=finishGift(act(game,'e',ui.sent[0]));
|
||||||
|
assert.equal(seat(game,'e').spice,emperor-1); assert.equal(seat(game,'a').spice,ally+1);
|
||||||
|
assert.deepEqual(game.phaseOpening,original);
|
||||||
|
const current=viewGame(game,'e').emperorPhaseOpeningPriority; assert.ok(current?.canContinue);
|
||||||
|
game=act(game,'e',{type:'emperorPhaseOpeningContinue',event:current.event});
|
||||||
|
const next=botActions(viewGame(game,'i')).find(action=>action.type==='ready'); assert.ok(next);
|
||||||
|
game=act(game,'i',next); assert.equal(game.phaseOpening,null);
|
||||||
|
});
|
||||||
|
|
||||||
|
void test('zero private spice does not alter another seat’s Advanced opening priority',()=>{
|
||||||
|
const funded=opening(), empty=structuredClone(funded);
|
||||||
|
// Controlled wallet supplement isolates the hidden affordability check; the
|
||||||
|
// native opening and all other projected fields remain unchanged.
|
||||||
|
seat(empty,'e').spice=0;
|
||||||
|
assert.equal(viewGame(empty,'e').emperorPhaseOpeningGift,null);
|
||||||
|
assert.ok(viewGame(funded,'e').emperorPhaseOpeningGift);
|
||||||
|
assert.deepEqual(viewGame(empty,'i').emperorPhaseOpeningPriority,viewGame(funded,'i').emperorPhaseOpeningPriority);
|
||||||
|
const view=viewGame(empty,'e'), priority=view.emperorPhaseOpeningPriority; assert.ok(priority?.canContinue);
|
||||||
|
const panel=EmperorPhaseOpeningPriority({game:view,busy:false,act() {}}); assert.ok(panel);
|
||||||
|
const next=act(empty,'e',{type:'emperorPhaseOpeningContinue',event:priority.event});
|
||||||
|
assert.ok(botActions(viewGame(next,'i')).some(action=>action.type==='ready'));
|
||||||
|
});
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||||
|
import { actTruthMovementNativeEarly as act } from './fixture-truth-movement-native-early';
|
||||||
|
import { nextStrongholdFactionsNativeStep as next } from './fixture-stronghold-factions';
|
||||||
|
import { truthTurnAmalInventory as inventory } from './fixture-truth-turn-amal';
|
||||||
|
|
||||||
|
const seat = (game:Game, id:string) => {
|
||||||
|
const player = game.players.find(row => row.id === id); assert.ok(player); return player;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Public Advanced Ix setup reaches its original opening. The reciprocal
|
||||||
|
* alliance and physical Amal/Karama custody are explicitly staged afterward;
|
||||||
|
* the opening, passes, gift, cancellation and continuation are native. */
|
||||||
|
function fixture(recipient:'ixians'|'tleilaxu') {
|
||||||
|
let game = createGame('ADVEMPOPEN',newPlayer('emperor','Emperor','emperor'),true,['ix']);
|
||||||
|
for (const id of ['ixians','tleilaxu','atreides'] as const) joinGame(game,newPlayer(id,id,id));
|
||||||
|
for (const player of game.players) game = act(game,player.id,{type:'ready'});
|
||||||
|
game = act(game,'emperor',{type:'start',advancedPreview:true});
|
||||||
|
for (let count = 0; game.status === 'setup' && count < 100; count++) {
|
||||||
|
const step = next(game); assert.ok(step);
|
||||||
|
game = act(game,step.actor,step.action);
|
||||||
|
}
|
||||||
|
assert.equal(game.status,'playing'); assert.ok(game.phaseOpening);
|
||||||
|
const original = inventory(game);
|
||||||
|
seat(game,'emperor').ally = recipient; seat(game,recipient).ally = 'emperor';
|
||||||
|
for (const player of game.players) {
|
||||||
|
const cards = player.hand.filter(card => card.effect === 'amal' || card.effect === 'karama');
|
||||||
|
player.hand = player.hand.filter(card => card.effect !== 'amal' && card.effect !== 'karama');
|
||||||
|
game.deck.push(...cards);
|
||||||
|
}
|
||||||
|
const transfer = (effect:'amal'|'karama') => {
|
||||||
|
const index = game.deck.findIndex(card => card.effect === effect); assert.ok(index >= 0);
|
||||||
|
const [card] = game.deck.splice(index,1); seat(game,'atreides').hand.push(card); return card.id;
|
||||||
|
};
|
||||||
|
const amal = transfer('amal'), counter = transfer('karama');
|
||||||
|
assert.deepEqual(inventory(game),original);
|
||||||
|
game = act(game,'emperor',{type:'ready'});
|
||||||
|
game = act(game,recipient,{type:'ready'});
|
||||||
|
assert.deepEqual(game.phaseOpening?.passed,['emperor',recipient]);
|
||||||
|
return {game,amal,counter,original};
|
||||||
|
}
|
||||||
|
|
||||||
|
function passResponse(game:Game):Game {
|
||||||
|
for (let count = 0; game.response && count < 16; count++) {
|
||||||
|
const player = game.players.find(row => !game.response!.passed.includes(row.id)); assert.ok(player);
|
||||||
|
game = act(game,player.id,{type:'passResponse'});
|
||||||
|
}
|
||||||
|
assert.equal(game.response,null);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const recipient of ['ixians','tleilaxu'] as const) for (const canceled of [false,true])
|
||||||
|
void test(`Advanced ${recipient} opening gift ${canceled ? 'cancellation' : 'allowance'} preserves the parent and later Amal`,() => {
|
||||||
|
const f = fixture(recipient), opening = structuredClone(f.game.phaseOpening);
|
||||||
|
const owner = seat(f.game,'emperor').spice, ally = seat(f.game,recipient).spice;
|
||||||
|
const phase = f.game.phase, turn = f.game.turn;
|
||||||
|
assert.deepEqual(viewGame(f.game,'emperor').emperorPhaseOpeningGift,{recipient,maximum:owner});
|
||||||
|
assert.equal(viewGame(f.game,recipient).emperorPhaseOpeningGift,null);
|
||||||
|
assert.equal(viewGame(f.game,'atreides').emperorPhaseOpeningGift,null);
|
||||||
|
let game = act(f.game,'emperor',{type:'emperorGift',amount:3});
|
||||||
|
assert.equal(game.response?.kind,'emperorGift'); assert.equal(game.phaseOpening,null);
|
||||||
|
assert.equal(viewGame(game,'atreides').response?.amount,undefined);
|
||||||
|
assert.equal(seat(game,'emperor').spice,owner); assert.equal(seat(game,recipient).spice,ally);
|
||||||
|
game = canceled ? act(game,'atreides',{type:'card',card:f.counter,mode:'cancel'}) : passResponse(game);
|
||||||
|
assert.equal(game.response,null); assert.deepEqual(game.phaseOpening,opening);
|
||||||
|
assert.equal(game.phase,phase); assert.equal(game.turn,turn);
|
||||||
|
assert.equal(seat(game,'emperor').spice,owner - (canceled ? 0 : 3));
|
||||||
|
assert.equal(seat(game,recipient).spice,ally + (canceled ? 0 : 3));
|
||||||
|
assert.equal(game.discard.filter(card => card.id === f.counter).length,Number(canceled));
|
||||||
|
assert.throws(() => act(game,'atreides',{type:'passResponse'}));
|
||||||
|
const wallets = game.players.map(player => player.spice);
|
||||||
|
game = act(game,'atreides',{type:'card',card:f.amal});
|
||||||
|
assert.deepEqual(game.players.map(player => player.spice),wallets.map(amount => Math.floor(amount / 2)));
|
||||||
|
assert.deepEqual(game.phaseOpening?.passed,[]);
|
||||||
|
assert.equal(game.discard.filter(card => card.id === f.amal).length,1);
|
||||||
|
for (const player of game.players) game = act(game,player.id,{type:'ready'});
|
||||||
|
assert.equal(game.phaseOpening,null); assert.equal(game.phase,phase); assert.equal(game.turn,turn);
|
||||||
|
assert.deepEqual(game.players.map(player => player.spice),wallets.map(amount => Math.floor(amount / 2)));
|
||||||
|
assert.throws(() => act(game,'atreides',{type:'card',card:f.amal}));
|
||||||
|
assert.deepEqual(inventory(game),f.original);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user