Support Revival answers with Richese Semuta
Verify and publish checkpoint container / container (push) Successful in 10m31s
Verify and publish checkpoint container / container (push) Successful in 10m31s
This commit is contained in:
1 parent
2eaaab876e
commit
4dfdd500e0
14 files changed
+540
-15
No files matched your search
@@ -36,9 +36,9 @@ void test('Basic Kull and Semuta expose the bribe family only in the supported n
|
||||
}
|
||||
});
|
||||
|
||||
void test('admitting bribes does not silently enable unrelated Semuta promise families', () => {
|
||||
void test('Basic Semuta retains separate alliance and bid boundaries', () => {
|
||||
assert.equal(alliancePromiseModeSupported(profile),false);
|
||||
assert.equal(revivalPromiseModeSupported(profile),false);
|
||||
assert.equal(revivalPromiseModeSupported(profile),true);
|
||||
assert.equal(bidPromiseModeSupported(profile),false);
|
||||
assert.equal(currentBidPromiseModeSupported(profile),true);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { handLimit, viewGame, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { act, finishRevival, inventory, player } from './fixture-kull-revival-semuta';
|
||||
import { createSemutaRevivalBenefitsForcesFixture } from './fixture-semuta-revival-benefits-forces';
|
||||
|
||||
/** The native source purchases Semuta, ships four forces and loses them to
|
||||
* Storm before this real Revival opportunity. As in the existing Kull
|
||||
* Semuta fixture, only original physical cards are reassigned among zones;
|
||||
* no phase, wallet, force, promise, response or pending revival is installed. */
|
||||
let nativeSource: ReturnType<typeof createSemutaRevivalBenefitsForcesFixture> | undefined;
|
||||
function fixture(answer: 'yes' | 'no' = 'yes') {
|
||||
const source = nativeSource ??= createSemutaRevivalBenefitsForcesFixture({kind:'choamRevival', advanced:false});
|
||||
let game = structuredClone(source.beforeRevival);
|
||||
assert.ok(game.kullPreview && game.semutaPreview);
|
||||
const originalCards = inventory(game);
|
||||
const zones = [game.deck, game.discard, ...(game.richeseCache ? [game.richeseCache] : []),
|
||||
...(game.richeseRemoved ? [game.richeseRemoved] : []), ...game.players.map(seat => seat.hand)];
|
||||
const move = (id:string, recipient:string) => {
|
||||
const zone = zones.find(cards=>cards.some(card=>card.id === id)); assert.ok(zone, id);
|
||||
const [card] = zone.splice(zone.findIndex(row=>row.id === id),1);
|
||||
const seat = player(game,recipient); assert.ok(seat.hand.length < handLimit(seat));
|
||||
seat.hand.push(card);
|
||||
};
|
||||
move(SEMUTA_DRUG_ID, 'richese');
|
||||
move('ix-kull-wahad', 'choam');
|
||||
const truth = zones.flat().find(card=>card.effect === 'truthtrance'); assert.ok(truth);
|
||||
move(truth.id, 'atreides');
|
||||
const counter = zones.flat().find(card=>card.effect === 'karama' && card.id !== source.cost &&
|
||||
!card.id.startsWith('richese-')); assert.ok(counter);
|
||||
move(counter.id, 'tleilaxu');
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
assert.equal(player(game,'choam').tanks,4);
|
||||
game = act(game,'atreides',{type:'card',card:truth.id});
|
||||
while (game.truthtrance?.stage === 'priority') {
|
||||
const next = game.players.find(seat=>!game.truthtrance!.passed.includes(seat.id)); assert.ok(next);
|
||||
game = act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
game = act(game,'atreides',{type:'truthAsk',question:{kind:'revival',target:'choam',
|
||||
turn:game.turn,counter:'total',minimum:3}});
|
||||
assert.ok(viewGame(game,'choam').truthRevivalAnswers?.includes(answer));
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(game,'choam'); view.players.find(seat=>seat.id === 'choam')!.bot = difficulty;
|
||||
const action = botActions(view)[0]; assert.ok(action,difficulty);
|
||||
assert.equal(action.type,'truthAnswer',difficulty);
|
||||
assert.ok(view.truthRevivalAnswers?.includes(action.answer as 'yes'|'no'),difficulty);
|
||||
assert.doesNotThrow(()=>act(game,'choam',action),difficulty);
|
||||
}
|
||||
game = act(game,'choam',{type:'truthAnswer',answer});
|
||||
const promise = game.revivalPromises!.find(row=>row.player === 'choam'); assert.ok(promise);
|
||||
// Pass the physical Truthtrance's Semuta reaction, retaining Semuta for the
|
||||
// subsequent Kull or counter discard.
|
||||
if (game.pendingTreacheryDiscard) game = semuta(game,truth.id,false);
|
||||
assert.ok(game.revivalPromises?.some(row=>row.event === promise.event && !row.released));
|
||||
return {game,source,originalCards,event:promise.event,kull:'ix-kull-wahad',
|
||||
karama:source.cost,counter:counter.id};
|
||||
}
|
||||
|
||||
function semuta(game:Game, card:string, claim:boolean):Game {
|
||||
const pending = game.pendingTreacheryDiscard; assert.ok(pending);
|
||||
assert.equal(pending.reaction?.stage,'offer');
|
||||
assert.equal(pending.batch.entries[0].card.id,card);
|
||||
const event = pending.batch.event;
|
||||
if (claim) {
|
||||
assert.equal(viewGame(game,'richese').semutaReaction?.canCommit,true);
|
||||
game = act(game,'richese',{type:'semutaCommit',event});
|
||||
if (game.pendingTreacheryDiscard?.reaction?.stage === 'select')
|
||||
game = act(game,'richese',{type:'semutaSelect',event,card});
|
||||
} else {
|
||||
for (let count=0;game.pendingTreacheryDiscard?.batch.event === event && count<game.players.length;count++) {
|
||||
const reaction = game.pendingTreacheryDiscard!.reaction; assert.ok(reaction?.stage === 'offer');
|
||||
const next = game.players.find(seat=>!reaction.passed.includes(seat.id)); assert.ok(next);
|
||||
game = act(game,next.id,{type:'semutaPass',event});
|
||||
}
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
|
||||
function pending(f:ReturnType<typeof fixture>) {
|
||||
let game = f.game;
|
||||
const guide = viewGame(game,'choam').revivalPromiseGuide; assert.ok(guide);
|
||||
assert.equal(guide.action.type,'revive'); assert.equal(guide.action.amount,3);
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(game,'choam'); view.players.find(seat=>seat.id === 'choam')!.bot = difficulty;
|
||||
const action = botActions(view).find(row=>row.revivalPromiseEvent === guide.action.revivalPromiseEvent);
|
||||
assert.ok(action,difficulty); assert.doesNotThrow(()=>act(game,'choam',action),difficulty);
|
||||
}
|
||||
game = act(game,'choam',guide.action);
|
||||
for (let count=0;count<20 && game.response?.kind !== 'choamRevival';count++) {
|
||||
if (game.decision?.kind === 'revivalStop' || game.decision?.kind === 'choamFreeRevival')
|
||||
game = act(game,game.decision.player,{type:'decision',decline:true});
|
||||
else throw Error('The original revival did not reach its native benefit response.');
|
||||
}
|
||||
assert.equal(game.response?.kind,'choamRevival'); assert.ok(game.pendingRevival);
|
||||
game = act(game,'emperor',{type:'card',mode:'cancel',card:f.karama});
|
||||
assert.equal(game.pendingKull?.stage,'offer');
|
||||
const reaction = viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
game = act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
assert.equal(game.pendingKull?.stage,'counter');
|
||||
return game;
|
||||
}
|
||||
|
||||
for (const claim of [false,true]) void test(`Revival Yes survives Kull success and Semuta ${claim?'claim':'pass'}`,()=>{
|
||||
const f = fixture(); let game = pending(f);
|
||||
const promise = structuredClone(game.revivalPromises!.find(row=>row.event === f.event)); assert.ok(promise);
|
||||
for (let count=0;count<game.players.length && !game.pendingTreacheryDiscard;count++) {
|
||||
assert.ok(game.response); const next = game.players.find(seat=>!game.response!.passed.includes(seat.id)); assert.ok(next);
|
||||
game = act(game,next.id,{type:'passResponse'});
|
||||
}
|
||||
assert.deepEqual(game.revivalPromises!.find(row=>row.event === f.event),promise);
|
||||
game = semuta(game,f.kull,claim);
|
||||
game = finishRevival(game);
|
||||
assert.equal(game.revivalPromises!.find(row=>row.event === f.event)?.fulfilled,true);
|
||||
assert.equal(player(game,'choam').tanks,1);
|
||||
assert.equal(player(game,'richese').hand.some(card=>card.id === f.kull),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
for (const claim of [false,true]) void test(`Revival Yes survives Kull counter and Semuta ${claim?'claim':'pass'}`,()=>{
|
||||
const f = fixture(); let game = pending(f);
|
||||
assert.ok(viewGame(game,'tleilaxu').responseControls?.cancelCards.includes(f.counter));
|
||||
game = act(game,'tleilaxu',{type:'card',mode:'cancel',card:f.counter});
|
||||
assert.ok(!game.revivalPromises!.find(row=>row.event === f.event)?.released);
|
||||
game = semuta(game,f.counter,claim);
|
||||
if (game.pendingTreacheryDiscard) game = semuta(game,f.karama,false);
|
||||
game = finishRevival(game);
|
||||
assert.equal(game.revivalPromises!.find(row=>row.event === f.event)?.fulfilled,true);
|
||||
assert.equal(player(game,'choam').tanks,1);
|
||||
assert.equal(player(game,'richese').hand.some(card=>card.id === f.counter),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
void test('Revival No retains its cap in the Kull and Richese profile',()=>{
|
||||
const f = fixture('no');
|
||||
const before = structuredClone(f.game);
|
||||
assert.throws(()=>act(f.game,'choam',{type:'revive',amount:3,elite:0}));
|
||||
assert.deepEqual(f.game,before);
|
||||
assert.ok(!f.game.revivalPromises!.find(row=>row.event === f.event)?.released);
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { alliancePromiseModeSupported } from '../game/alliance-promises';
|
||||
import { revivalPromiseModeSupported } from '../game/revival-promises';
|
||||
import { leaderRevivalPromiseModeSupported } from '../game/leader-revival-promises';
|
||||
import { revivalExpressionPromiseModeSupported } from '../game/revival-expression-promises';
|
||||
import { createGame, joinGame, newPlayer, viewGame } from '../game/engine';
|
||||
import { act, advance, clean, createKullRicheseSemutaFixture } from './fixture-kull-richese-semuta';
|
||||
|
||||
const profile = {
|
||||
advanced: false, expansions: ['choam', 'ix'], kullPreview: true, semutaPreview: true,
|
||||
players: [{faction:'choam'}, {faction:'richese'}, {faction:'emperor'}, {faction:'harkonnen'}],
|
||||
};
|
||||
|
||||
void test('Basic Richese admits each Revival family with and without printed Kull', () => {
|
||||
for (const quote of [revivalPromiseModeSupported, leaderRevivalPromiseModeSupported,
|
||||
revivalExpressionPromiseModeSupported]) {
|
||||
assert.equal(quote(profile), true);
|
||||
assert.equal(quote({...profile, kullPreview:false}), true);
|
||||
assert.equal(quote({...profile, expansions:['ix','choam']}), true);
|
||||
assert.equal(quote({...profile, expansions:['choam','ix','ecaz'],
|
||||
players:[...profile.players,{faction:'ecaz'},{faction:'moritani'}]}), true);
|
||||
for (const unsupported of [
|
||||
{...profile, advanced:true},
|
||||
{...profile, expansions:['choam']},
|
||||
{...profile, expansions:['choam','ix','ix']},
|
||||
{...profile, players:profile.players.filter(player=>player.faction!=='choam')},
|
||||
{...profile, players:profile.players.filter(player=>player.faction!=='richese')},
|
||||
{...profile, players:[...profile.players,{faction:'ecaz'}]},
|
||||
{...profile, players:[...profile.players,{faction:'richese'}]},
|
||||
]) assert.equal(quote(unsupported),false);
|
||||
for (const key of ['homeworlds','nexusCards','leaderSkills','techTokens','strongholdCards',
|
||||
'discoveryEnabled','nexusKullPreview','richeseBetrayalPreview','guildBetrayalPreview',
|
||||
'nexusIxianReplacementPreview','nexusIxianBetrayalPreview','nexusHarkonnenBetrayalPreview',
|
||||
'moritaniAssassinatePreview'] as const)
|
||||
assert.equal(quote({...profile,[key]:true}),false,key);
|
||||
}
|
||||
assert.equal(alliancePromiseModeSupported(profile),false);
|
||||
assert.equal(alliancePromiseModeSupported({...profile,kullPreview:false}),false);
|
||||
});
|
||||
|
||||
function assertRevivalTargets(game: ReturnType<typeof createGame>) {
|
||||
const view = viewGame(game,'emperor');
|
||||
assert.ok(view.truthRevivalTargets.includes('harkonnen'));
|
||||
assert.ok(view.truthLeaderRevivalTargets.includes('harkonnen'));
|
||||
assert.ok(view.truthRevivalExpressionTargets.includes('harkonnen'));
|
||||
assert.ok(view.truthMixedRevivalTargets.includes('harkonnen'));
|
||||
assert.deepEqual(view.truthAllianceTargets,[]);
|
||||
}
|
||||
|
||||
void test('a real Basic Kull and Richese start projects all Revival question families', () => {
|
||||
const {acquired} = createKullRicheseSemutaFixture();
|
||||
assert.ok(acquired.kullPreview && acquired.semutaPreview);
|
||||
assert.equal(acquired.phase,3);
|
||||
assertRevivalTargets(acquired);
|
||||
});
|
||||
|
||||
void test('a real Basic Richese start with Kull switched off projects the same Revival questions', () => {
|
||||
let game = createGame('SEMUTAREVIVALSCOPE',newPlayer('choam','CHOAM','choam'),false,['choam','ix']);
|
||||
for (const id of ['richese','emperor','harkonnen'] as const) joinGame(game,newPlayer(id,id,id));
|
||||
game = act(game,'choam',{type:'moduleOption',module:'kullPreview',enabled:false});
|
||||
for (const seat of game.players) game = act(game,seat.id,{type:'ready'});
|
||||
game = act(game,'choam',{type:'start'});
|
||||
game = advance(game,state=>state.status==='playing' && clean(state));
|
||||
assert.ok(!game.kullPreview);
|
||||
assert.equal(game.semutaPreview,true);
|
||||
assertRevivalTargets(game);
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { registerHooks } from 'node:module';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createElement } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { handLimit, viewGame, type Action, type GameView } from '../game/engine';
|
||||
import { act, finishRevival, inventory, player } from './fixture-kull-revival-semuta';
|
||||
import { createSemutaRevivalBenefitsForcesFixture } from './fixture-semuta-revival-benefits-forces';
|
||||
|
||||
const aliases = registerHooks({
|
||||
resolve(specifier, context, next) {
|
||||
return next(specifier === 'next/image' ? 'vinext/shims/image' :
|
||||
specifier === 'next/link' ? 'vinext/shims/link' : specifier, context);
|
||||
},
|
||||
load(url, context, next) {
|
||||
if (!url.endsWith('.module.css')) return next(url, context);
|
||||
const css = readFileSync(new URL(url),'utf8');
|
||||
const classes = Object.fromEntries([...css.matchAll(/\.([a-zA-Z_][\w-]*)/g)].map(match => [match[1],match[1]]));
|
||||
return {format:'module',source:`export default ${JSON.stringify(classes)}`,shortCircuit:true};
|
||||
},
|
||||
});
|
||||
const {GameTable} = await import('../components/game-table');
|
||||
const {Truthtrance} = await import('../components/truthtrance');
|
||||
const {RevivalPromiseGuideButton} = await import('../components/revival-promises');
|
||||
aliases.deregister();
|
||||
|
||||
const table = (game:GameView) => renderToStaticMarkup(createElement(GameTable,
|
||||
{game,busy:false,send:async () => {},onExit() {}}));
|
||||
const truth = (game:GameView) => renderToStaticMarkup(createElement(Truthtrance,
|
||||
{game,busy:false,act() {}}));
|
||||
|
||||
/** The native Basic source actually buys Semuta, ships four CHOAM forces and
|
||||
* loses them to Storm. Only an original physical Truthtrance is reassigned to
|
||||
* the asker; no phase, force, purse, pending decision or promise is installed. */
|
||||
void test('the Kull and Richese table renders a real Revival question, answer and owned return guide',()=>{
|
||||
const source = createSemutaRevivalBenefitsForcesFixture({kind:'choamRevival',advanced:false});
|
||||
let game = structuredClone(source.beforeRevival);
|
||||
assert.ok(game.kullPreview && game.semutaPreview);
|
||||
assert.equal(player(game,'choam').tanks,4);
|
||||
const originalCards = inventory(game);
|
||||
const zones = [game.deck,game.discard,...(game.richeseCache ? [game.richeseCache] : []),
|
||||
...(game.richeseRemoved ? [game.richeseRemoved] : []),...game.players.map(seat=>seat.hand)];
|
||||
const zone = zones.find(cards=>cards.some(card=>card.effect === 'truthtrance')); assert.ok(zone);
|
||||
const [card] = zone.splice(zone.findIndex(row=>row.effect === 'truthtrance'),1);
|
||||
const asker = player(game,'atreides'); assert.ok(asker.hand.length < handLimit(asker));
|
||||
asker.hand.push(card);
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
|
||||
game = act(game,'atreides',{type:'card',card:card.id});
|
||||
while (game.truthtrance?.stage === 'priority') {
|
||||
const next = game.players.find(seat=>!game.truthtrance!.passed.includes(seat.id)); assert.ok(next);
|
||||
game = act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
const asking = viewGame(game,'atreides');
|
||||
assert.ok(asking.truthRevivalTargets.includes('choam'));
|
||||
assert.match(truth(asking), /<option value="revival">Bind ordinary force revivals this turn<\/option>/);
|
||||
assert.match(table(asking), /Bind ordinary force revivals this turn/);
|
||||
|
||||
game = act(game,'atreides',{type:'truthAsk',question:{kind:'revival',target:'choam',
|
||||
turn:game.turn,counter:'total',minimum:3}});
|
||||
const respondent = viewGame(game,'choam');
|
||||
assert.ok(respondent.truthRevivalAnswers?.includes('yes'));
|
||||
assert.ok(respondent.truthRevivalAnswers?.includes('no'));
|
||||
assert.equal(viewGame(game,'atreides').truthRevivalAnswers,null);
|
||||
assert.match(truth(respondent),/Answer Yes/);
|
||||
assert.match(truth(respondent),/Answer No/);
|
||||
assert.match(table(respondent),/Answer Yes/);
|
||||
assert.match(table(respondent),/Answer No/);
|
||||
|
||||
game = act(game,'choam',{type:'truthAnswer',answer:'yes'});
|
||||
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||
const event = pending.batch.event;
|
||||
for (let count=0;game.pendingTreacheryDiscard?.batch.event === event && count<game.players.length;count++) {
|
||||
const reaction = game.pendingTreacheryDiscard!.reaction; assert.ok(reaction?.stage === 'offer');
|
||||
const next = game.players.find(seat=>!reaction.passed.includes(seat.id)); assert.ok(next);
|
||||
game = act(game,next.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
const own = viewGame(game,'choam'), sent:Action[] = [];
|
||||
assert.ok(own.revivalPromiseGuide);
|
||||
assert.match(table(own),/Revive 3 forces while honoring your answers/);
|
||||
const button = RevivalPromiseGuideButton({game:own,busy:false,send(action) {sent.push(action);}});
|
||||
assert.ok(button); assert.equal(button.props.disabled,false); button.props.onClick();
|
||||
assert.deepEqual(sent,[own.revivalPromiseGuide.action]);
|
||||
game = act(game,'choam',sent[0]);
|
||||
game = finishRevival(game);
|
||||
assert.ok(game.revivalPromises?.some(row=>row.player === 'choam' && row.fulfilled));
|
||||
assert.equal(player(game,'choam').tanks,1);
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { handLimit, viewGame, type Game } from '../game/engine';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { act, finishRevival, inventory, player } from './fixture-kull-revival-semuta';
|
||||
import { createSemutaRevivalBenefitsForcesFixture } from './fixture-semuta-revival-benefits-forces';
|
||||
|
||||
/** Real Basic setup, cache purchase, shipment, Storm losses and Revival
|
||||
* window. Only original Truth and Semuta cards are reassigned. The no-Kull
|
||||
* variant stages the already available option off; leader cases stage the
|
||||
* original five-leader cohort dead so a normal CHOAM return is legal.
|
||||
* No forces, wallet or pending actions are staged. */
|
||||
let nativeSource: ReturnType<typeof createSemutaRevivalBenefitsForcesFixture> | undefined;
|
||||
function source(kull:boolean, leaderNeeded:boolean) {
|
||||
const fixture=nativeSource ??= createSemutaRevivalBenefitsForcesFixture({kind:'choamRevival',advanced:false});
|
||||
const game=structuredClone(fixture.beforeRevival);
|
||||
assert.ok(game.kullPreview && game.semutaPreview);
|
||||
if (!kull) game.kullPreview=false;
|
||||
const originalCards=inventory(game);
|
||||
const zones=[game.deck,game.discard,...(game.richeseCache?[game.richeseCache]:[]),
|
||||
...(game.richeseRemoved?[game.richeseRemoved]:[]),...game.players.map(seat=>seat.hand)];
|
||||
const move=(id:string,recipient:string)=>{
|
||||
const zone=zones.find(cards=>cards.some(card=>card.id===id)); assert.ok(zone);
|
||||
const [card]=zone.splice(zone.findIndex(row=>row.id===id),1);
|
||||
const seat=player(game,recipient); assert.ok(seat.hand.length<handLimit(seat)); seat.hand.push(card);
|
||||
};
|
||||
move(SEMUTA_DRUG_ID,'richese');
|
||||
const truth=zones.flat().find(card=>card.effect==='truthtrance'); assert.ok(truth); move(truth.id,'atreides');
|
||||
const leaders=player(game,'choam').leaders;
|
||||
const leader=[...leaders].sort((a,b)=>a.strength-b.strength)[0]; assert.ok(leader);
|
||||
if (leaderNeeded) for (const row of leaders) {row.dead=true; row.deaths=1;}
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,truth:truth.id,leader:leader.id,originalCards};
|
||||
}
|
||||
|
||||
function react(game:Game,truth:string,claim:boolean):Game {
|
||||
const pending=game.pendingTreacheryDiscard; assert.ok(pending);
|
||||
assert.equal(pending.reaction?.stage,'offer');
|
||||
assert.ok(pending.batch.entries.some(entry=>entry.card.id===truth));
|
||||
const event=pending.batch.event;
|
||||
if (claim) {
|
||||
assert.equal(viewGame(game,'richese').semutaReaction?.canCommit,true);
|
||||
game=act(game,'richese',{type:'semutaCommit',event});
|
||||
if (game.pendingTreacheryDiscard?.reaction?.stage==='select')
|
||||
game=act(game,'richese',{type:'semutaSelect',event,card:truth});
|
||||
} else for (let count=0;game.pendingTreacheryDiscard?.batch.event===event && count<game.players.length;count++) {
|
||||
const reaction=game.pendingTreacheryDiscard!.reaction; assert.ok(reaction?.stage==='offer');
|
||||
const actor=game.players.find(seat=>!reaction.passed.includes(seat.id)); assert.ok(actor);
|
||||
game=act(game,actor.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
|
||||
for (const kull of [false,true]) for (const kind of ['revival','revivalExpression','mixedRevival','leaderRevival'] as const)
|
||||
for (const claim of [false,true]) void test(`${kull?'Kull':'non-Kull'} ${kind} remains bound after Semuta ${claim?'claims':'passes'} Truthtrance`,()=>{
|
||||
const f=source(kull,kind==='leaderRevival'); let game=act(f.game,'atreides',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const next=game.players.find(seat=>!game.truthtrance!.passed.includes(seat.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
const forces={kind:'forces' as const,counter:'total' as const,minimum:1};
|
||||
const question=kind==='revival' ? {kind,target:'choam',turn:game.turn,counter:'total',minimum:1} :
|
||||
kind==='revivalExpression' ? {kind,target:'choam',turn:game.turn,claim:forces} :
|
||||
kind==='leaderRevival' ? {kind,target:'choam',turn:game.turn,leader:f.leader} :
|
||||
{kind,target:'choam',turn:game.turn,mixed:{kind:'and',terms:[
|
||||
{kind:'fact',fact:{kind:'spice',compare:'eq',value:player(game,'choam').spice}},
|
||||
{kind:'action',action:forces},
|
||||
]}};
|
||||
game=act(game,'atreides',{type:'truthAsk',question});
|
||||
const view=viewGame(game,'choam');
|
||||
const answers=kind==='revival'?view.truthRevivalAnswers:
|
||||
kind==='revivalExpression'?view.truthRevivalExpressionAnswers:
|
||||
kind==='mixedRevival'?view.truthMixedRevivalAnswers:view.truthLeaderRevivalAnswers;
|
||||
assert.ok(answers?.includes('yes'));
|
||||
game=act(game,'choam',{type:'truthAnswer',answer:'yes'});
|
||||
game=react(game,f.truth,claim);
|
||||
const after=viewGame(game,'choam');
|
||||
const guide=kind==='revival'?after.revivalPromiseGuide:
|
||||
kind==='leaderRevival'?after.leaderRevivalPromiseGuide:after.revivalExpressionPromiseGuide;
|
||||
assert.ok(guide);
|
||||
game=act(game,'choam',guide.action);
|
||||
game=finishRevival(game);
|
||||
if (kind==='revival') assert.ok(game.revivalPromises?.some(row=>row.player==='choam' && row.fulfilled));
|
||||
else if (kind==='leaderRevival') assert.ok(game.leaderRevivalPromises?.some(row=>row.player==='choam' && row.fulfilled));
|
||||
else assert.ok(game.revivalExpressionPromises?.some(row=>row.player==='choam' && row.fulfilled));
|
||||
assert.equal(player(game,'richese').hand.some(card=>card.id===f.truth),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
for (const kull of [false,true]) for (const claim of [false,true])
|
||||
void test(`${kull?'Kull':'non-Kull'} constant mixed Revival survives Semuta ${claim?'claim':'pass'} without a residual promise`,()=>{
|
||||
const f=source(kull,false); let game=act(f.game,'atreides',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const next=game.players.find(seat=>!game.truthtrance!.passed.includes(seat.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
game=act(game,'atreides',{type:'truthAsk',question:{kind:'mixedRevival',target:'choam',turn:game.turn,
|
||||
mixed:{kind:'or',terms:[
|
||||
{kind:'fact',fact:{kind:'spice',compare:'eq',value:player(game,'choam').spice}},
|
||||
{kind:'action',action:{kind:'forces',counter:'total',minimum:1}},
|
||||
]}}});
|
||||
assert.ok(viewGame(game,'choam').truthMixedRevivalAnswers?.includes('yes'));
|
||||
game=act(game,'choam',{type:'truthAnswer',answer:'yes'});
|
||||
const record=game.mixedRevivalQuestions?.at(-1); assert.ok(record);
|
||||
assert.equal(record.binding,false);
|
||||
assert.ok(!game.revivalExpressionPromises?.some(row=>row.event===record.event));
|
||||
game=react(game,f.truth,claim);
|
||||
assert.deepEqual(game.mixedRevivalQuestions?.at(-1),record);
|
||||
assert.equal(player(game,'richese').hand.some(card=>card.id===f.truth),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -33,7 +33,7 @@ void test('public host lobby shows the explicitly selected Kull preview and its
|
||||
assert.match(html,/Printed Kull is enabled by default/);
|
||||
assert.match(html,/Combined turn-action Truthtrance questions are unavailable/);
|
||||
assert.match(html,/Unfunded non-CHOAM Karama-dependent bids remain deferred/);
|
||||
assert.match(html,/When Richese is seated, alliance and Revival commitments are also unavailable/);
|
||||
assert.match(html,/When Richese is seated, alliance commitments are also unavailable/);
|
||||
const off = act(f.lobby,f.lobby.host,{type:'moduleOption',module:'kullPreview',enabled:false});
|
||||
const unselected = viewGame(off,off.host);
|
||||
assert.equal(unselected.lobbyModules?.kullPreview,false);
|
||||
|
||||
Reference in new issue
Block a user