From b3843bf18e84cee44efe04fc895e49866fcd758d Mon Sep 17 00:00:00 2001
From: Quintine <15965533+Quintine@users.noreply.github.com>
Date: Mon, 16 Nov 2026 17:36:52 +1100
Subject: [PATCH] Support Advanced Truthtrance ally funding
---
components/truthtrance.tsx | 2 +-
docs/CURRENT_STATUS.md | 14 +-
docs/RULE_DECISIONS.md | 7 +
docs/TRUTHTRANCE_ALLY_FUNDING.md | 31 +++-
game/engine.ts | 21 ++-
game/reference.ts | 2 +-
game/truthtrance.ts | 4 +-
tests/truth-pledge-advanced-controls.test.tsx | 58 ++++++
...th-pledge-advanced-guild-transport.test.ts | 87 +++++++++
tests/truth-pledge-advanced-runtime.test.ts | 168 ++++++++++++++++++
10 files changed, 383 insertions(+), 11 deletions(-)
create mode 100644 tests/truth-pledge-advanced-controls.test.tsx
create mode 100644 tests/truth-pledge-advanced-guild-transport.test.ts
create mode 100644 tests/truth-pledge-advanced-runtime.test.ts
diff --git a/components/truthtrance.tsx b/components/truthtrance.tsx
index 42780f29..e684a97f 100644
--- a/components/truthtrance.tsx
+++ b/components/truthtrance.tsx
@@ -1013,7 +1013,7 @@ export function Truthtrance({
{kind === 'pledgeAid' && <>
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.
} + {!g.truthPledgeTargets.includes(target) &&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.
} >} {!['fact', 'battlePlan', 'futureBattleLeader', 'shipment'].includes(kind) && button( 'Ask publicly', diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md index a165a4ed..c92e0c2c 100644 --- a/docs/CURRENT_STATUS.md +++ b/docs/CURRENT_STATUS.md @@ -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 diff --git a/docs/RULE_DECISIONS.md b/docs/RULE_DECISIONS.md index e5715cfa..b35dfa23 100644 --- a/docs/RULE_DECISIONS.md +++ b/docs/RULE_DECISIONS.md @@ -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 diff --git a/docs/TRUTHTRANCE_ALLY_FUNDING.md b/docs/TRUTHTRANCE_ALLY_FUNDING.md index 56dd237d..6c584a43 100644 --- a/docs/TRUTHTRANCE_ALLY_FUNDING.md +++ b/docs/TRUTHTRANCE_ALLY_FUNDING.md @@ -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 diff --git a/game/engine.ts b/game/engine.ts index dc65a88c..ecb613a5 100644 --- a/game/engine.ts +++ b/game/engine.ts @@ -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; } } diff --git a/game/reference.ts b/game/reference.ts index 672ff836..1a8d81c0 100644 --- a/game/reference.ts +++ b/game/reference.ts @@ -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.', diff --git a/game/truthtrance.ts b/game/truthtrance.ts index 95f0cd6a..3f4a7605 100644 --- a/game/truthtrance.ts +++ b/game/truthtrance.ts @@ -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') { diff --git a/tests/truth-pledge-advanced-controls.test.tsx b/tests/truth-pledge-advanced-controls.test.tsx new file mode 100644 index 00000000..012fbffd --- /dev/null +++ b/tests/truth-pledge-advanced-controls.test.tsx @@ -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/); +}); diff --git a/tests/truth-pledge-advanced-guild-transport.test.ts b/tests/truth-pledge-advanced-guild-transport.test.ts new file mode 100644 index 00000000..ed660757 --- /dev/null +++ b/tests/truth-pledge-advanced-guild-transport.test.ts @@ -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