Support whole-turn answers with Basic Kull
Verify and publish checkpoint container / container (push) Successful in 10m21s
Verify and publish checkpoint container / container (push) Successful in 10m21s
This commit is contained in:
1 parent
d6ddb7cb5c
commit
07f1f1f2ae
16 files changed
+870
-14
No files matched your search
@@ -0,0 +1,84 @@
|
||||
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, advance, attempt, clean, createKullRicheseSemutaFixture, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Genuine Basic setup, real cache purchase and movement window. Only the
|
||||
* existing physical counter Karama is moved from Harkonnen to Richese and
|
||||
* an original Truthtrance is moved to Harkonnen. No purse, force, pending
|
||||
* response, clock, promise or fresh discard is installed. */
|
||||
function source() {
|
||||
const f=createKullRicheseSemutaFixture(), game=structuredClone(f.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(f.counter,'richese');
|
||||
const truth=zones.flat().find(card=>card.effect==='truthtrance'); assert.ok(truth);
|
||||
move(truth.id,'harkonnen');
|
||||
assert.ok(player(game,'richese').hand.some(card=>card.id===SEMUTA_DRUG_ID));
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
return {...f,game,truth:truth.id};
|
||||
}
|
||||
|
||||
function passDiscard(game:Game, card:string):Game {
|
||||
const batch=game.pendingTreacheryDiscard; assert.ok(batch?.reaction?.stage==='offer');
|
||||
assert.ok(batch.batch.entries.some(entry=>entry.card.id===card));
|
||||
const event=batch.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 seat=game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
|
||||
void test('Richese may counter Kull then use Semuta on the resumed original Karama while preserving a whole answer',()=>{
|
||||
const f=source(); let game=act(f.game,'harkonnen',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
const mixed={kind:'or',terms:[
|
||||
{kind:'action',action:{kind:'cardPlay',effect:'semutaDrug'}},
|
||||
{kind:'action',action:{kind:'payment',recipient:'emperor',minimum:1}},
|
||||
]};
|
||||
game=act(game,'harkonnen',{type:'truthAsk',question:{kind:'turnActions',target:'richese',turn:game.turn,mixed}});
|
||||
assert.ok(viewGame(game,'richese').truthTurnActionAnswers?.includes('yes'));
|
||||
game=act(game,'richese',{type:'truthAnswer',answer:'yes'});
|
||||
const promise=game.turnActionPromises?.at(-1); assert.ok(promise);
|
||||
const event=promise.event;
|
||||
// A currently affordable payment is a real alternative, so passing the
|
||||
// Truth discard does not evade the complete OR answer.
|
||||
game=passDiscard(game,f.truth);
|
||||
game=act(game,'emperor',attempt(f));
|
||||
const reaction=viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
game=act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
assert.ok(viewGame(game,'richese').responseControls?.cancelCards?.includes(f.counter));
|
||||
game=act(game,'richese',{type:'card',mode:'cancel',card:f.counter});
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
// The physical counter belongs to Richese and cannot be its own Semuta
|
||||
// target. Its neutral discard completes first, then the suspended original
|
||||
// Emperor Karama produces a distinct, claimable fresh discard.
|
||||
game=passDiscard(game,f.counter);
|
||||
if (!game.pendingTreacheryDiscard)
|
||||
game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
const pending=game.pendingTreacheryDiscard; assert.ok(pending?.reaction?.stage==='offer');
|
||||
assert.ok(pending.batch.entries.some(entry=>entry.card.id===f.karama));
|
||||
assert.equal(viewGame(game,'richese').semutaReaction?.canCommit,true);
|
||||
game=act(game,'richese',{type:'semutaCommit',event:pending.batch.event});
|
||||
if (game.pendingTreacheryDiscard?.reaction?.stage==='select')
|
||||
game=act(game,'richese',{type:'semutaSelect',event:pending.batch.event,card:f.karama});
|
||||
game=advance(game,clean);
|
||||
const result=game.turnActionPromises!.find(row=>row.event===event); assert.ok(result);
|
||||
assert.equal(result.cardPlays?.semutaDrug?.played,true);
|
||||
assert.equal(result.fulfilled,true);
|
||||
assert.ok(player(game,'richese').hand.some(card=>card.id===f.karama));
|
||||
assert.equal(game.karamaShipping?.owner,'emperor');
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,184 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
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';
|
||||
|
||||
/** Genuine Basic lobby, physical deal and Richese cache purchase. Only the
|
||||
* still-unopened deal and one safe Spice position are selected; no played
|
||||
* cards, force counts, purses, phase, pending response or promise is staged. */
|
||||
function source() {
|
||||
let game = createGame('KULLRICHWHOLE', 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 [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));
|
||||
const safe=game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(safe>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(safe,1)[0]);
|
||||
game=advance(game,state => state.phase===5 && state.active==='emperor' &&
|
||||
!player(state,'emperor').shipped && player(state,'richese').hand.some(card=>card.id===SEMUTA_DRUG_ID) && clean(state));
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,kull,karama,counter,truth,originalCards};
|
||||
}
|
||||
|
||||
function semuta(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 seat=game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
|
||||
function ask(game:Game, truth:string, mixed:unknown, answer:'yes'|'no' = 'yes', target='emperor') {
|
||||
game=act(game,'guild',{type:'card',card:truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
assert.ok(viewGame(game,'guild').truthTurnActionTargets.includes(target));
|
||||
game=act(game,'guild',{type:'truthAsk',question:{kind:'turnActions',target,turn:game.turn,mixed}});
|
||||
const choices=viewGame(game,target).truthTurnActionAnswers; assert.ok(choices); assert.ok(choices.includes(answer));
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view=viewGame(game,target); view.players.find(row=>row.id===target)!.bot=difficulty;
|
||||
const action=botActions(view)[0]; assert.ok(action,difficulty);
|
||||
assert.equal(action.type,'truthAnswer',difficulty);
|
||||
assert.ok(choices.includes(action.answer as 'yes'|'no'|'unknown'),difficulty);
|
||||
assert.doesNotThrow(()=>act(game,target,action),difficulty);
|
||||
}
|
||||
game=act(game,target,{type:'truthAnswer',answer});
|
||||
const promise=game.turnActionPromises?.at(-1); assert.ok(promise);
|
||||
return {game,event:promise.event};
|
||||
}
|
||||
|
||||
const paymentShipment = {kind:'and',terms:[
|
||||
{kind:'action',action:{kind:'payment',recipient:'guild',minimum:2}},
|
||||
{kind:'action',action:{kind:'ship',territory:'polar_sink',minimum:1}},
|
||||
]};
|
||||
|
||||
for (const claim of [false,true]) void test(`whole payment and shipment answer survives Semuta ${claim?'claim':'pass'} of Truthtrance`,()=>{
|
||||
const f=source(); const {game:initialGame,event}=ask(f.game,f.truth,paymentShipment); let game=initialGame;
|
||||
const promise=structuredClone(game.turnActionPromises!.find(row=>row.event===event)); assert.ok(promise);
|
||||
game=semuta(game,f.truth,claim);
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),promise);
|
||||
game=act(game,'emperor',{type:'bribe',target:'guild',amount:2});
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
game=act(game,'emperor',{type:'ship',territory:'polar_sink',sector:0,amount:1,elite:0,allyPayment:0});
|
||||
game=advance(game,clean);
|
||||
assert.equal(game.turnActionPromises!.find(row=>row.event===event)?.fulfilled,true);
|
||||
assert.equal(player(game,'richese').hand.some(row=>row.id===f.truth),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
for (const counter of [false,true]) for (const claim of [false,true])
|
||||
void test(`whole payment and shipment answer survives Kull ${counter?'counter':'success'} and Semuta ${claim?'claim':'pass'}`,()=>{
|
||||
const f=source(); const {game:initialGame,event}=ask(f.game,f.truth,paymentShipment); let game=initialGame;
|
||||
game=semuta(game,f.truth,false);
|
||||
const before=structuredClone(game.turnActionPromises!.find(row=>row.event===event)); assert.ok(before);
|
||||
game=act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'});
|
||||
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');
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
if (counter) game=act(game,'harkonnen',{type:'card',mode:'cancel',card:f.counter});
|
||||
else game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
game=semuta(game,counter?f.counter:f.kull,claim);
|
||||
game=advance(game,clean);
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
game=act(game,'emperor',{type:'bribe',target:'guild',amount:2});
|
||||
game=act(game,'emperor',{type:'ship',territory:'polar_sink',sector:0,amount:1,elite:0,allyPayment:0});
|
||||
game=advance(game,clean);
|
||||
assert.equal(game.turnActionPromises!.find(row=>row.event===event)?.fulfilled,true);
|
||||
assert.equal(player(game,'richese').hand.some(row=>row.id===(counter?f.counter:f.kull)),claim);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
void test('successful Kull leaves a promised printed shipment-price use unfulfilled until it is impossible',()=>{
|
||||
const f=source();
|
||||
const window=JSON.stringify(['karamaShipment',f.game.turn,'emperor','original']);
|
||||
const mixed={kind:'action',action:{kind:'windowCardPlay',effect:'karamaShipment',source:window}};
|
||||
const {game:initialGame,event}=ask(f.game,f.truth,mixed); let game=initialGame;
|
||||
game=semuta(game,f.truth,false);
|
||||
const before=structuredClone(game.turnActionPromises!.find(row=>row.event===event)); assert.ok(before);
|
||||
game=act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'});
|
||||
const reaction=viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
game=act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
game=semuta(game,f.kull,false); game=advance(game,clean);
|
||||
const after=game.turnActionPromises!.find(row=>row.event===event); assert.ok(after);
|
||||
assert.equal(after.fulfilled ?? false,false);
|
||||
assert.equal(after.released,true);
|
||||
assert.ok(player(game,'emperor').hand.some(row=>row.id===f.karama));
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
void test('whole Semuta Yes cannot voluntarily pass the known Truth discard that makes it possible',()=>{
|
||||
const f=source(); const mixed={kind:'action',action:{kind:'cardPlay',effect:'semutaDrug'}};
|
||||
const {game:initialGame,event}=ask(f.game,f.truth,mixed,'yes','richese'); let game=initialGame;
|
||||
const pending=game.pendingTreacheryDiscard; assert.ok(pending);
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,'richese',{type:'semutaPass',event:pending.batch.event}));
|
||||
assert.deepEqual(game,before);
|
||||
game=semuta(game,f.truth,true);
|
||||
const promise=game.turnActionPromises!.find(row=>row.event===event); assert.ok(promise);
|
||||
assert.equal(promise.cardPlays?.semutaDrug?.played,true);
|
||||
assert.equal(promise.fulfilled,true);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
for (const counter of [false,true]) void test(`a whole Semuta-or-payment answer records Semuta on ${counter?'counter':'Kull'} discard`,()=>{
|
||||
const f=source(); const mixed={kind:'or',terms:[
|
||||
{kind:'action',action:{kind:'cardPlay',effect:'semutaDrug'}},
|
||||
{kind:'action',action:{kind:'payment',recipient:'guild',minimum:1}},
|
||||
]};
|
||||
const {game:initialGame,event}=ask(f.game,f.truth,mixed,'yes','richese'); let game=initialGame;
|
||||
// Payment remains a real affordable alternative, so the holder may pass
|
||||
// the Truth discard without abandoning the whole answer.
|
||||
game=semuta(game,f.truth,false);
|
||||
const before=structuredClone(game.turnActionPromises!.find(row=>row.event===event)); assert.ok(before);
|
||||
game=act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'});
|
||||
const reaction=viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
game=act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
if (counter) game=act(game,'harkonnen',{type:'card',mode:'cancel',card:f.counter});
|
||||
else game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
assert.deepEqual(game.turnActionPromises!.find(row=>row.event===event),before);
|
||||
const cost=counter?f.counter:f.kull;
|
||||
game=semuta(game,cost,true); game=advance(game,clean);
|
||||
const promise=game.turnActionPromises!.find(row=>row.event===event); assert.ok(promise);
|
||||
assert.equal(promise.cardPlays?.semutaDrug?.played,true);
|
||||
assert.equal(promise.fulfilled,true);
|
||||
assert.ok(player(game,'richese').hand.some(row=>row.id===cost));
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { windowCardOpportunity } from '../game/window-card-play';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { act, advance, clean, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Genuine Basic setup and Richese cache purchase. Only unopened deal and
|
||||
* Spice positions are selected; all answers, payments and auctions are real. */
|
||||
function source() {
|
||||
let game=createGame('KULLWHOLEAUCTION',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 p of game.players) game=act(game,p.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 [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));
|
||||
const safe=game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(safe>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(safe,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));
|
||||
const window=windowCardOpportunity(game,'karamaAuction'); assert.ok(window);
|
||||
const lot=game.auction!.cards[game.auction!.index].id;
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,kull,karama,truth,window,lot,originalCards};
|
||||
}
|
||||
function passDiscard(game:Game):Game {
|
||||
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 seat=game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
function answer(f:ReturnType<typeof source>,mixed:unknown,value:'yes'|'no') {
|
||||
let game=act(f.game,'guild',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
game=act(game,'guild',{type:'truthAsk',question:{kind:'turnActions',target:'emperor',turn:game.turn,mixed}});
|
||||
assert.ok(viewGame(game,'emperor').truthTurnActionAnswers?.includes(value));
|
||||
game=act(game,'emperor',{type:'truthAnswer',answer:value});
|
||||
const row=game.turnActionPromises!.at(-1); assert.ok(row);
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
return {game,event:row.event};
|
||||
}
|
||||
for (const decline of [true,false]) void test(`an unrelated whole payment remains legal through Karama purchase and Kull ${decline?'decline':'success'}`,()=>{
|
||||
const f=source(); const {game:initialGame,event}=answer(f,{kind:'action',action:{kind:'payment',recipient:'guild',minimum:2}},'yes'); let game=initialGame;
|
||||
game=act(game,'emperor',{type:'card',mode:'purchase',card:f.karama});
|
||||
const reaction=viewGame(game,'choam').kullReaction; assert.ok(reaction);
|
||||
game=decline ? act(game,'choam',{type:'kullDecision',event:reaction.event,decline:true}) :
|
||||
act(game,'choam',{type:'kullDecision',event:reaction.event,source:'printed',card:f.kull});
|
||||
if (!decline) game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
game=advance(game,clean);
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
if (decline) assert.ok(player(game,'emperor').hand.some(card=>card.id===f.lot));
|
||||
else assert.ok(player(game,'emperor').hand.some(card=>card.id===f.karama));
|
||||
game=act(game,'emperor',{type:'bribe',target:'guild',amount:2});
|
||||
assert.equal(game.turnActionPromises!.find(row=>row.event===event)?.fulfilled,true);
|
||||
assert.equal(player(game,'guild').bribes,2);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
void test('a whole No to the original auction Karama rejects the printed purchase before Kull',()=>{
|
||||
const f=source(); const {game:initialGame,event}=answer(f,{kind:'action',action:{kind:'windowCardPlay',
|
||||
effect:'karamaAuction',source:f.window.source}},'no'); let game=initialGame;
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,'emperor',{type:'card',mode:'purchase',card:f.karama}));
|
||||
assert.deepEqual(game,before);
|
||||
assert.equal(game.pendingKull ?? null,null);
|
||||
game=act(game,'emperor',{type:'bid',amount:1,allyPayment:0});
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { handLimit, viewGame, type Game } from '../game/engine';
|
||||
import { act, advance, clean, createKullRicheseSemutaFixture, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Native Basic setup, physical deal, Richese cache purchase and the active
|
||||
* Emperor shipment window are inherited. Existing Truthtrance and Richese
|
||||
* Karama cards are moved to Richese's hand; no cash, pending actions or
|
||||
* promises are staged. The distinct Karama keeps the counter window open. */
|
||||
function source() {
|
||||
const f = createKullRicheseSemutaFixture();
|
||||
const game = structuredClone(f.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 [truth] = zone.splice(zone.findIndex(card => card.effect === 'truthtrance'), 1);
|
||||
assert.ok(player(game,'richese').hand.length < handLimit(player(game,'richese')));
|
||||
player(game,'richese').hand.push(truth);
|
||||
const cache = game.richeseCache; assert.ok(cache);
|
||||
const karamaIndex = cache.findIndex(card => card.id === 'richese-karama'); assert.ok(karamaIndex >= 0);
|
||||
const [additionalKarama] = cache.splice(karamaIndex,1);
|
||||
assert.ok(player(game,'richese').hand.length < handLimit(player(game,'richese')));
|
||||
player(game,'richese').hand.push(additionalKarama);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
assert.deepEqual(player(game,'harkonnen').hand.filter(card=>card.effect==='karama').map(card=>card.id),[f.counter]);
|
||||
return {...f,game,truth:truth.id};
|
||||
}
|
||||
function passDiscard(game:Game):Game {
|
||||
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 seat = game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game = act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
|
||||
void test('a Kull counter cannot spend the sole Karama promised for the open shipment-price window',()=>{
|
||||
const f=source(); let game=act(f.game,'richese',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
const windowSource=JSON.stringify(['karamaShipment',game.turn,'emperor','original']);
|
||||
game=act(game,'richese',{type:'truthAsk',question:{kind:'turnActions',target:'harkonnen',turn:game.turn,
|
||||
mixed:{kind:'action',action:{kind:'windowCardPlay',effect:'karamaShipment',source:windowSource}}}});
|
||||
assert.ok(viewGame(game,'harkonnen').truthTurnActionAnswers?.includes('yes'));
|
||||
game=act(game,'harkonnen',{type:'truthAnswer',answer:'yes'});
|
||||
const promise=game.turnActionPromises!.at(-1); assert.ok(promise);
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
game=act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'});
|
||||
const opportunity=viewGame(game,'choam').kullReaction; assert.ok(opportunity);
|
||||
game=act(game,'choam',{type:'kullDecision',event:opportunity.event,source:'printed',card:f.kull});
|
||||
assert.equal(game.pendingKull?.stage,'counter');
|
||||
assert.ok(viewGame(game,'richese').responseControls?.cancelCards.includes('richese-karama'));
|
||||
assert.ok(!viewGame(game,'harkonnen').responseControls?.cancelCards.includes(f.counter));
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,'harkonnen',{type:'card',mode:'cancel',card:f.counter}));
|
||||
assert.deepEqual(game,before);
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===promise.event)?.released);
|
||||
game=advance(game,state=>!!state.pendingTreacheryDiscard);
|
||||
game=passDiscard(game);
|
||||
game=advance(game,clean);
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===promise.event)?.released);
|
||||
game=act(game,'harkonnen',{type:'card',mode:'shipment',card:f.counter,target:'emperor'});
|
||||
const second=viewGame(game,'choam').kullReaction;
|
||||
if (second) game=act(game,'choam',{type:'kullDecision',event:second.event,decline:true});
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
game=advance(game,clean);
|
||||
assert.equal(game.turnActionPromises!.find(row=>row.event===promise.event)?.fulfilled,true);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { windowCardOpportunity } from '../game/window-card-play';
|
||||
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
|
||||
import { act, advance, clean, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Genuine Basic setup and Richese cache purchase. Only unopened deal and
|
||||
* Spice positions are selected; all answers, payments and auctions are real. */
|
||||
function source() {
|
||||
let game=createGame('KULLWHOLEAUCTION',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 p of game.players) game=act(game,p.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 [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));
|
||||
const safe=game.spiceDeck.findIndex(card=>'territory' in card && !card.discovery); assert.ok(safe>=0);
|
||||
game.spiceDeck.unshift(game.spiceDeck.splice(safe,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));
|
||||
const window=windowCardOpportunity(game,'karamaAuction'); assert.ok(window);
|
||||
const lot=game.auction!.cards[game.auction!.index].id;
|
||||
assert.deepEqual(inventory(game),originalCards);
|
||||
return {game,kull,karama,truth,window,lot,originalCards};
|
||||
}
|
||||
function passDiscard(game:Game):Game {
|
||||
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 seat=game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
function answer(f:ReturnType<typeof source>,mixed:unknown,value:'yes'|'no') {
|
||||
let game=act(f.game,'guild',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
game=act(game,'guild',{type:'truthAsk',question:{kind:'turnActions',target:'emperor',turn:game.turn,mixed}});
|
||||
assert.ok(viewGame(game,'emperor').truthTurnActionAnswers?.includes(value));
|
||||
game=act(game,'emperor',{type:'truthAnswer',answer:value});
|
||||
const row=game.turnActionPromises!.at(-1); assert.ok(row);
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
return {game,event:row.event};
|
||||
}
|
||||
|
||||
void test('a whole-answer Karama purchase quote is independent of the unopened lot face',()=>{
|
||||
const f=source();
|
||||
const mixed={kind:'or',terms:[
|
||||
{kind:'action',action:{kind:'cardPlay',effect:'ghola'}},
|
||||
{kind:'action',action:{kind:'payment',recipient:'guild',minimum:2}},
|
||||
]};
|
||||
const {game,event}=answer(f,mixed,'yes');
|
||||
const makeVariant=(effect:'ghola'|'other'):Game=>{
|
||||
const trial=structuredClone(game), auction=trial.auction; assert.ok(auction);
|
||||
const matches=(card:Game['deck'][number])=>effect==='ghola'
|
||||
? card.effect==='ghola' : card.effect!=='ghola';
|
||||
if (!matches(auction.cards[auction.index])) {
|
||||
const deckIndex=trial.deck.findIndex(matches);
|
||||
if (deckIndex>=0) [auction.cards[auction.index],trial.deck[deckIndex]]=
|
||||
[trial.deck[deckIndex],auction.cards[auction.index]];
|
||||
else {
|
||||
const other=auction.cards.findIndex((card,index)=>index>auction.index && matches(card));
|
||||
assert.ok(other>=0,'Need two original unopened faces for the two variants');
|
||||
[auction.cards[auction.index],auction.cards[other]]=[auction.cards[other],auction.cards[auction.index]];
|
||||
}
|
||||
}
|
||||
return trial;
|
||||
};
|
||||
const variants=[makeVariant('ghola'),makeVariant('other')];
|
||||
assert.notEqual(variants[0].auction!.cards[variants[0].auction!.index].id,
|
||||
variants[1].auction!.cards[variants[1].auction!.index].id);
|
||||
assert.equal(variants[0].auction!.cards[variants[0].auction!.index].effect,'ghola');
|
||||
for (let trial of variants) {
|
||||
assert.deepEqual(inventory(trial),f.originalCards);
|
||||
assert.deepEqual(player(trial,'emperor').hand,player(game,'emperor').hand);
|
||||
trial=act(trial,'emperor',{type:'card',mode:'purchase',card:f.karama});
|
||||
assert.ok(viewGame(trial,'choam').kullReaction);
|
||||
assert.ok(!trial.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { handLimit, viewGame, type Game } from '../game/engine';
|
||||
import { act, advance, clean, createKullRicheseSemutaFixture, inventory, player } from './fixture-kull-richese-semuta';
|
||||
|
||||
/** Real Basic setup, cache purchase and active Emperor shipment window.
|
||||
* Only an existing physical Truthtrance is reassigned to Richese's hand. */
|
||||
function source() {
|
||||
const f=createKullRicheseSemutaFixture(), game=structuredClone(f.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 [truth]=zone.splice(zone.findIndex(card=>card.effect==='truthtrance'),1);
|
||||
assert.ok(player(game,'richese').hand.length<handLimit(player(game,'richese')));
|
||||
player(game,'richese').hand.push(truth);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
return {...f,game,truth:truth.id};
|
||||
}
|
||||
function passDiscard(game:Game):Game {
|
||||
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 seat=game.players.find(row=>!reaction.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'semutaPass',event});
|
||||
}
|
||||
assert.notEqual(game.pendingTreacheryDiscard?.batch.event,event);
|
||||
return game;
|
||||
}
|
||||
function answer(f:ReturnType<typeof source>, value:'yes'|'no') {
|
||||
let game=act(f.game,'richese',{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
const source=JSON.stringify(['karamaShipment',game.turn,'emperor','original']);
|
||||
game=act(game,'richese',{type:'truthAsk',question:{kind:'turnActions',target:'emperor',turn:game.turn,
|
||||
mixed:{kind:'action',action:{kind:'windowCardPlay',effect:'karamaShipment',source}}}});
|
||||
assert.ok(viewGame(game,'emperor').truthTurnActionAnswers?.includes(value));
|
||||
game=act(game,'emperor',{type:'truthAnswer',answer:value});
|
||||
const promise=game.turnActionPromises!.at(-1); assert.ok(promise);
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
return {game,event:promise.event};
|
||||
}
|
||||
|
||||
void test('an original Karama forbidden by the actor’s whole No cannot open Kull',()=>{
|
||||
const f=source(); const {game:initialGame,event}=answer(f,'no'); let game=initialGame;
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'}));
|
||||
assert.deepEqual(game,before);
|
||||
assert.equal(game.pendingKull ?? null,null);
|
||||
game=act(game,'emperor',{type:'ship',territory:'polar_sink',sector:0,amount:1,elite:0,allyPayment:0});
|
||||
game=advance(game,clean);
|
||||
assert.ok(!game.turnActionPromises!.find(row=>row.event===event)?.released);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
|
||||
void test('an original printed Karama required by the actor’s whole Yes stays legal through Kull decline',()=>{
|
||||
const f=source(); const {game:initialGame,event}=answer(f,'yes'); let game=initialGame;
|
||||
game=act(game,'emperor',{type:'card',mode:'shipment',card:f.karama,target:'emperor'});
|
||||
const opportunity=viewGame(game,'choam').kullReaction; assert.ok(opportunity);
|
||||
game=act(game,'choam',{type:'kullDecision',event:opportunity.event,decline:true});
|
||||
if (game.pendingTreacheryDiscard) game=passDiscard(game);
|
||||
game=advance(game,clean);
|
||||
assert.equal(game.turnActionPromises!.find(row=>row.event===event)?.fulfilled,true);
|
||||
assert.equal(game.karamaShipping?.card,f.karama);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
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 Game, type GameView } from '../game/engine';
|
||||
import { turnActionPromiseModeSupported } from '../game/turn-action-promises';
|
||||
import { createKullBribeFixture } from './fixture-kull-bribe';
|
||||
import { act, advance, clean, createKullRicheseSemutaFixture, 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 {TurnActionGuideButton} = await import('../components/turn-action-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() {}}));
|
||||
|
||||
void test('Basic printed Kull admits whole-turn questions without opening Advanced or optional modules',()=>{
|
||||
const classic = {advanced:false, expansions:['choam','ix'], kullPreview:true,
|
||||
players:[{faction:'choam'},{faction:'emperor'},{faction:'guild'}]};
|
||||
const richese = {...classic, semutaPreview:true,
|
||||
players:[...classic.players, {faction:'richese'}]};
|
||||
assert.equal(turnActionPromiseModeSupported(classic),true);
|
||||
assert.equal(turnActionPromiseModeSupported(richese),true);
|
||||
assert.equal(turnActionPromiseModeSupported({...richese,kullPreview:false}),true);
|
||||
assert.equal(turnActionPromiseModeSupported({...richese,advanced:true}),false);
|
||||
assert.equal(turnActionPromiseModeSupported({...classic,expansions:['choam']}),false);
|
||||
assert.equal(turnActionPromiseModeSupported({...richese,players:[...richese.players,{faction:'richese'}]}),false);
|
||||
for (const flag of ['nexusKullPreview','richeseBetrayalPreview','nexusCards','homeworlds',
|
||||
'leaderSkills','techTokens','strongholdCards','discoveryEnabled','ecazTreachery'] as const)
|
||||
assert.equal(turnActionPromiseModeSupported({...richese,[flag]:true}),false,flag);
|
||||
});
|
||||
|
||||
/** Both sources use genuine Basic setup and phases. In the Richese case only
|
||||
* one original physical Truthtrance is moved to Harkonnen's hand; the native
|
||||
* Richese cache purchase and all subsequent actions remain real. */
|
||||
function source(richese:boolean): {game:Game; asker:string; card:string; originalCards:string[]} {
|
||||
if (!richese) {
|
||||
const f = createKullBribeFixture();
|
||||
return {game:structuredClone(f.game),asker:f.asker,card:f.truth,originalCards:f.originalCards};
|
||||
}
|
||||
const f = createKullRicheseSemutaFixture();
|
||||
const game = structuredClone(f.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,'harkonnen'); assert.ok(asker.hand.length < handLimit(asker)); asker.hand.push(card);
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
return {game,asker:'harkonnen',card:card.id,originalCards:f.originalCards};
|
||||
}
|
||||
|
||||
for (const richese of [false,true]) void test(`Basic Kull ${richese?'with':'without'} Richese renders and executes a whole-answer guide`,()=>{
|
||||
const f=source(richese); let game=act(f.game,f.asker,{type:'card',card:f.card});
|
||||
while (game.truthtrance?.stage==='priority') {
|
||||
const seat=game.players.find(row=>!game.truthtrance!.passed.includes(row.id)); assert.ok(seat);
|
||||
game=act(game,seat.id,{type:'truthPass'});
|
||||
}
|
||||
const asker=viewGame(game,f.asker);
|
||||
assert.ok(asker.truthTurnActionTargets.includes('emperor'));
|
||||
assert.match(truth(asker),/Combine printed card plays, native battle powers and this turn’s other actions/);
|
||||
assert.match(table(asker),/Combine printed card plays, native battle powers and this turn’s other actions/);
|
||||
game=act(game,f.asker,{type:'truthAsk',question:{kind:'turnActions',target:'emperor',turn:game.turn,
|
||||
mixed:{kind:'and',terms:[
|
||||
{kind:'action',action:{kind:'payment',recipient:'choam',minimum:1}},
|
||||
{kind:'action',action:{kind:'ship',territory:'polar_sink',minimum:1}},
|
||||
]}}});
|
||||
const respondent=viewGame(game,'emperor');
|
||||
assert.ok(respondent.truthTurnActionAnswers?.includes('yes'));
|
||||
assert.ok(respondent.truthTurnActionAnswers?.includes('no'));
|
||||
assert.equal(viewGame(game,f.asker).truthTurnActionAnswers,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.turnActionGuide);
|
||||
assert.match(table(own),/while honoring your whole answer/);
|
||||
const button=TurnActionGuideButton({game:own,busy:false,act(action) {sent.push(action);}});
|
||||
assert.ok(button); assert.equal(button.props.disabled,false); button.props.onClick();
|
||||
assert.deepEqual(sent,[own.turnActionGuide.action]);
|
||||
game=act(game,'emperor',sent[0]);
|
||||
assert.ok(game.turnActionPromises?.some(row=>row.player==='emperor' && !row.released));
|
||||
assert.deepEqual(inventory(game),f.originalCards);
|
||||
});
|
||||
@@ -31,7 +31,7 @@ void test('public host lobby shows the explicitly selected Kull preview and its
|
||||
assert.equal(host.lobbyModules?.kullPreview,true);
|
||||
assert.match(html,/Kull Wahad · Basic development preview/);
|
||||
assert.match(html,/Printed Kull is enabled by default/);
|
||||
assert.match(html,/Combined turn-action Truthtrance questions are unavailable/);
|
||||
assert.match(html,/Combined turn-action questions are available/);
|
||||
assert.match(html,/Unfunded non-CHOAM Karama-dependent bids remain deferred/);
|
||||
assert.match(html,/Some Kull reactions may be unavailable in complex response windows/);
|
||||
const off = act(f.lobby,f.lobby.host,{type:'moduleOption',module:'kullPreview',enabled:false});
|
||||
@@ -39,7 +39,7 @@ void test('public host lobby shows the explicitly selected Kull preview and its
|
||||
assert.equal(unselected.lobbyModules?.kullPreview,false);
|
||||
assert.match(table(unselected),/Kull Wahad · Basic development preview/);
|
||||
assert.match(table(unselected),/The host has turned off the printed Kull preview/);
|
||||
assert.doesNotMatch(table(unselected),/Combined turn-action Truthtrance questions are unavailable/);
|
||||
assert.doesNotMatch(table(unselected),/Combined turn-action questions are available/);
|
||||
const nonhost = table(viewGame(f.lobby,f.actor));
|
||||
assert.match(nonhost,/disabled=""[^>]*type="checkbox"|type="checkbox"[^>]*disabled=""/);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user