Files
Dune/tests/fixture-truth-movement-waiting-box.ts
T
Quintine 49586efd2f Support waiting-turn Basic ground-movement promises
Allow unused respondents in the current Movement queue to answer against their current owned board and resources. Isolate foreign declarations, prices, flights and searches in detached forecasting without future income/discard assumptions. Preserve native per-player Hajr history. Other players cannot fulfill or close the promise with their own moves/end. Ordinary executable guidance waits until the real owned turn.

Keep an actual already-paid Box decision actionable while waiting. Enumerate its full entitled choice, prioritizing movement cards without excluding ordinary cards that preserve an existing route; pre-payment known-discard rules remain unchanged. Preserve the original event, fee, private inspection and source continuation. Check deferred Emperor gift and Spiritual Advisor costs on their allowed outcome before another player responds. Localize native pending-movement deferral to the actual mover so another waiting owner cannot hide voluntary Box overspending. Minimal profiles may decline optional accompaniment under a positive promise.

Verify 18 files125/125, types/lint and four original-action guidance/paid-choice/table-rendering programmes. Original source19 reverses the unopened classic deal; native44 earns Box1/Hajr1 and genuinely spends Richese Truth, with Guild's actual later question supplying a second ordinary paid candidate. Eight existing-profile runs make32 accepted proposals plus12 separate neutral acknowledgements. Controlled pact/gift, BG losses, original Ornithopter acquisition and native Fremen/Box cases disclose their staging. Paired affordable/unaffordable interruptions preserve exact frames and prevent voluntary route loss.

The production build passes at the initial freeze. Only the regression gains its affordable counterpart afterward; source identity proves every application/build/dependency and other file unchanged, while final tests/types/runtime run again. Final checkpoint/reference prose overlays are separately reviewed. Earlier phases/later rounds, remaining preparations, No-Field/modules, full modes, comprehensive assurance and deployed acceptance remain open. No strategic tuning or saved-room/reset/restart/deployment operation.
2026-10-24 15:31:17 +11:00

71 lines
5.8 KiB
TypeScript

