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
@@ -1013,7 +1013,7 @@ export function Truthtrance({
|
||||
{kind === 'pledgeAid' && <>
|
||||
<PledgeClaimFields minimum={pledgeMinimum} allyName={pledgeAlly ? name(pledgeAlly) : 'their current ally'}
|
||||
disabled={busy || !g.truthPledgeTargets.includes(target)} onChange={setPledgeMinimum} />
|
||||
{!g.truthPledgeTargets.includes(target) && <p className="notice">Choose a player with a mutual ally in a supported quiet Basic Bidding or Movement phase. Earlier definite future-action questions can make this question unavailable.</p>}
|
||||
{!g.truthPledgeTargets.includes(target) && <p className="notice">Choose a player with a mutual ally in a supported quiet Basic or Advanced Bidding or Movement phase. Earlier definite future-action questions can make this question unavailable.</p>}
|
||||
</>}
|
||||
{!['fact', 'battlePlan', 'futureBattleLeader', 'shipment'].includes(kind) && button(
|
||||
'Ask publicly',
|
||||
|
||||
+11
-3
@@ -17,6 +17,15 @@ open mode gates.
|
||||
|
||||
## Current checkpoint and work
|
||||
|
||||
**Advanced Truthtrance ally funding — 16 November. Prototyped / Partial.**
|
||||
Supported quiet Advanced Bidding and Shipment/Movement now use the existing
|
||||
funding-update question, private feasible answers and native escrow. Pending
|
||||
shipment and Guild transport costs constrain future completion without debiting
|
||||
the live wallet. Real Advanced setup, alliance, locked bids, payments and legal
|
||||
bots are covered in eight related unit files, with 50 passing cases. Optional
|
||||
modules, wider combinations, complete games and deployed acceptance remain
|
||||
open. [Scope](TRUTHTRANCE_ALLY_FUNDING.md#advanced-current-phase-prototype--16-november-2026).
|
||||
|
||||
**Basic No-Field reveal at Emperor auction gifts — 16 November. Prototyped /
|
||||
Partial.** Richese can voluntarily reveal during a supported allied gift
|
||||
opportunity or active gift response in ordinary and Richese cache auctions.
|
||||
@@ -28,9 +37,8 @@ open. [Scope](RICHESE_NO_FIELD_RULES.md#basic-reveal-at-emperor-auction-gifts--1
|
||||
|
||||
The latest bounded scan found first versions of the standalone Basic native
|
||||
faction powers inspected, with interaction and complete-game boundaries still
|
||||
open. Next source-clear Advanced candidates for review are the Emperor gift
|
||||
during a Guild-rate response and truthful ally-funding commitments; neither is
|
||||
implemented or verified by this checkpoint.
|
||||
open. An additional source-clear Advanced candidate is an Emperor gift during
|
||||
a Guild-rate response; it is not implemented or verified by this checkpoint.
|
||||
|
||||
**Basic Emperor gifts while Sandtrout waits — 16 November. Prototyped /
|
||||
Partial.** Supported opening, ordinary auction and Richese cache gift windows
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Rule decision index
|
||||
|
||||
## Advanced Truthtrance ally funding — 16 November 2026
|
||||
|
||||
The existing provisional current-phase funding-update question extends to
|
||||
supported Advanced windows using native escrow and payment rules. Pending
|
||||
shipment costs constrain future pledge feasibility without moving funds.
|
||||
[Scope](TRUTHTRANCE_ALLY_FUNDING.md#advanced-current-phase-prototype--16-november-2026).
|
||||
|
||||
## Basic No-Field reveal at Emperor auction gifts — 16 November 2026
|
||||
|
||||
The existing provisional before-Battle reveal ordering extends to supported
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
# Truthtrance ally-funding questions
|
||||
|
||||
## Advanced current-phase prototype — 16 November 2026
|
||||
|
||||
**Prototyped / Partial.** The existing structured question is available in
|
||||
supported quiet Advanced Bidding and Shipment and Movement as well as Basic.
|
||||
It retains the native funding action, winning-bid lock and Advanced payment
|
||||
routing. A respondent's pending unpaid shipment or Guild transport reserves its
|
||||
approved personal cost when testing whether an unfulfilled Yes can still be
|
||||
kept; that projection does not move or charge spice. A No permits inaction even
|
||||
when an existing bid locks a higher pledge and rejects a later qualifying update.
|
||||
|
||||
The user-authorized revised rulebook physical p. 39 / printed p. 37 supplies
|
||||
Truthtrance's question and current-turn obligation; physical p. 15 / printed
|
||||
p. 13 describes allied Bidding and shipment payments. Applying that permission
|
||||
to this update and its current-phase deadline remains the provisional online
|
||||
interpretation described below, not an added publisher ruling. Module and
|
||||
combined-question guards remain; complete Advanced games and deployed
|
||||
acceptance are not established.
|
||||
|
||||
The [Advanced runtime journeys](../tests/truth-pledge-advanced-runtime.test.ts)
|
||||
use public setup, a real worm, alliance, native actions and legal bots; the
|
||||
[rendered controls](../tests/truth-pledge-advanced-controls.test.tsx) show
|
||||
phase-specific private answer availability. [Guild transport journeys](../tests/truth-pledge-advanced-guild-transport.test.ts)
|
||||
exercise a real cross-shipment and pending permission. Their fixtures select
|
||||
unopened deals and Spice order, and stage a Karama for the transport response.
|
||||
Broader faction combinations and save/restore assurance remain due.
|
||||
|
||||
## Current-phase prototype — 29 October 2026
|
||||
|
||||
**Prototyped / Partial.** In a supported quiet Basic Bidding or Shipment and
|
||||
@@ -28,8 +54,9 @@ action questions remain unavailable for the rest of the phase. A prior definite
|
||||
future-action question in the turn also excludes a new funding question. These
|
||||
fences use public question history, avoiding disclosure of private fulfillment
|
||||
or mixed-question residuals. They avoid inventing joint funding or future unlocked
|
||||
escrow. Other modules,
|
||||
Advanced, combined questions and full-game/deployed acceptance remain open.
|
||||
escrow. At this earlier checkpoint, Advanced remained open; the section above
|
||||
records the later extension. Other modules, combined questions and
|
||||
full-game/deployed acceptance remain open.
|
||||
|
||||
The [helper](../game/pledge-promises.ts), [native runtime journeys](../tests/truth-pledge-runtime.test.ts)
|
||||
and [controls](../components/pledge-claim-fields.tsx) record the physical and
|
||||
|
||||
+19
-2
@@ -17058,7 +17058,7 @@ function otherPledgeCommitments(g: Game): boolean {
|
||||
});
|
||||
}
|
||||
function pledgePublicWindow(g: Game): boolean {
|
||||
return g.status === 'playing' && !g.advanced && (g.phase === 3 || g.phase === 5) &&
|
||||
return g.status === 'playing' && (g.phase === 3 || g.phase === 5) &&
|
||||
nativePromiseScopeSupported(g) && !g.kullPreview && !g.semutaPreview && !g.nexusKullPreview &&
|
||||
!g.coalitionPreview && !g.coalitionState &&
|
||||
!g.response && !g.decision && !g.phaseOpening && !g.pendingKarama && !g.pendingTreacheryDiscard &&
|
||||
@@ -17078,6 +17078,8 @@ function pledgeCompletion(g: Game, p: Player, promises = g.pledgePromises ?? [])
|
||||
if (!ally || (g.phase !== 3 && g.phase !== 5)) return null;
|
||||
const required = pledgeRule(() => pledgePromiseRequirements(promises, p.id, g.turn, g.phase, ally));
|
||||
if (!required) return null;
|
||||
// A No-only claim is satisfiable by making no qualifying future update;
|
||||
// this sentinel is not a suggestion to withdraw a currently locked pledge.
|
||||
if (!required.minimum) return {type: 'pledgeAid', amount: 0};
|
||||
const current = g.aid[p.id]?.amount ?? 0;
|
||||
const silent = g.richeseAuction?.method === 'silent' && !g.richeseAuction.outcome &&
|
||||
@@ -17087,7 +17089,22 @@ function pledgeCompletion(g: Game, p: Player, promises = g.pledgePromises ?? [])
|
||||
if (required.maximum !== undefined && amount > required.maximum) return null;
|
||||
try {
|
||||
const trial = structuredClone(g);
|
||||
pledgeAid(trial, getPlayer(trial, p.id), amount);
|
||||
const donor = getPlayer(trial, p.id);
|
||||
// A shipment or Guild transport can be declared before another seat's
|
||||
// response. Its approved price is still in the wallet, but cannot also
|
||||
// witness a future pledge if the declaration completes. The pending
|
||||
// record is cleared before actual payment, so reserve this cost only in
|
||||
// the detached completion quote, never in the live wallet.
|
||||
const shipment = trial.pendingShipment;
|
||||
const offer = shipment?.alliedNoField;
|
||||
const shipmentCost = offer
|
||||
? p.id === offer.owner ? (offer.payer === offer.owner ? shipment.cost : offer.payer === 'both' ? 1 : 0)
|
||||
: p.id === offer.recipient ? (offer.payer === offer.recipient ? shipment.cost : offer.payer === 'both' ? 1 : 0) : 0
|
||||
: shipment?.player === p.id ? shipment.cost - shipment.allyPayment : 0;
|
||||
const transport = trial.pendingGuildTransport;
|
||||
const transportCost = transport?.player === p.id ? transport.cost - transport.allyPayment : 0;
|
||||
donor.spice -= shipmentCost + transportCost;
|
||||
pledgeAid(trial, donor, amount);
|
||||
return {type: 'pledgeAid', amount};
|
||||
} catch (error) { if (error instanceof RuleError) return null; throw error; }
|
||||
}
|
||||
|
||||
+1
-1
@@ -4057,7 +4057,7 @@ export const RULE_TOPICS: RuleTopic[] = [
|
||||
'Declare the card from your hand at any time after cards are dealt. Other players may declare a competing Truthtrance or pass; questions are then asked in storm order. The interrupted phase, response, or battle decision resumes afterward.',
|
||||
'Ask a game-related yes/no question. Named-card, selected-traitor, currently unrevealed Face Dancer and current personal-spice questions are checked by the server. Face Dancer and ordinary Traitor holdings stay distinct. AND and OR combine facts; only the combined answer is published, with no extra inventory details or separate answer for each clause.',
|
||||
'In a new freeform game-fact question, exact personal-spice, named-card, total-hand-size and selected weapon, defense or Worthless category forms are checked as current facts. Supported negative hand questions check that the named face or category count is zero. Category questions use the displayed printed primary role. Bounded questions about predictions, storm dials and forecasts, known Spice Blows, physical force pools, concealed No-Field values, current auction knowledge, and uniquely named Traitors or unrevealed Face Dancers also use the existing checked facts. Two to eight recognized clauses can be joined by one unambiguous AND or OR; only their aggregate answer is published. The recognized interpretation appears before asking and with the question. Other wording and current-turn promises remain player-managed; bots answer unknown. Already-pending older questions keep their original behavior.',
|
||||
'In supported quiet Basic Bidding or Shipment and Movement, ask whether a player will update funding for their current mutual ally to at least a chosen amount this phase. Yes requires a future accepted update while possible; No forbids reaching the amount. An existing pledge alone does not count, a repeated same total does, and the ally chooses whether to spend it. Only one definite funding question is supported per phase; other future-action questions in that phase and optional modules remain separate.',
|
||||
'In supported quiet Basic or Advanced Bidding or Shipment and Movement, ask whether a player will update funding for their current mutual ally to at least a chosen amount this phase. Yes requires a future accepted update while possible; No forbids reaching the amount. An existing pledge alone does not count, a repeated same total does, and the ally chooses whether to spend it. Only one definite funding question is supported per phase; other future-action questions in that phase and optional modules remain separate.',
|
||||
'For current spice, choose Exactly, At least or At most and a nonnegative whole amount. This counts spice personally held when answering, excluding separately pledged aid and incoming payments. It does not ask whether a particular action is affordable or promise that the balance will stay unchanged. A true current-spice answer does not prevent later legal spending.',
|
||||
'For a concealed No-Field, choose its current printed value0,3 or5, not the prospective force pool. A missing or already revealed marker answers No, including for0; a concealed5 with empty reserves still answers Yes to5. Only the respondent sees the expected aggregate before public reply. Neither question nor answer turns up the physical token or commits later use; current-force facts continue to exclude markers.',
|
||||
'The questioned player answers publicly. A definite answer discards the card. If the answer cannot be known, the holder may ask a different question or save Truthtrance for later.',
|
||||
|
||||
+2
-2
@@ -411,10 +411,10 @@ function parseQuestion(g: Game, asker: string, value: unknown): TruthQuestion {
|
||||
check(Object.keys(v).sort().join(',') === 'ally,kind,minimum,phase,target,turn',
|
||||
'Supply the current phase, respondent, ally and funding minimum.');
|
||||
const claim = parsePledgeClaim(v), respondent = g.players.find(player => player.id === v.target)!;
|
||||
check(g.status === 'playing' && !g.advanced && claim.turn === g.turn && claim.phase === g.phase &&
|
||||
check(g.status === 'playing' && claim.turn === g.turn && claim.phase === g.phase &&
|
||||
respondent.ally === claim.ally && g.players.some(player => player.id === claim.ally && player.ally === respondent.id) &&
|
||||
!g.response && !g.decision && !g.phaseOpening && !g.pendingTreacheryDiscard && !g.pendingKarama,
|
||||
'Choose a current mutual ally in a supported quiet Basic Bidding or Shipment and Movement window.');
|
||||
'Choose a current mutual ally in a supported quiet Bidding or Shipment and Movement window.');
|
||||
return {kind: 'pledgeAid', target: v.target, ...claim};
|
||||
}
|
||||
if (v.kind === 'bribe') {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
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 {viewGame, type Game} from '../game/engine';
|
||||
import {actTruthAlliance as act, advanceTruthAlliance as advance, createTruthAllianceFixture,
|
||||
truthAllianceClean as clean, truthAlliancePlayer as player} from './fixture-truth-alliance';
|
||||
import {declareTruthBribe} from './fixture-truth-bribe';
|
||||
|
||||
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 {Truthtrance} = await import('../components/truthtrance');
|
||||
aliases.deregister();
|
||||
|
||||
/** Native Advanced setup, ordinary worm and consensual alliance. The only
|
||||
* staged inputs are the fixture's unopened physical deal and Spice order. */
|
||||
function asked(phase: 3 | 5, tooMuch: boolean) {
|
||||
const f = createTruthAllianceFixture({advanced:true, consent:'allied'});
|
||||
let game = advance(f.game, state => state.phase === phase && (phase !== 3 || !!state.auction) && clean(state));
|
||||
const minimum = tooMuch ? player(game, f.target).spice + (game.aid[f.target]?.amount ?? 0) + 1 : 1;
|
||||
game = declareTruthBribe(f, game).game;
|
||||
assert.ok(viewGame(game, f.asker).truthPledgeTargets.includes(f.target));
|
||||
game = act(game, f.asker, {type:'truthAsk', question:{kind:'pledgeAid',target:f.target,
|
||||
turn:game.turn,phase,ally:f.partner,minimum}});
|
||||
return {game, target:f.target, asker:f.asker};
|
||||
}
|
||||
|
||||
function markup(game:Game, actor:string, busy = false) {
|
||||
return renderToStaticMarkup(createElement(Truthtrance, {game:viewGame(game,actor),busy,act() {
|
||||
assert.fail('Rendering must not send an answer');
|
||||
}}));
|
||||
}
|
||||
|
||||
for (const phase of [3,5] as const) void test(`Advanced phase ${phase} shows only legal Truthtrance funding answers`, () => {
|
||||
const available = asked(phase,false);
|
||||
const view = viewGame(available.game,available.target);
|
||||
assert.ok(view.truthPledgeAnswers?.includes('yes')); assert.ok(view.truthPledgeAnswers?.includes('no'));
|
||||
assert.equal(viewGame(available.game,available.asker).truthPledgeAnswers,null);
|
||||
const html = markup(available.game,available.target);
|
||||
assert.match(html,/Answer Yes/); assert.match(html,/Answer No/);
|
||||
assert.match(html,/future funding update/);
|
||||
const unavailable = asked(phase,true);
|
||||
assert.deepEqual(viewGame(unavailable.game,unavailable.target).truthPledgeAnswers,['no']);
|
||||
const noOnly = markup(unavailable.game,unavailable.target);
|
||||
assert.doesNotMatch(noOnly,/Answer Yes/); assert.match(noOnly,/Answer No/);
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
@@ -0,0 +1,168 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { viewGame, type Action, type Game } from '../game/engine';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { actTruthAlliance as act, advanceTruthAlliance as advance, createTruthAllianceFixture,
|
||||
truthAllianceClean as clean, truthAllianceInventory as inventory,
|
||||
truthAlliancePlayer as player } from './fixture-truth-alliance';
|
||||
import { declareTruthBribe } from './fixture-truth-bribe';
|
||||
import { createTruthBidFixture } from './fixture-truth-bid';
|
||||
import { truthAllianceNexus } from './fixture-truth-alliance';
|
||||
import { beforeIxSpiceDraw, orderIxSpiceCards } from './fixture-ix-spice-cards';
|
||||
|
||||
/** Genuine public Advanced start, actual turn-two worm and reciprocal alliance.
|
||||
* Only unopened setup/deck/Spice order and scalar lotteries are selected by
|
||||
* the shared fixture; wallets, alliances, auctions and commitments are earned. */
|
||||
function fixture(phase: 3 | 5 = 3) {
|
||||
const base = createTruthAllianceFixture({advanced:true, consent:'allied'});
|
||||
const game = advance(base.game, state => state.phase === phase &&
|
||||
(phase !== 3 || !!state.auction) && clean(state));
|
||||
assert.equal(player(game,base.target).ally,base.partner);
|
||||
assert.equal(player(game,base.partner).ally,base.target);
|
||||
assert.deepEqual(inventory(game),base.originalCards);
|
||||
return {...base, game, ally:base.partner, physical:inventory(game)};
|
||||
}
|
||||
/** A public four-seat Advanced game with the Guild. Its original second-turn
|
||||
* worm opens the actual Nexus; Atreides and Emperor explicitly consent before
|
||||
* the Emperor's native Shipment and Movement turn. */
|
||||
function guildShipmentFixture() {
|
||||
const base=createTruthBidFixture({advanced:true,window:'waiting',extraGuild:true});
|
||||
let game=advance(base.game,state=>state.turn===2&&beforeIxSpiceDraw(state));
|
||||
orderIxSpiceCards(game,['worm','land','land']);
|
||||
game=advance(game,truthAllianceNexus);
|
||||
game=act(game,base.opponent,{type:'alliance',target:base.target});
|
||||
game=act(game,base.target,{type:'alliance',target:base.opponent});
|
||||
game=advance(game,state=>state.phase===5&&state.active===base.target&&clean(state));
|
||||
assert.equal(player(game,base.target).ally,base.opponent);
|
||||
assert.equal(player(game,base.opponent).ally,base.target);
|
||||
assert.ok(!player(game,base.target).shipped);
|
||||
assert.deepEqual(inventory(game),base.originalCards);
|
||||
return {...base,game,ally:base.opponent,physical:inventory(game)};
|
||||
}
|
||||
function ask(f:{game:Game;asker:string;target:string;ally:string;truths:string[]}, source:Game, minimum:number) {
|
||||
let game=declareTruthBribe(f,source).game;
|
||||
assert.ok(viewGame(game,f.asker).truthPledgeTargets.includes(f.target));
|
||||
game=act(game,f.asker,{type:'truthAsk',question:{kind:'pledgeAid',target:f.target,
|
||||
turn:game.turn,phase:game.phase,ally:f.ally,minimum}});
|
||||
return game;
|
||||
}
|
||||
function rejected(game:Game, id:string, action:Action) {
|
||||
const before=structuredClone(game);
|
||||
assert.throws(()=>act(game,id,action));assert.deepEqual(game,before);
|
||||
}
|
||||
function promise(game:Game) {
|
||||
const row=game.pledgePromises?.at(-1);assert.ok(row);return row;
|
||||
}
|
||||
function passResponse(game:Game) {
|
||||
for(let n=0;game.response&&n<20;n++) {
|
||||
const responder=game.players.find(row=>!game.response!.passed.includes(row.id));assert.ok(responder);
|
||||
game=act(game,responder.id,{type:'passResponse'});
|
||||
}
|
||||
assert.equal(game.response,null);return game;
|
||||
}
|
||||
|
||||
for(const phase of [3,5] as const) void test(`Advanced phase ${phase} pledge Yes preserves native escrow and bot continuation`,()=>{
|
||||
const f=fixture(phase);
|
||||
let game=act(f.game,f.target,{type:'pledgeAid',amount:1});
|
||||
const before=structuredClone(game),recipientSpice=player(game,f.ally).spice;
|
||||
game=ask(f,game,4);
|
||||
assert.ok(viewGame(game,f.target).truthPledgeAnswers?.includes('yes'));
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
assert.ok(!promise(game).fulfilled);
|
||||
const guide=viewGame(game,f.target).pledgePromiseGuide;assert.ok(guide);
|
||||
assert.equal(guide.action.type,'pledgeAid');assert.equal(guide.action.amount,4);
|
||||
for(const difficulty of DIFFICULTIES) {
|
||||
const view=viewGame(game,f.target);view.players.find(row=>row.id===f.target)!.bot=difficulty;
|
||||
const action=botActions(view)[0];assert.ok(action,difficulty);
|
||||
assert.doesNotThrow(()=>act(game,f.target,action),difficulty);
|
||||
}
|
||||
game=act(game,f.target,guide.action);
|
||||
assert.equal(promise(game).fulfilled,true);
|
||||
assert.equal(game.aid[f.target].recipient,f.ally);assert.equal(game.aid[f.target].amount,4);
|
||||
assert.equal(player(game,f.target).spice,player(before,f.target).spice-3);
|
||||
assert.equal(player(game,f.ally).spice,recipientSpice);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
for(const phase of [3,5] as const) void test(`Advanced phase ${phase} pledge No prevents qualifying future updates`,()=>{
|
||||
const f=fixture(phase);let game=ask(f,f.game,3);
|
||||
assert.ok(viewGame(game,f.target).truthPledgeAnswers?.includes('no'));
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'no'});
|
||||
game=act(game,f.target,{type:'pledgeAid',amount:2});
|
||||
const aid=structuredClone(game.aid[f.target]),spice=player(game,f.target).spice;
|
||||
rejected(game,f.target,{type:'pledgeAid',amount:3});
|
||||
assert.deepEqual(game.aid[f.target],aid);assert.equal(player(game,f.target).spice,spice);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
void test('Advanced pledge excludes an unaffordable Yes without mutating native resources',()=>{
|
||||
const f=fixture(), game=ask(f,f.game,player(f.game,f.target).spice+1);
|
||||
assert.deepEqual(viewGame(game,f.target).truthPledgeAnswers,['no']);
|
||||
rejected(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
});
|
||||
|
||||
void test('Advanced pledge Yes blocks voluntary spending that would make its update impossible',()=>{
|
||||
const f=fixture();let game=ask(f,f.game,4);
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
const available=player(game,f.target).spice;
|
||||
rejected(game,f.target,{type:'bribe',target:f.asker,amount:available-1});
|
||||
assert.ok(!promise(game).fulfilled&&!promise(game).released);
|
||||
const guide=viewGame(game,f.target).pledgePromiseGuide;assert.ok(guide);
|
||||
game=act(game,f.target,guide.action);assert.equal(promise(game).fulfilled,true);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
void test('Advanced Yes rejects an unaffordable pending Guild shipment without mutating state',()=>{
|
||||
const f=guildShipmentFixture(),available=player(f.game,f.target).spice;
|
||||
assert.ok(available>=4);
|
||||
let game=ask(f,f.game,available-1);
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
const ship:Action={type:'ship',amount:1,territory:'polar_sink',sector:0,allyPayment:0};
|
||||
rejected(game,f.target,ship);
|
||||
assert.ok(!promise(game).fulfilled&&!promise(game).released);
|
||||
assert.equal(game.pendingShipment??null,null);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
void test('Advanced Yes permits a funded Guild shipment and its original continuation',()=>{
|
||||
const f=guildShipmentFixture(),available=player(f.game,f.target).spice;
|
||||
assert.ok(available>=4);
|
||||
let game=ask(f,f.game,available-2);
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'yes'});
|
||||
const before=structuredClone(game);
|
||||
game=act(game,f.target,{type:'ship',amount:1,territory:'polar_sink',sector:0,allyPayment:0});
|
||||
assert.equal(game.decision?.kind,'guildShipment');assert.ok(game.pendingShipment);
|
||||
assert.equal(player(game,f.target).spice,player(before,f.target).spice);
|
||||
game=act(game,'guild',{type:'decision',allow:true});
|
||||
game=passResponse(game);
|
||||
assert.equal(game.pendingShipment??null,null);
|
||||
assert.equal(player(game,f.target).spice,available-2);
|
||||
assert.equal(player(game,f.target).reserves,player(before,f.target).reserves-1);
|
||||
const guide=viewGame(game,f.target).pledgePromiseGuide;assert.ok(guide);
|
||||
game=act(game,f.target,guide.action);assert.equal(promise(game).fulfilled,true);
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
|
||||
void test('Advanced No remains available with a locked winning bid and rejects a qualifying update',()=>{
|
||||
const f=fixture();let game=act(f.game,f.target,{type:'pledgeAid',amount:4});
|
||||
game=advance(game,state=>state.auction?.active===f.ally && clean(state));
|
||||
game=act(game,f.ally,{type:'bid',amount:5,allyPayment:4});
|
||||
assert.equal(game.auction?.bidder,f.ally);assert.equal(game.auction?.allyPayment,4);
|
||||
game=ask(f,game,4);
|
||||
assert.ok(viewGame(game,f.target).truthPledgeAnswers?.includes('no'));
|
||||
game=act(game,f.target,{type:'truthAnswer',answer:'no'});
|
||||
const bid=structuredClone(game.auction), aid=structuredClone(game.aid[f.target]);
|
||||
rejected(game,f.target,{type:'pledgeAid',amount:4});
|
||||
rejected(game,f.target,{type:'pledgeAid',amount:5});
|
||||
assert.deepEqual(game.auction,bid);assert.deepEqual(game.aid[f.target],aid);
|
||||
const owner=player(game,f.target).spice,buyer=player(game,f.ally).spice;
|
||||
game=advance(game,state=>state.decision?.kind==='auctionPayment');
|
||||
if(game.pendingEmperorAuctionGift)game=act(game,f.target,{type:'emperorAuctionGiftContinue',event:game.pendingEmperorAuctionGift.event});
|
||||
if(game.decision?.kind==='auctionPayment')game=act(game,f.ally,{type:'decision',karama:false});
|
||||
game=passResponse(game);
|
||||
assert.equal(game.aid[f.target]?.amount??0,0);
|
||||
assert.equal(player(game,f.ally).spice,buyer-1);
|
||||
assert.equal(player(game,f.target).spice,owner+1,'Advanced sends the ally-funded portion to the bank');
|
||||
assert.deepEqual(inventory(game),f.physical);
|
||||
});
|
||||
Reference in new issue
Block a user