Support Advanced Truthtrance ally funding
Verify and publish checkpoint container / container (push) Successful in 11m4s
Verify and publish checkpoint container / container (push) Successful in 11m4s
This commit is contained in:
1 parent
e1209083e6
commit
b3843bf18e
10 files changed
+383
-11
No files matched your search
@@ -0,0 +1,87 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {territory} from '../game/board';
|
||||
import {type Action, type Game, viewGame} from '../game/engine';
|
||||
import {actTruthAlliance as act, advanceTruthAlliance as advance,
|
||||
truthAllianceClean as clean, truthAllianceInventory as inventory,
|
||||
truthAllianceNexus, truthAlliancePlayer as player} from './fixture-truth-alliance';
|
||||
import {createTruthBidFixture} from './fixture-truth-bid';
|
||||
import {declareTruthBribe} from './fixture-truth-bribe';
|
||||
import {beforeIxSpiceDraw, orderIxSpiceCards} from './fixture-ix-spice-cards';
|
||||
|
||||
/** Public Advanced setup and real turn-one Polar shipment, then a natural
|
||||
* second-turn worm and reciprocal Emperor/Guild alliance. Selected unopened
|
||||
* setup and Spice order are inherited from the native fixture; one actual
|
||||
* Karama is moved between physical card zones to keep permission open. */
|
||||
function fixture() {
|
||||
const base=createTruthBidFixture({advanced:true,window:'waiting',extraGuild:true});
|
||||
let game=advance(base.game,state=>state.turn===1 && state.phase===5 && state.active===base.target && clean(state));
|
||||
assert.ok(!player(game,base.target).shipped);
|
||||
game=act(game,base.target,{type:'ship',territory:'polar_sink',sector:0,amount:2,allyPayment:0});
|
||||
game=advance(game,state=>state.turn===2 && beforeIxSpiceDraw(state));
|
||||
assert.equal(player(game,base.target).forces['polar_sink:0'],2);
|
||||
orderIxSpiceCards(game,['worm','land','land']);
|
||||
game=advance(game,truthAllianceNexus);
|
||||
game=act(game,'guild',{type:'alliance',target:base.target});
|
||||
game=act(game,base.target,{type:'alliance',target:'guild'});
|
||||
game=advance(game,state=>state.phase===5 && state.active===base.target && clean(state));
|
||||
assert.equal(player(game,base.target).ally,'guild');
|
||||
assert.equal(player(game,'guild').ally,base.target);
|
||||
assert.equal(player(game,base.target).forces['polar_sink:0'],2);
|
||||
assert.ok(!player(game,base.target).shipped);
|
||||
const recipient=player(game,base.opponent);
|
||||
if(!recipient.hand.some(card=>card.effect==='karama')) {
|
||||
const index=game.deck.findIndex(card=>card.effect==='karama');assert.ok(index>=0);
|
||||
if(recipient.hand.length>=4)game.deck.push(recipient.hand.pop()!);
|
||||
recipient.hand.push(...game.deck.splice(index,1));
|
||||
}
|
||||
assert.deepEqual(inventory(game),base.originalCards);
|
||||
const sector=territory('red_chasm').sectors.find(value=>value!==game.storm);assert.notEqual(sector,undefined);
|
||||
const transport:Action={type:'guildShip',from:'polar_sink:0',amount:2,
|
||||
territory:'red_chasm',sector,allyPayment:0};
|
||||
return {...base,game,ally:'guild',transport,physical:inventory(game)};
|
||||
}
|
||||
function answerYes(f:ReturnType<typeof fixture>, minimum:number) {
|
||||
let game=declareTruthBribe(f,f.game).game;
|
||||
game=act(game,f.asker,{type:'truthAsk',question:{kind:'pledgeAid',target:f.target,
|
||||
turn:game.turn,phase:5,ally:f.ally,minimum}});
|
||||
assert.ok(viewGame(game,f.target).truthPledgeAnswers?.includes('yes'));
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
return game;
|
||||
}
|
||||
function passResponses(game:Game):Game {
|
||||
for(let i=0;game.response && i<20;i++) {
|
||||
const actor=game.players.find(row=>!game.response!.passed.includes(row.id));assert.ok(actor);
|
||||
game=act(game,actor.id,{type:'passResponse'});
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
void test('Advanced pledge Yes rejects a Guild cross-shipment that consumes its last completion funds',()=>{
|
||||
const f=fixture(), available=player(f.game,f.target).spice;assert.ok(available>=3);
|
||||
const game=answerYes(f,available-1), before=structuredClone(game);
|
||||
assert.throws(()=>act(game,f.target,f.transport));
|
||||
assert.deepEqual(game,before);
|
||||
assert.equal(game.pendingGuildTransport??null,null);
|
||||
assert.ok(!game.pledgePromises?.at(-1)?.fulfilled && !game.pledgePromises?.at(-1)?.released);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
void test('Advanced pledge Yes permits a funded Guild cross-shipment and its native responses',()=>{
|
||||
const f=fixture(), available=player(f.game,f.target).spice;assert.ok(available>=3);
|
||||
let game=answerYes(f,available-2);
|
||||
game=act(game,f.target,f.transport);
|
||||
assert.equal(game.response?.kind,'guildTransportPermission');
|
||||
assert.equal(game.pendingGuildTransport?.cost,2);
|
||||
assert.equal(player(game,f.target).spice,available);
|
||||
game=passResponses(game);
|
||||
// Allow the native rate response too, if one remains after permission.
|
||||
game=passResponses(game);
|
||||
assert.equal(game.pendingGuildTransport??null,null);
|
||||
assert.equal(player(game,f.target).spice,available-2);
|
||||
assert.equal(player(game,f.target).forces['polar_sink:0']??0,0);
|
||||
const guide=viewGame(game,f.target).pledgePromiseGuide;assert.ok(guide);
|
||||
game=act(game,f.target,guide.action);
|
||||
assert.equal(game.pledgePromises?.at(-1)?.fulfilled,true);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
Reference in new issue
Block a user