import assert from 'node:assert/strict';
import type { Action, Game } from '../game/engine';
import {
actHajrReplay, advanceHajrReplay, createHajrReplayFixture,
hajrReplayClean, hajrReplayPlayer, type HajrReplayStep,
} from './fixture-hajr-replay';
import { truthMovementBoxInventory } from './fixture-truth-movement-box';
export const actTruthMovementWaitingBox = actHajrReplay;
export const truthMovementWaitingBoxClean = hajrReplayClean;
export const truthMovementWaitingBoxPlayer = hajrReplayPlayer;
export const truthMovementWaitingBoxInventory = truthMovementBoxInventory;
/** Genuine public purchases, first movement turn and an actual spent fact
* question create an ordinary discard before a later waiting-owner promise.
* The caller still owns the Guild question/answer, Box payment/choice, Richese
* turn completion and Emperor's later shipment and ground movement. */
export function createTruthMovementWaitingBoxFixture() {
const base = createHajrReplayFixture({ truthForGuild: true, truthForRichese: true });
const target = base.owner, asker = 'guild', active = 'richese';
const truth = base.guildTruth, richeseTruth = base.richeseTruth;
assert.ok(truth && richeseTruth); assert.notEqual(truth, richeseTruth);
let game = structuredClone(base.acquired);
const actions: HajrReplayStep[] = structuredClone(base.actions.slice(0, base.acquiredActionCount));
const act = (actor: string, action: Action) => { game = actHajrReplay(game, actor, action, actions); };
const reach = (until: (game: Game) => boolean) => { game = advanceHajrReplay(game, until, actions); };
reach(state => state.phase === 5 && state.active === active && hajrReplayClean(state));
const beforeFact = structuredClone(game), factStart = actions.length;
const factQuestion = { kind: 'fact' as const, target,
fact: { kind: 'spice' as const, compare: 'gte' as const, value: 0 } };
assert.ok(hajrReplayPlayer(game, active).hand.some(card => card.id === richeseTruth));
act(active, { type: 'card', card: richeseTruth });
for (const player of game.players)
if (!game.truthtrance!.passed.includes(player.id)) act(player.id, { type: 'truthPass' });
act(active, { type: 'truthAsk', question: factQuestion });
act(target, { type: 'truthAnswer', answer: 'yes' });
reach(hajrReplayClean);
const factActions = structuredClone(actions.slice(factStart));
const owner = hajrReplayPlayer(game, target), originalCards = truthMovementBoxInventory(base.setup);
assert.equal(game.status, 'playing'); assert.equal(game.advanced, false);
assert.equal(game.phase, 5); assert.equal(game.active, active);
assert.ok(game.movementRemaining?.includes(target)); assert.notEqual(game.active, target);
assert.equal(owner.shipped, false); assert.equal(owner.moved, 0);
assert.deepEqual(owner.forces, {}); assert.equal(owner.reserves, 20);
assert.equal(owner.spice, 8, 'The original Box1/Hajr1 purchases leave the native eight-spice wallet');
assert.ok(owner.hand.some(card => card.id === base.box));
assert.ok(owner.hand.some(card => card.id === base.hajr));
assert.ok(hajrReplayPlayer(game, asker).hand.some(card => card.id === truth));
assert.equal(game.discard.filter(card => card.id === richeseTruth).length, 1);
assert.equal(game.discard.filter(card => card.id === truth).length, 0);
assert.equal(game.movementPromises, undefined); assert.ok(!game.pendingNullentropy && !game.truthtrance);
assert.deepEqual(truthMovementBoxInventory(game), originalCards);
return {
game, source: structuredClone(game), base, lobby: base.lobby, setup: base.setup,
beforeStartingDeal: base.beforeStartingDeal, startingDealSelection: base.startingDealSelection,
afterSetup: base.afterSetup, beforePurchases: base.beforePurchases, acquired: base.acquired,
beforeFact, factQuestion, factActions, actions, sourceActionCount: actions.length,
target, owner: target, asker, active, truth, richeseTruth, box: base.box, hajr: base.hajr,
originalCards, balances: Object.fromEntries(game.players.map(player => [player.id, player.spice])),
boxFee: 2, shipmentCost: 1, expectedPaidChoices: [richeseTruth, truth],
claim: { kind: 'movement' as const, target, territory: 'carthag', minimum: 1 },
currentEnd: { type: 'endMovement' } satisfies Action,
shipment: { type: 'ship', territory: 'arrakeen', sector: 10, amount: 1, elite: 0, allyPayment: 0 } satisfies Action,
move: { type: 'move', from: 'arrakeen:10', territory: 'carthag', sector: 11, amount: 1 } satisfies Action,
staging: [
'Original public bare Basic Richese/Emperor/Guild setup selects the two distinct original unopened Truthtrance deals for Richese and Guild, ordinary Spice/Hajr positions and native scalar lotteries only. Emperor actually buys Box1 and Hajr1. The recorded prefix stops at those acquisitions and continues through actual phase controls to Richese\'s first movement turn, before Emperor acts; the original factory\'s later movement/shipment suffix is excluded. Active Richese genuinely plays its original Truth on the current nonnegative-spice fact, Emperor answers Yes and the original neutral discard continuation completes. That physical Truth remains in discard; Guild still holds its distinct original Truth, and Emperor retains bought Box/Hajr, all twenty reserves, zero board forces and its native eight-spice wallet. No hand, wallet, force, queue, active player, phase, promise or pending receipt is installed. The caller\'s later definite Guild answer naturally supplies the second ordinary paid-search candidate. The source stops before that question/answer, any Box fee/choice or Richese turn ending. Neither Truth candidate is a movement card: a valid ordinary paid selection can preserve the future ordinary shipment and ground move.',
],
};
}
export type TruthMovementWaitingBoxFixture = ReturnType<typeof createTruthMovementWaitingBoxFixture>;