Support bribe promises with Kull and Richese
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
52d932002b
commit
2eaaab876e
15 files changed
+422
-10
No files matched your search
@@ -27,6 +27,9 @@ void test('Basic printed Kull supports the shared bribe family in its declared n
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'moritani'}],expansions:['choam','ix','ecaz'],kullPreview:true}),true);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'ecaz'}],kullPreview:true}),false);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'richese'}],kullPreview:true}),false);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'richese'}],kullPreview:true,semutaPreview:true}),true);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'richese'}],kullPreview:true,semutaPreview:true,advanced:true}),false);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'richese'}],kullPreview:true,semutaPreview:true,homeworlds:true}),false);
|
||||
assert.equal(quote({...basic,players:[{faction:'choam'},{faction:'emperor'},{faction:'emperor'}],kullPreview:true}),false);
|
||||
for (const option of ['semutaPreview','nexusKullPreview','richeseBetrayalPreview','guildBetrayalPreview',
|
||||
'nexusIxianReplacementPreview','nexusIxianBetrayalPreview','nexusHarkonnenBetrayalPreview',
|
||||
|
||||
@@ -75,7 +75,7 @@ void test('phase-wide Kull questions admit the supported native Richese and Semu
|
||||
semutaPreview:true, players:[{faction:'choam'}, {faction:'richese'}]};
|
||||
assert.equal(phaseBidPromiseModeSupported(scope), true);
|
||||
assert.equal(bidPromiseModeSupported(scope), false);
|
||||
assert.equal(bribePromiseModeSupported(scope), false);
|
||||
assert.equal(bribePromiseModeSupported(scope), true);
|
||||
});
|
||||
|
||||
void test('phase-wide Yes survives a real Kull interception and completes its original bid', () => {
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Action, 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, advance, clean, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Genuine public Basic start. Only the original unopened deal and a safe
|
||||
* unopened spice position are selected. The question, Richese cache purchase,
|
||||
* Kull response, Semuta reaction and payment all use actual actions. */
|
||||
function fixture(answer:'yes'|'no' = 'yes') {
|
||||
let game = createGame('KULLRICHBRIBE',newPlayer('choam','CHOAM','choam'),false,['choam','ix']);
|
||||
for (const id of ['richese','emperor','harkonnen','guild'] as const)
|
||||
joinGame(game,newPlayer(id,id,id));
|
||||
game = act(game,'choam',{type:'moduleOption',module:'kullPreview',enabled:true});
|
||||
for (const seat of game.players) game = act(game,seat.id,{type:'ready'});
|
||||
game = act(game,'choam',{type:'start'});
|
||||
assert.equal(game.status,'setup'); assert.ok(game.kullPreview && game.semutaPreview);
|
||||
const originalCards = inventory(game), selected:Game['deck'] = [];
|
||||
// Harkonnen receives two cards before Guild's one.
|
||||
for (const kind of ['kull','filler','karama','karama','filler','truth'] as const) {
|
||||
const index = game.deck.findIndex(card => kind === 'kull' ? card.id === 'ix-kull-wahad' :
|
||||
kind === 'truth' ? card.effect === 'truthtrance' : kind === 'karama' ? card.effect === 'karama' :
|
||||
card.kind === 'worthless' && card.id !== 'ix-kull-wahad');
|
||||
assert.ok(index >= 0); selected.push(game.deck.splice(index,1)[0]);
|
||||
}
|
||||
game.deck.unshift(...selected);
|
||||
game = advance(game,state => state.status === 'playing');
|
||||
const [kull,,karama,counter,,truth] = selected.map(card=>card.id);
|
||||
for (const [id,card] of [['choam',kull],['emperor',karama],['harkonnen',counter],['guild',truth]] as const)
|
||||
assert.ok(player(game,id).hand.some(row=>row.id===card),`${id} received ${card}`);
|
||||
const spice = game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(spice>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(spice,1)[0]);
|
||||
game = advance(game,state => state.phase===2 && clean(state) && state.choamCharity?.turn===state.turn);
|
||||
game = act(game,'guild',{type:'card',card:truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const next=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
game=act(game,'guild',{type:'truthAsk',question:{kind:'bribe',target:'emperor',turn:game.turn,
|
||||
recipient:'guild',minimum:2}});
|
||||
const answers=viewGame(game,'emperor').truthBribeAnswers;
|
||||
assert.ok(answers?.includes(answer));
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view=viewGame(game,'emperor'); view.players.find(row=>row.id==='emperor')!.bot=difficulty;
|
||||
const action=botActions(view)[0]; assert.ok(action,difficulty);
|
||||
assert.equal(action.type,'truthAnswer',difficulty);
|
||||
assert.ok(view.truthBribeAnswers?.includes(action.answer as 'yes'|'no'),difficulty);
|
||||
assert.doesNotThrow(()=>act(game,'emperor',action),difficulty);
|
||||
}
|
||||
game=act(game,'emperor',{type:'truthAnswer',answer});
|
||||
const commitment=game.bribePromises!.find(row=>row.player==='emperor')!;
|
||||
game=advance(game,state=>player(state,'richese').hand.some(card=>card.id===SEMUTA_DRUG_ID) &&
|
||||
!!state.auction && state.auction.active==='emperor' && clean(state));
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===commitment.event && !row.fulfilled && !row.released));
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,kull,karama,counter,event:commitment.event,originalCards};
|
||||
}
|
||||
|
||||
function declare(f:ReturnType<typeof fixture>) {
|
||||
let game=act(f.game,'harkonnen',{type:'card',mode:'purchase',card:f.counter});
|
||||
assert.equal(game.pendingKull?.stage,'offer');
|
||||
const reaction=viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
assert.ok(reaction.plays.some(row=>row.card.id===f.kull && !row.blocked));
|
||||
game=act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
assert.equal(game.pendingKull?.stage,'counter');
|
||||
return game;
|
||||
}
|
||||
function resolveSemuta(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;
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view=viewGame(game,'richese'); view.players.find(row=>row.id==='richese')!.bot=difficulty;
|
||||
const action=botActions(view)[0]; assert.ok(action,difficulty);
|
||||
assert.ok(['semutaPass','semutaCommit'].includes(action.type),difficulty);
|
||||
assert.doesNotThrow(()=>act(game,'richese',action),difficulty);
|
||||
}
|
||||
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(row=>!reaction.passed.includes(row.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'semutaPass',event});
|
||||
}
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
for (const claim of [false,true]) void test(`Basic bribe Yes survives Kull success and Semuta ${claim?'claim':'pass'}`,()=>{
|
||||
const f=fixture();
|
||||
let game=declare(f);
|
||||
assert.equal(viewGame(game,'emperor').bribePromiseGuide,null);
|
||||
game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===f.event && !row.fulfilled && !row.released));
|
||||
game=resolveSemuta(game,f.kull,claim);
|
||||
game=advance(game,clean);
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===f.event && !row.fulfilled && !row.released));
|
||||
const guide=viewGame(game,'emperor').bribePromiseGuide; assert.ok(guide);
|
||||
assert.equal(guide.action.type,'bribe'); assert.equal(guide.action.target,'guild');
|
||||
game=act(game,'emperor',guide.action);
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===f.event && row.fulfilled));
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
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(`Basic bribe Yes survives Kull counter and Semuta ${claim?'claim':'pass'}`,()=>{
|
||||
const f=fixture();
|
||||
let game=declare(f);
|
||||
assert.ok(viewGame(game,'emperor').responseControls?.cancelCards?.includes(f.karama));
|
||||
game=act(game,'emperor',{type:'card',mode:'cancel',card:f.karama});
|
||||
game=resolveSemuta(game,f.karama,claim);
|
||||
game=advance(game,clean);
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===f.event && !row.fulfilled && !row.released));
|
||||
const guide=viewGame(game,'emperor').bribePromiseGuide; assert.ok(guide);
|
||||
assert.equal(guide.action.type,'bribe'); assert.equal(guide.action.target,'guild');
|
||||
game=act(game,'emperor',guide.action);
|
||||
assert.ok(game.bribePromises?.some(row=>row.event===f.event && row.fulfilled));
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
assert.equal(player(game,'richese').hand.some(card=>card.id===f.karama),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
void test('Basic bribe No retains its cap through Kull and Semuta',()=>{
|
||||
const f=fixture('no'); let game=declare(f);
|
||||
game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
game=resolveSemuta(game,f.kull,false); game=advance(game,clean);
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,'emperor',{type:'bribe',target:'guild',amount:2} as Action));
|
||||
assert.deepEqual(game,before);
|
||||
game=act(game,'emperor',{type:'bribe',target:'guild',amount:1});
|
||||
assert.equal(player(game,'guild').bribes,1);
|
||||
assert.ok(!game.bribePromises?.find(row=>row.event===f.event)?.released);
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { alliancePromiseModeSupported } from '../game/alliance-promises';
|
||||
import { bidPromiseModeSupported, currentBidPromiseModeSupported } from '../game/bid-promises';
|
||||
import { bribeExpressionPromiseModeSupported } from '../game/bribe-expression-promises';
|
||||
import { bribePromiseModeSupported } from '../game/bribe-promises';
|
||||
import { revivalPromiseModeSupported } from '../game/revival-promises';
|
||||
import { viewGame } from '../game/engine';
|
||||
import { 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 Kull and Semuta expose the bribe family only in the supported native profile', () => {
|
||||
for (const quote of [bribePromiseModeSupported, bribeExpressionPromiseModeSupported]) {
|
||||
assert.equal(quote(profile), true);
|
||||
assert.equal(quote({...profile, expansions:['ix','choam']}), true);
|
||||
assert.equal(quote({...profile, expansions:['choam','ix','ecaz'],
|
||||
players:[...profile.players, {faction:'moritani'}, {faction:'ecaz'}]}), 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);
|
||||
}
|
||||
});
|
||||
|
||||
void test('admitting bribes does not silently enable unrelated Semuta promise families', () => {
|
||||
assert.equal(alliancePromiseModeSupported(profile),false);
|
||||
assert.equal(revivalPromiseModeSupported(profile),false);
|
||||
assert.equal(bidPromiseModeSupported(profile),false);
|
||||
assert.equal(currentBidPromiseModeSupported(profile),true);
|
||||
});
|
||||
|
||||
void test('a genuine public Basic Kull and Richese start projects the ordinary bribe controls', () => {
|
||||
const {game} = createKullRicheseSemutaFixture();
|
||||
assert.equal(game.kullPreview,true);
|
||||
assert.equal(game.semutaPreview,true);
|
||||
const view = viewGame(game,'emperor');
|
||||
assert.ok(view.truthBribeTargets.includes('harkonnen'));
|
||||
assert.ok(view.truthBribeExpressionTargets.includes('harkonnen'));
|
||||
assert.ok(view.truthMixedBribeTargets.includes('harkonnen'));
|
||||
assert.deepEqual(view.truthAllianceTargets,[]);
|
||||
assert.deepEqual(view.truthRevivalTargets,[]);
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
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 { createGame, joinGame, newPlayer, viewGame, type Action, type Game, type GameView } from '../game/engine';
|
||||
import { act, advance, clean, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
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 { BribePromiseGuideButton } = await import('../components/bribe-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() {}}));
|
||||
|
||||
/** Native lobby/start and actions; only original unopened deal and Spice
|
||||
* positions are selected. The question is at a real settled Charity opening. */
|
||||
function fixture() {
|
||||
let game=createGame('KULLRICHTABLE',newPlayer('choam','CHOAM','choam'),false,['choam','ix']);
|
||||
for (const id of ['richese','emperor','harkonnen','guild'] as const) joinGame(game,newPlayer(id,id,id));
|
||||
game=act(game,'choam',{type:'moduleOption',module:'kullPreview',enabled:true});
|
||||
for (const seat of game.players) game=act(game,seat.id,{type:'ready'});
|
||||
game=act(game,'choam',{type:'start'});
|
||||
assert.equal(game.status,'setup'); assert.ok(game.kullPreview && game.semutaPreview);
|
||||
const originalCards=inventory(game), selected:Game['deck']=[];
|
||||
for (const kind of ['kull','filler','karama','karama','filler','truth'] as const) {
|
||||
const index=game.deck.findIndex(card=>kind==='kull' ? card.id==='ix-kull-wahad' :
|
||||
kind==='truth' ? card.effect==='truthtrance' : kind==='karama' ? card.effect==='karama' :
|
||||
card.kind==='worthless' && card.id!=='ix-kull-wahad');
|
||||
assert.ok(index>=0); selected.push(game.deck.splice(index,1)[0]);
|
||||
}
|
||||
game.deck.unshift(...selected);
|
||||
game=advance(game,state=>state.status==='playing');
|
||||
const truthCard=selected[5].id;
|
||||
assert.ok(player(game,'guild').hand.some(card=>card.id===truthCard));
|
||||
const spice=game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(spice>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(spice,1)[0]);
|
||||
game=advance(game,state=>state.phase===2 && clean(state) && state.choamCharity?.turn===state.turn);
|
||||
game=act(game,'guild',{type:'card',card:truthCard});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const next=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
return {game,originalCards};
|
||||
}
|
||||
|
||||
void test('Basic Kull and Richese render the real bribe question, answer and subsequent payment guide',()=>{
|
||||
const f=fixture();
|
||||
let game=f.game;
|
||||
const asker=viewGame(game,'guild');
|
||||
assert.ok(asker.truthBribeTargets.includes('emperor'));
|
||||
assert.match(truth(asker), /<option value="bribe">Bind ordinary bribe payments this turn<\/option>/);
|
||||
assert.match(table(asker), /Bind ordinary bribe payments this turn/);
|
||||
|
||||
game=act(game,'guild',{type:'truthAsk',question:{kind:'bribe',target:'emperor',turn:game.turn,
|
||||
recipient:'guild',minimum:2}});
|
||||
const respondent=viewGame(game,'emperor');
|
||||
assert.ok(respondent.truthBribeAnswers?.includes('yes'));
|
||||
assert.ok(respondent.truthBribeAnswers?.includes('no'));
|
||||
assert.equal(viewGame(game,'guild').truthBribeAnswers,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,'emperor',{type:'truthAnswer',answer:'yes'});
|
||||
game=advance(game,clean);
|
||||
const own=viewGame(game,'emperor'), sent:Action[]=[];
|
||||
assert.ok(own.bribePromiseGuide);
|
||||
assert.match(table(own),/Pay 2 spice to guild while honoring your answers/i);
|
||||
const button=BribePromiseGuideButton({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.bribePromiseGuide.action]);
|
||||
game=act(game,'emperor',sent[0]);
|
||||
assert.ok(game.bribePromises?.some(row=>row.player==='emperor' && row.fulfilled));
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { act, advance, clean, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Only the original unopened deal and a safe unopened Spice position are
|
||||
* selected. Richese actually purchases Semuta in the native cache auction,
|
||||
* then Guild asks its original physically held Truthtrance during Bidding. */
|
||||
function fixture() {
|
||||
let game=createGame('KULLRICHTRUTH',newPlayer('choam','CHOAM','choam'),false,['choam','ix']);
|
||||
for (const id of ['richese','emperor','harkonnen','guild'] as const) joinGame(game,newPlayer(id,id,id));
|
||||
game=act(game,'choam',{type:'moduleOption',module:'kullPreview',enabled:true});
|
||||
for (const seat of game.players) game=act(game,seat.id,{type:'ready'});
|
||||
game=act(game,'choam',{type:'start'});
|
||||
assert.equal(game.status,'setup'); assert.ok(game.kullPreview && game.semutaPreview);
|
||||
const originalCards=inventory(game), selected:Game['deck']=[];
|
||||
for (const kind of ['kull','filler','karama','karama','filler','truth'] as const) {
|
||||
const index=game.deck.findIndex(card=>kind==='kull' ? card.id==='ix-kull-wahad' :
|
||||
kind==='truth' ? card.effect==='truthtrance' : kind==='karama' ? card.effect==='karama' :
|
||||
card.kind==='worthless' && card.id!=='ix-kull-wahad');
|
||||
assert.ok(index>=0); selected.push(game.deck.splice(index,1)[0]);
|
||||
}
|
||||
game.deck.unshift(...selected);
|
||||
game=advance(game,state=>state.status==='playing');
|
||||
const truth=selected[5].id;
|
||||
assert.ok(player(game,'guild').hand.some(card=>card.id===truth));
|
||||
const spice=game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(spice>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(spice,1)[0]);
|
||||
game=advance(game,state=>player(state,'richese').hand.some(card=>card.id===SEMUTA_DRUG_ID) &&
|
||||
!!state.auction && state.auction.active==='emperor' && clean(state));
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,truth,originalCards};
|
||||
}
|
||||
function resolveSemuta(game:Game,card: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===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(row=>!reaction.passed.includes(row.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'semutaPass',event});
|
||||
}
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
for (const kind of ['bribe','bribeExpression','mixedBribe'] as const)
|
||||
for (const claim of [false,true]) void test(`Basic ${kind} answer retains its payment after Semuta ${claim?'claims':'passes'} Truthtrance`,()=>{
|
||||
const f=fixture(); let game=act(f.game,'guild',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const next=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(next);
|
||||
game=act(game,next.id,{type:'truthPass'});
|
||||
}
|
||||
const payment={kind:'payment' as const,recipient:'guild',minimum:2};
|
||||
const question=kind==='bribe' ? {kind,target:'emperor',turn:game.turn,recipient:'guild',minimum:2} :
|
||||
kind==='bribeExpression' ? {kind,target:'emperor',turn:game.turn,claim:payment} :
|
||||
{kind,target:'emperor',turn:game.turn,mixed:{kind:'and',terms:[
|
||||
{kind:'fact',fact:{kind:'spice',compare:'eq',value:player(game,'emperor').spice}},
|
||||
{kind:'action',action:{recipient:'guild',minimum:2}},
|
||||
]}};
|
||||
game=act(game,'guild',{type:'truthAsk',question});
|
||||
const view=viewGame(game,'emperor');
|
||||
const answers=kind==='bribe' ? view.truthBribeAnswers :
|
||||
kind==='bribeExpression' ? view.truthBribeExpressionAnswers : view.truthMixedBribeAnswers;
|
||||
assert.ok(answers?.includes('yes'));
|
||||
game=act(game,'emperor',{type:'truthAnswer',answer:'yes'});
|
||||
game=resolveSemuta(game,f.truth,claim);
|
||||
game=advance(game,clean);
|
||||
const guide=viewGame(game,'emperor').bribePromiseGuide; assert.ok(guide);
|
||||
assert.equal(guide.action.type,'bribe'); assert.equal(guide.action.target,'guild');
|
||||
game=act(game,'emperor',guide.action);
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
if (kind==='bribe') assert.ok(game.bribePromises?.some(row=>row.player==='emperor' && row.fulfilled));
|
||||
else assert.ok(game.bribeExpressionPromises?.some(row=>row.player==='emperor' && row.fulfilled));
|
||||
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, Revival and bribe commitments are also unavailable/);
|
||||
assert.match(html,/When Richese is seated, alliance and Revival 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