Support Advanced Semuta at Truthtrance auction answers
Verify and publish checkpoint container / container (push) Successful in 11m23s
Verify and publish checkpoint container / container (push) Successful in 11m23s
This commit is contained in:
1 parent
dd4222ee92
commit
12060f3112
7 files changed
+383
-12
No files matched your search
@@ -0,0 +1,128 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { viewGame, type Game } from '../game/engine';
|
||||
import { createTruthRicheseBidFixture } from './fixture-truth-richese-bid';
|
||||
import { createTruthRicheseSilentFixture } from './fixture-truth-richese-silent';
|
||||
import {
|
||||
actTruthtranceRichesePromises as act, advanceTruthtranceRichesePromises as advance,
|
||||
createTruthtranceRichesePromisesFixture, passTruthRicheseFreshDiscard,
|
||||
truthtranceRichesePromisesClean as clean, truthtranceRichesePromisesInventory as inventory,
|
||||
truthtranceRichesePromisesPlayer as seat,
|
||||
} from './fixture-truthtrance-richese-promises';
|
||||
|
||||
type Method = 'ordinary' | 'onceAround' | 'silent';
|
||||
type Kind = 'fact' | 'bid' | 'mixed';
|
||||
|
||||
/** Native Advanced setup and auction actions. The original Semuta moves from
|
||||
* Richese's cache into its hand as a disclosed conserved custody supplement;
|
||||
* no bid, wallet, promise or phase is installed. */
|
||||
function fixture(method: Method) {
|
||||
let game: Game = method === 'ordinary'
|
||||
? structuredClone(createTruthtranceRichesePromisesFixture({advanced:true}).earlySource)
|
||||
: structuredClone((method === 'onceAround' ? createTruthRicheseBidFixture(true) : createTruthRicheseSilentFixture(true)).game);
|
||||
const asker = 'atreides', owner = 'richese';
|
||||
if (method === 'ordinary') {
|
||||
game = advance(game, state => state.phase === 3 && !!state.auction && clean(state));
|
||||
if (game.auction!.active === asker) game = act(game,asker,{type:'passBid'});
|
||||
assert.ok(game.auction && game.auction.active !== asker);
|
||||
} else if (method === 'onceAround') {
|
||||
assert.equal(game.richeseAuction?.active,asker);
|
||||
game = act(game,asker,{type:'richeseBid',event:game.richeseAuction!.event,amount:null});
|
||||
}
|
||||
assert.equal(game.semutaAdvancedOrdinaryPreview,true);
|
||||
const cache = game.richeseCache!;
|
||||
const semutaAt = cache.findIndex(card => card.effect === 'semutaDrug'); assert.ok(semutaAt >= 0);
|
||||
assert.notEqual(cache[semutaAt].id,game.richeseAuction?.cardId);
|
||||
const [semuta] = cache.splice(semutaAt,1); seat(game,owner).hand.push(semuta);
|
||||
const cards = inventory(game), truth = seat(game,asker).hand.find(card => card.effect === 'truthtrance'); assert.ok(truth);
|
||||
const target = method === 'ordinary' ? game.auction!.active : 'emperor';
|
||||
assert.notEqual(target,asker);
|
||||
const parent = structuredClone({auction:game.auction, richeseAuction:game.richeseAuction,
|
||||
richeseBidding:game.richeseBidding, richeseFunding:game.richeseFunding, aid:game.aid,
|
||||
turn:game.turn,phase:game.phase,active:game.active,order:game.order});
|
||||
return {game,asker,owner,target,truth:truth.id,semuta:semuta.id,cards,parent,method};
|
||||
}
|
||||
function assertParent(game: Game, f: ReturnType<typeof fixture>) {
|
||||
assert.deepEqual({auction:game.auction, richeseAuction:game.richeseAuction,
|
||||
richeseBidding:game.richeseBidding, richeseFunding:game.richeseFunding, aid:game.aid,
|
||||
turn:game.turn,phase:game.phase,active:game.active,order:game.order},f.parent);
|
||||
}
|
||||
function question(f: ReturnType<typeof fixture>, kind: Kind) {
|
||||
if (kind === 'fact') return {kind:'fact',target:f.target,fact:{kind:'spice',compare:'gte',value:0}};
|
||||
const mixed = {kind:'and',terms:[{kind:'fact',fact:{kind:'spice',compare:'gte',value:0}},
|
||||
{kind:'action',action:{minimum:1}}]};
|
||||
if (f.method === 'ordinary') return kind === 'bid'
|
||||
? {kind:'bid',target:f.target,turn:f.game.turn,lot:f.game.auction!.index+1,minimum:1}
|
||||
: {kind:'mixedBid',target:f.target,turn:f.game.turn,lot:f.game.auction!.index+1,mixed};
|
||||
return kind === 'bid'
|
||||
? {kind:'richeseBid',target:f.target,turn:f.game.turn,event:f.game.richeseAuction!.event,minimum:1}
|
||||
: {kind:'mixedRicheseBid',target:f.target,turn:f.game.turn,event:f.game.richeseAuction!.event,mixed};
|
||||
}
|
||||
|
||||
for (const method of ['ordinary','onceAround','silent'] as const)
|
||||
for (const kind of ['fact','bid','mixed'] as const)
|
||||
for (const claim of [false,true]) void test(
|
||||
`Advanced ${method} ${kind} answer Semuta ${claim ? 'claim' : 'pass'} retains the native auction`, () => {
|
||||
const f = fixture(method); let game = act(f.game,f.asker,{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage === 'priority') {
|
||||
const actor = game.players.find(player => !game.truthtrance!.passed.includes(player.id)); assert.ok(actor);
|
||||
game = act(game,actor.id,{type:'truthPass'});
|
||||
}
|
||||
assert.equal(game.truthtrance?.stage,'ask');
|
||||
game = act(game,f.asker,{type:'truthAsk',question:question(f,kind)});
|
||||
game = act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||
assert.equal(pending.continuation.kind,'truthtranceDiscard');
|
||||
assert.equal(pending.batch.entries[0].card.id,f.truth);
|
||||
assert.equal(game.truthtrance,null);
|
||||
assert.equal(viewGame(game,f.owner).semutaReaction?.canCommit,true);
|
||||
assertParent(game,f);
|
||||
const event = pending.batch.event;
|
||||
game = claim ? act(game,f.owner,{type:'semutaCommit',event}) : passTruthRicheseFreshDiscard(game);
|
||||
assert.equal(game.pendingTreacheryDiscard,null);
|
||||
assert.equal(game.truthtrance,null);
|
||||
assert.equal(seat(game,f.owner).hand.some(card => card.id === f.truth),claim);
|
||||
assert.equal(game.discard.some(card => card.id === f.semuta),claim);
|
||||
assertParent(game,f);
|
||||
if (kind !== 'fact') {
|
||||
const guide = method === 'ordinary' ? viewGame(game,f.target).bidPromiseGuide : viewGame(game,f.target).richeseBidPromiseGuide;
|
||||
assert.ok(guide, 'The native commitment and guide survive the discard response');
|
||||
game = act(game,f.target,guide.action);
|
||||
assert.equal(seat(game,f.target).spice,seat(f.game,f.target).spice,'A declaration does not pay the purchase');
|
||||
if (method === 'silent') {
|
||||
assert.equal(viewGame(game,f.target).richeseAuction?.ownBid,1);
|
||||
assert.equal(viewGame(game,f.asker).richeseAuction?.ownBid,null);
|
||||
assert.equal(viewGame(game,f.asker).richeseAuction?.revealedBids,null);
|
||||
}
|
||||
}
|
||||
assert.deepEqual(inventory(game),f.cards);
|
||||
});
|
||||
|
||||
for (const claim of [false,true]) void test(
|
||||
`Advanced ordinary phase-wide bid Yes survives Truthtrance Semuta ${claim ? 'claim' : 'pass'}`, () => {
|
||||
const f = fixture('ordinary');
|
||||
let game = act(f.game,f.asker,{type:'card',card:f.truth});
|
||||
while (game.truthtrance?.stage === 'priority') {
|
||||
const actor = game.players.find(player => !game.truthtrance!.passed.includes(player.id)); assert.ok(actor);
|
||||
game = act(game,actor.id,{type:'truthPass'});
|
||||
}
|
||||
assert.equal(game.truthtrance?.stage,'ask');
|
||||
game = act(game,f.asker,{type:'truthAsk',question:{kind:'phaseBid',target:f.target,turn:game.turn,minimum:1}});
|
||||
assert.ok(viewGame(game,f.target).truthPhaseBidAnswers?.includes('yes'));
|
||||
game = act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
const pending = game.pendingTreacheryDiscard; assert.ok(pending?.reaction);
|
||||
assert.equal(pending.continuation.kind,'truthtranceDiscard');
|
||||
assert.equal(pending.batch.entries[0].card.id,f.truth);
|
||||
assert.equal(viewGame(game,f.owner).semutaReaction?.canCommit,true);
|
||||
assertParent(game,f);
|
||||
game = claim ? act(game,f.owner,{type:'semutaCommit',event:pending.batch.event}) : passTruthRicheseFreshDiscard(game);
|
||||
assert.equal(game.pendingTreacheryDiscard,null); assert.equal(game.truthtrance,null);
|
||||
assert.equal(seat(game,f.owner).hand.some(card => card.id === f.truth),claim);
|
||||
assertParent(game,f);
|
||||
const guide = viewGame(game,f.target).phaseBidPromiseGuide;
|
||||
assert.ok(guide, 'The native phase-wide bid guide returns after the discard');
|
||||
game = act(game,f.target,guide.action);
|
||||
const receipt = viewGame(game,f.target).phaseBidPromises.find(row => row.player === f.target);
|
||||
assert.ok(receipt?.fulfilled);
|
||||
assert.deepEqual(inventory(game),f.cards);
|
||||
});
|
||||
Reference in new issue
Block a user