Connect unmodified Smuggler battle collection

New Leader Skills battles bind territory spice to the public plan reveal and automatically pay the controlling player once the selected Smuggler survives, including a loser or captive with no surviving forces. Cap collection at the original single pile and unmodified disc strength. Pending spice cannot fund a plan. Settlement before Sandmaster's after-win addition remains an explicitly documented timing inference; modified strength, multiple positive piles and other module combinations remain gated pending the existing rulings and integration.

Share pre-seal admission across server, controls and all four bot profiles. Expose the public Ecaz card-variant flag so its guard also works in private views. Normalize the selected Kwisatz value once for UI validation and submission. Fix AI selection of unavailable native face-up skilled discs. Show reveal-time pending guidance and an automatic collection notice/chronicle without a new confirmation. Keep unversioned saved battles on their existing behavior.

Bind saved receipts to the original battle, controller, leader, plans, posture and pile; project no internal binding frame. Void collection on leader death, opposing/mutual Traitors and explosion without restoring destroyed spice. Apply captured-leader settlement before normal custody cleanup. Existing room versioning prevents concurrent final votes from paying twice.

Twelve new engine/SQLite tests cover Basic/Advanced winners and losers, caps, empty piles, zero remaining forces, weapon/Traitor/explosion outcomes, captive survival/death custody, Sandmaster ordering, corrupted receipts, immutable pre-seal guards, legacy continuation, legal paths for four profiles and authenticated concurrent/restarted settlement. Independent review prompted the Ecaz gate and stale-Kwisatz corrections and found no further material defect in the bounded delta. A focused regression also identified the missing public Ecaz configuration field, now projected.

Types, lint, 4884 offline tests, production build and 43 HTTP tests passed on the unchanged source fingerprint. Two genuine four-profile Leader Skills samples completed in 265 Basic and 211 Advanced actions with no rejected candidates and 14 JSON/private-view restorations; neither sampled game naturally exercised Smuggler collection, so focused and browser evidence establish that effect.

In isolated browser room YWV8AGKS, the Emperor selected Smuggler, sealed a zero dial, saw six pending spice without early credit, refreshed the pending decision and submitted no Traitor. After the opponent's production-engine final action, the browser showed the 6-8 loss, automatic six-spice collection, explanatory chronicle and restored balance 26 after another refresh. Opponent/setup staging was private and confined to the new QA room. Screenshot acceptance remains open. An initial private verification script compared SQLite null-prototype rows with parsed JSON too strictly; the transaction rolled back and the corrected content comparison passed.

After the reported outage the server was healthy and the previous private QA seat restored. All 1106 baseline rooms, 2314 seats and every original recovery, entry and handover row remain byte-for-byte unchanged; the HTTP/browser checks added 34 rooms and 71 seats. SQLite integrity and foreign keys pass. No restart, migration, database reset or automation was needed. No mode, module or publication gate is opened.

Verified source tree: dc55a36f7bfe108d6529b2e42add019d212648e6c17772b36e06fe73f9443265
This commit is contained in:
Quintine committed 2026-09-20 14:54:52 +10:00
1 parent 9be7dfb9fb
commit 20cc6057e9
15 files changed
+564 -37

No files matched your search

+7 -1
View File
@@ -1,7 +1,8 @@
import { discoveryBotActions } from './discovery-options';
import { recruitsPlayAction } from './recruits';
import type { Card } from './cards';
import { bureaucratBattlePenalty, canUsePlanetologistBattleSpecial, leaderSkillBattleBonus } from './leader-skill-combat';
import { bureaucratBattlePenalty, canUsePlanetologistBattleSpecial, leaderSkillBattleBonus, usesSurvivingSkilledLeader } from './leader-skill-combat';
import { smugglerBattleModeSupported, smugglerBattlePlanBlock } from './smuggler-battle';
import { battleCardSlotEligible, battleCategoryInspectionValue, fixedBattleInspectionMatches, validBattleSlotPair, type BattlePlanInspectionField } from './battle-card-slots';
import { defaultHarassWithdrawAllocation, quoteHarassWithdraw } from './harass-withdraw';
import { leaderSkillStrongholdCount } from './leader-skill-battle-board';
@@ -708,6 +709,7 @@ function plans(g: GameView): Action[] {
(l) =>
!l.dead &&
controlsLeader(me, l) &&
!battleSkills.some(a => a.leader === l.id && a.faceUp && !a.captured) &&
(!l.usedAt || l.usedAt === b.territory),
);
const heroes = (me.hand ?? []).filter((c) => c.kind === 'hero');
@@ -748,6 +750,7 @@ function plans(g: GameView): Action[] {
for (const defense of defenses) {
const kwisatz =
!!leader &&
!(b.smugglerCollectionEnabled && usesSurvivingSkilledLeader(battleSkills, 'smuggler', leader, true)) &&
!!me.kwisatz?.active &&
!me.kwisatz.dead &&
!b.kwisatzBlocked &&
@@ -778,6 +781,9 @@ function plans(g: GameView): Action[] {
) + (kwisatz ? 2 : 0);
const w = me.hand?.find((c) => c.id === weapon);
const d = me.hand?.find((c) => c.id === defense);
if (b.smugglerCollectionEnabled && smugglerBattlePlanBlock({ assignments: battleSkills,
leader: myLeader, weapon: w, defense: d, kwisatz }, smugglerBattleModeSupported(g),
{ territory: b.territory, spice: g.spice })) continue;
if (!battleCardSlotEligible('weapon', w, {planetologistWeapon: specialForLeader(w, leader)})) continue;
const stoneBattle =
isStoneBurner(w) || (inspected && isStoneBurner(enemyWeapon));
+72 -2
View File
@@ -12,6 +12,7 @@ import { beginRihani, chooseRihaniDraw, finishRihani, validateRihani, type Rihan
import { planetologistLeader, planetologistRange, type PlanetologistMovement } from './planetologist-movement';
import { quoteSmugglerNoField, smugglerNoFieldModeSupported, type SmugglerNoFieldCompanion } from './smuggler-no-field';
import { quoteSmugglerShipment, type SmugglerShipment } from './smuggler-shipment';
import { createSmugglerBattle, settleSmugglerBattle, smugglerBattleModeSupported, smugglerBattlePlanBlock, smugglerBattlePile, smugglerBattleSignature, type SmugglerBattleReceipt } from './smuggler-battle';
import { quoteSandmasterMovement, validateSandmasterMovement, type SandmasterMovement, type SandmasterOrder } from './sandmaster-movement';
import { spiceBankerModeSupported, validateSpiceBankerSpend } from './spice-banker';
import { quoteDiplomatDefense, diplomatDefenseModeSupported, type DiplomatDefenseQuote } from './diplomat-defense';
@@ -612,6 +613,9 @@ export type HarassAllocationReceipt = {
stage: 'offered' | 'selected'; selection: HarassWithdrawSelection | null; signature: string;
};
export type Battle = {
/** New battles bind automatic collection to the original public plan reveal. */
smugglerCollectionVersion?: 1;
smugglerCollection?: SmugglerBattleReceipt | null;
/** New battles allow physical withdrawal choice after reveal, never in the sealed plan. */
harassAllocationVersion?: 1;
harassAllocationEvent?: string;
@@ -1592,6 +1596,7 @@ export type Game = {
sukRescue?: { signature: string; completed: boolean };
rihani?: { skill: RihaniSkill; cards: string[]; signature: string; completed: boolean };
sandmaster?: { leader: string; key: string; before: number; after: number };
smugglerCollection?: SmugglerBattleReceipt;
caladanReinforcement?: HomeworldVictoryObligation;
nexusSardaukarCasualties?: string;
moritaniAssassinate?: {event:string;signature:string;continuation?:string};
@@ -5267,6 +5272,7 @@ function leaderSkillsIntegrity(g: Game) {
sandmasterIntegrity(g);
sukRescueIntegrity(g);
rihaniIntegrity(g);
smugglerBattleIntegrity(g);
for (const [owner, plan] of Object.entries(g.battle?.plans ?? {})) {
if (plan.bankerSpice === undefined) continue;
const p = getPlayer(g, owner);
@@ -14031,6 +14037,13 @@ function validatePlan(
);
const w = cardOf(p, plan.weapon),
d = cardOf(p, plan.defense);
if (b.smugglerCollectionVersion === 1) {
const smugglerPlan = { assignments: battleLeaderSkills(g, p), leader: l, weapon: w, defense: d, kwisatz: plan.kwisatz };
const block = smugglerBattlePlanBlock(smugglerPlan, smugglerBattleModeSupported(g), { territory: b.territory, spice: g.spice });
requireRule(!block, block ?? 'Smuggler collection is unavailable for this plan.');
if (smugglerPlan.assignments.some(a => a.skill === 'smuggler' && a.leader === l?.id))
nexusRule(() => smugglerBattlePile(b.territory, g.spice));
}
const planetologistWeapon = canUsePlanetologistWeapon(
g,
p,
@@ -15448,6 +15461,36 @@ function traitorVoters(g: Game, b: Battle) {
function traitorBeneficiary(g: Game, b: Battle, id: string) {
return [b.attacker, b.defender].includes(id) ? id : getPlayer(g, id).ally;
}
function pendingSmugglerBattle(g: Game): SmugglerBattleReceipt | null {
const b = g.battle!;
const frame = JSON.stringify({ plans: b.plans, hidden: b.leaderSkillHidden,
skills: [b.attacker, b.defender].map(id => battleLeaderSkills(g, getPlayer(g, id))) });
const receipts = [b.attacker, b.defender].flatMap(id => {
const p = getPlayer(g, id), plan = b.plans[id];
const receipt = nexusRule(() => createSmugglerBattle({ event: b.event!, turn: g.turn,
territory: b.territory, player: id, frame, spice: g.spice, supported: smugglerBattleModeSupported(g),
plan: { assignments: battleLeaderSkills(g, p),
leader: controlledLeaders(g, p).find(l => l.id === plan.leader && !l.dead),
weapon: cardOf(p, plan.weapon), defense: cardOf(p, plan.defense), kwisatz: plan.kwisatz } }));
return receipt ? [receipt] : [];
});
requireRule(receipts.length <= 1, 'Smuggler needs its unique physical skill card.');
return receipts[0] ?? null;
}
function smugglerBattleIntegrity(g: Game) {
const b = g.battle;
if (b?.smugglerCollectionVersion !== undefined || b?.smugglerCollection !== undefined) {
requireRule(b && b.smugglerCollectionVersion === 1, 'The saved Smuggler collection lost its battle version.');
if (b.revealed) requireRule(JSON.stringify(b.smugglerCollection) === JSON.stringify(pendingSmugglerBattle(g)),
'The saved Smuggler collection changed its original plans, leader or reveal-time spice.');
else requireRule(b.smugglerCollection === undefined, 'Smuggler collection cannot precede public Battle Plans.');
}
const context = g.lastBattleContext, receipt = context?.smugglerCollection;
if (receipt) requireRule(receipt.event === context!.event && receipt.turn === context!.turn &&
receipt.territory === context!.territory && context!.combatants.includes(receipt.player) &&
['collected', 'void'].includes(receipt.stage) && receipt.signature === smugglerBattleSignature(receipt),
'The completed Smuggler collection changed its original battle receipt.');
}
/** Prepare current server-only inputs once; the pure module cannot inspect Game or mutate it. */
function currentBattleResolutionQuote(g: Game, canceledVoter?: string) {
const b = g.battle!;
@@ -15521,7 +15564,11 @@ function currentBattleResolutionQuote(g: Game, canceledVoter?: string) {
!g.homeworlds && !g.nexusCards && !g.discoveryEnabled && !g.strongholdCards && !g.techTokens && !g.expansions.length &&
g.players.every((p) => faction(p.faction).expansion === 'base'),
'These Leader Skill victory effects with expansion factions or other optional modules are still being integrated.');
if (quote.sandmaster) nexusRule(() => sandmasterVictorySpice(b.territory, g.spice));
const smuggler = b.smugglerCollection ? nexusRule(() => settleSmugglerBattle(b.smugglerCollection!,
!(b.smugglerCollection!.player === b.attacker ? quote.leaderDeaths.attacker : quote.leaderDeaths.defender), g.spice)) : null;
if (smuggler) requireRule(Number.isSafeInteger(getPlayer(g, smuggler.receipt.player).spice + smuggler.amount),
'Smuggler collection would overflow the spice balance.');
if (quote.sandmaster) nexusRule(() => sandmasterVictorySpice(b.territory, smuggler?.spice ?? g.spice));
if (quote.rihani) {
const winner = getPlayer(g, quote.winner!);
nexusRule(() => beginRihani(nexusTraitorSnapshot(g), nexusTraitorUniverse(g),
@@ -15542,7 +15589,7 @@ function currentBattleResolutionQuote(g: Game, canceledVoter?: string) {
);
if (quote.homeworldExplosion)
for (const losses of quote.homeworldExplosion.options) quoteHomeworldLoss(g, quote.homeworldExplosion.player, b.territory, losses);
return quote;
return { ...quote, smuggler };
} catch (error) {
if (
error instanceof BattleResolutionQuoteError ||
@@ -15841,6 +15888,17 @@ function resolveBattle(g: Game) {
...(sardaukar?.casualties ? {nexusSardaukarCasualties:sardaukar.receipt.event} : {}),
};
recordMoritaniAssassinateOpportunity(g, b, winner, losingPlayer);
if (quote.smuggler) {
const { receipt, amount } = quote.smuggler;
const collector = getPlayer(g, receipt.player);
if (amount && receipt.key) g.spice[receipt.key] = receipt.before - amount;
collector.spice += amount;
g.lastBattleContext.smugglerCollection = receipt;
log(g, receipt.stage === 'void'
? `${collector.name}'s Smuggler did not survive. Its pending collection is void; no spice was taken from ${combatLocationName(g, b.territory)}.`
: `${collector.name}'s surviving Smuggler collected ${amount} spice from ${combatLocationName(g, b.territory)}. The reveal-time pile held ${receipt.before}; the leader's unmodified strength was ${receipt.strength}. ${receipt.before - amount} spice remains before any after-victory effects.`,
{ faction: collector.faction, name: 'Smuggler collection' });
}
if (winner && quote.sandmaster) {
const placement = nexusRule(() => sandmasterVictorySpice(b.territory, g.spice));
if (placement) {
@@ -23829,6 +23887,7 @@ function applyActionInner(
...choice,
chooserEvent: battleChooserEvent(g.turn, battleOrderAfterBattle(g), g.battleOrder?.uses.length ?? 0),
event: battleEvent,
...(g.leaderSkills ? { smugglerCollectionVersion: 1 as const } : {}),
...(g.mentatQuestionPreview === true && g.leaderSkills && mentatQuestionModeSupported(g) ? { mentatQuestionVersion: 1 as const } : {}),
...(g.leaderSkills && diplomatDefenseModeSupported(g) ? { diplomatDefenseVersion: 1 as const } : {}),
...(g.ecazTreachery ? { harassAllocationVersion: 1 as const } : {}),
@@ -24009,6 +24068,11 @@ function applyActionInner(
if (l?.capturedBy) delete l.concealed;
}
log(g, 'Both battle plans are revealed.');
if (b.smugglerCollectionVersion === 1) {
b.smugglerCollection = pendingSmugglerBattle(g);
if (b.smugglerCollection) log(g,
`${getPlayer(g, b.smugglerCollection.player).name}'s Smuggler may collect ${b.smugglerCollection.amount} spice from the reveal-time pile if the leader survives. That spice is not yet spendable.`);
}
nextRevealedDecision(g);
}
return g;
@@ -24559,6 +24623,7 @@ export function viewGame(state: Game, id: string) {
advisorAccompanyMaximum: spiritualAdvisorMaximum(g, me.id, 'arrakeen'),
},
expansions: g.expansions,
ecazTreachery: !!g.ecazTreachery,
turn: g.turn,
phase: g.phase,
phaseOpening: g.phaseOpening ? { passed: g.phaseOpening.passed } : null,
@@ -25136,6 +25201,11 @@ export function viewGame(state: Game, id: string) {
}
: null,
lateDefense: b.revealed ? (b.lateDefense ?? {}) : {},
smugglerCollectionEnabled: b.smugglerCollectionVersion === 1,
smugglerCollection: b.revealed && b.smugglerCollection
? { player: b.smugglerCollection.player, leader: b.smugglerCollection.leader,
amount: b.smugglerCollection.amount, before: b.smugglerCollection.before }
: null,
diplomatDefense: b.revealed && b.diplomatDefense
? { player: b.diplomatDefense.player, event: b.diplomatDefense.event,
leader: b.diplomatDefense.leader, cards: [...b.diplomatDefense.cards],
+7 -6
View File
@@ -3699,7 +3699,7 @@ export const RULE_TOPICS: RuleTopic[] = [
category: 'Advanced & expansions',
coverage: 'Partial',
developmentStage: 'Prototyped',
summary: 'Fourteen physical skills, private assignment choices, five battle disciplines, Planetologist movement/battle effects and Suk Graduate rescues, Mentat/Bureaucrat scoring and Bureaucrat payment redirection, Sandmaster victory spice, Rihani exchanges, optional Smuggler shipping, Sandmaster route collection sealed Spice Banker battle spending and optional Diplomat base-defense copying in development tables. Other effects and combined-module acceptance remain unfinished.',
summary: 'Fourteen physical skills, private assignment choices, five battle disciplines, Planetologist movement/battle effects and Suk Graduate rescues, Mentat/Bureaucrat scoring and Bureaucrat payment redirection, Sandmaster victory spice, Rihani exchanges, optional Smuggler shipping and unmodified battle collection, Sandmaster route collection, sealed Spice Banker battle spending and optional Diplomat base-defense copying in development tables. Other effects and combined-module acceptance remain unfinished.',
steps: [
'With this optional module, starting Treachery Cards are dealt after prediction and before skill assignment. Every faction privately receives two skills, keeps one, returns the other to the shuffled deck, and assigns its chosen card to an eligible leader. Skill and leader become public before traitor selection.',
'Before Battle Plans, leave the skilled leader face up to keep its normal effect, or move it behind the shield for possible use. A face-up leader cannot be selected for the plan. Concealing it while choosing another leader gives neither effect. A leader that must be used because no alternative remains moves behind the shield automatically.',
@@ -3717,16 +3717,17 @@ export const RULE_TOPICS: RuleTopic[] = [
'Diplomat may use one committed Worthless card as the opponent’s base Shield or Snooper if you played no defense. After both plans reveal, choose the card or decline before traitor decisions. A native Diplomat may protect its own selected trained leader this way; a captive grants no upper effect. The chosen Worthless must be discarded afterward, even if you win. Lower retreat and modified defenses remain unfinished.',
'Mentat has a private developer preview for naming a specific weapon before posture and faction powers. The target privately shows the named held card or chooses another held card. It stays in hand and need not enter a Battle Plan. Every answer uses the same private response step; ordinary activation awaits the user’s timing-design decision. Empty hands skip without an answer. Private history records an observation, not a later hand guarantee.',
'Bureaucrat may redirect two spice from a payment of at least five between two other players, once per phase. The payer still pays in full; the recipient receives two less. Declining keeps the use available for a later payment. Paid bribes qualify when transferred, with the remaining share still unavailable until Mentat Pause. Ordinary auctions, Guild income and Richese sales have connected payment paths; split funding, other payment families and combined modules remain unfinished.',
'Special Sandmaster relocation and Smuggler battle collection, Spice Banker normal income and Diplomat retreat remain missing. Foreign gholas, Face Dancers and combined modules remain unfinished. This development prototype does not enable public module starts.',
'Smuggler records the existing battle-territory spice when plans reveal, capped by the selected leader’s unmodified strength. If that leader survives, it collects automatically even when losing or no forces remain. A captive pays its controller. Pending spice cannot fund the plan. Collection precedes Sandmaster’s addition; a drained pile receives none. Modified strength, multiple positive piles and combined modules remain guarded. Older saved battles keep their original behavior.',
'Special Sandmaster relocation, Spice Banker normal income and Diplomat retreat remain missing. Foreign gholas, Face Dancers and combined modules remain unfinished. This development prototype does not enable public module starts.',
...LEADER_SKILL_CARDS.map(card => `${card.name}. Normal: ${card.normal.join(' ')} Skilled battle: ${card.battle.join(' ')}`),
],
related: ['setup','choam-modules','implementation-checklist'],
checklist: [
{ area:'Implementation',status:'Partial',detail:'Exact fourteen-card custody, source-ordered setup, public capture, concealment, death and own revival connect five role bonuses, Planetologist movement/Special substitution and Suk Graduate casualty rescue. Rihani inspection/exchange and lower Mentat/Bureaucrat/Sandmaster effects are connected. Smuggler normal reserve shipping, the owned Richese No-Field companion and optional Sandmaster ground-route collection are connected. A separately opted-in Mentat preview connects private pre-plan questions and historical observations while ordinary activation awaits the uniform-response decision. Spice Banker lower spending and native Diplomat base Shield/Snooper copying are connected; Spice Banker normal income, other remaining bands, Diplomat retreat and combined modules remain missing. Bureaucrat redirects supported third-party auction, shipment and bribe payments with exact saved once-per-phase use.',evidence:['game/leader-skill-cards.ts','game/leader-skills.ts','game/leader-skill-combat.ts','game/suk-graduate.ts','game/rihani-decipherer.ts','game/mentat-question.ts','game/bureaucrat-payment.ts','game/leader-skill-battle-board.ts','game/smuggler-shipment.ts','game/smuggler-no-field.ts','game/spice-banker.ts','game/sandmaster-movement.ts','game/diplomat-defense.ts','game/engine.ts'] },
{ area:'Player controls',status:'Partial',detail:'Private card/leader selection, readable inspectors, public battle posture and revival draw/decline, Planetologist range/gather controls, Special weapon selection and Suk Graduate physical rescue choices are connected. Rihani has private history and separate keep-new/reveal-old controls; automatic battle effects need no confirmation. Smuggler has explicit ordinary shipping opt-out and No-Field companion opt-in with physical-versus-priced force counts. Banker exposes separate sealed spending and authorized inspection. Sandmaster exposes explicit legal routes and per-territory collection choices. Diplomat offers a named committed Worthless choice or decline after public reveal. Bureaucrat offers redirect or full payment with explicit recipient amounts and deferred bribe custody. Remaining effect controls are missing.',evidence:['components/leader-skills.tsx','components/planetologist-movement.tsx','components/suk-graduate.tsx','components/rihani-decipherer.tsx','components/mentat-question.tsx','components/bureaucrat-payment.tsx','components/leader-skill-battle-guide.tsx','components/smuggler-shipment.tsx','components/spice-banker.tsx','components/sandmaster-movement.tsx','components/diplomat-defense.tsx','components/game-table.tsx'] },
{ area:'AI',status:'Partial',detail:'All four profiles use private offers, legal visibility/revival actions and Planetologist movement/battle candidates and legal Suk Graduate rescues, Rihani exchanges, shared battle scoring, Smuggler reserve/owned No-Field shipments, Sandmaster route collection funded Banker commitments and optional Diplomat copying from public revealed defenses. Bureaucrat uses the public payee alliance to redirect enemy income or preserve allied income. These are legal prototype paths; complete skill strategy and difficulty calibration remain unfinished.',evidence:['game/bots.ts'] },
{ area:'Implementation',status:'Partial',detail:'Exact fourteen-card custody, source-ordered setup, public capture, concealment, death and own revival connect five role bonuses, Planetologist movement/Special substitution and Suk Graduate casualty rescue. Rihani inspection/exchange and lower Mentat/Bureaucrat/Sandmaster effects are connected. Smuggler normal reserve shipping, the owned Richese No-Field companion, unmodified battle collection and optional Sandmaster ground-route collection are connected. A separately opted-in Mentat preview connects private pre-plan questions and historical observations while ordinary activation awaits the uniform-response decision. Spice Banker lower spending and native Diplomat base Shield/Snooper copying are connected; Spice Banker normal income, other remaining bands, Diplomat retreat and combined modules remain missing. Bureaucrat redirects supported third-party auction, shipment and bribe payments with exact saved once-per-phase use.',evidence:['game/leader-skill-cards.ts','game/leader-skills.ts','game/leader-skill-combat.ts','game/suk-graduate.ts','game/rihani-decipherer.ts','game/mentat-question.ts','game/bureaucrat-payment.ts','game/leader-skill-battle-board.ts','game/smuggler-shipment.ts','game/smuggler-no-field.ts','game/smuggler-battle.ts','game/spice-banker.ts','game/sandmaster-movement.ts','game/diplomat-defense.ts','game/engine.ts'] },
{ area:'Player controls',status:'Partial',detail:'Private card/leader selection, readable inspectors, public battle posture and revival draw/decline, Planetologist range/gather controls, Special weapon selection and Suk Graduate physical rescue choices are connected. Rihani has private history and separate keep-new/reveal-old controls; automatic battle effects need no confirmation. Smuggler has explicit ordinary shipping opt-out and No-Field companion opt-in with physical-versus-priced force counts, plus automatic surviving-leader battle collection with reveal-time guidance. Banker exposes separate sealed spending and authorized inspection. Sandmaster exposes explicit legal routes and per-territory collection choices. Diplomat offers a named committed Worthless choice or decline after public reveal. Bureaucrat offers redirect or full payment with explicit recipient amounts and deferred bribe custody. Remaining effect controls are missing.',evidence:['components/leader-skills.tsx','components/planetologist-movement.tsx','components/suk-graduate.tsx','components/rihani-decipherer.tsx','components/mentat-question.tsx','components/bureaucrat-payment.tsx','components/leader-skill-battle-guide.tsx','components/smuggler-shipment.tsx','components/spice-banker.tsx','components/sandmaster-movement.tsx','components/diplomat-defense.tsx','components/game-table.tsx'] },
{ area:'AI',status:'Partial',detail:'All four profiles use private offers, legal visibility/revival actions and Planetologist movement/battle candidates and legal Suk Graduate rescues, Rihani exchanges, shared battle scoring, Smuggler reserve/owned No-Field shipments and unmodified collection plans, Sandmaster route collection funded Banker commitments and optional Diplomat copying from public revealed defenses. Bureaucrat uses the public payee alliance to redirect enemy income or preserve allied income. These are legal prototype paths; complete skill strategy and difficulty calibration remain unfinished.',evidence:['game/bots.ts'] },
{ area:'Documentation',status:'Partial',detail:'All fourteen faces and common rules are recorded. Skilled capture follows public physical-card custody; replacement entitlement and other material timing interpretations remain explicit.',evidence:['docs/LEADER_SKILLS_RULES.md','docs/LEADER_SKILLS_CAPTURE.md','docs/LEADER_SKILLS_RUNTIME.md','docs/PLANETOLOGIST_RULES.md','docs/SUK_GRADUATE_RULES.md','docs/LEADER_BATTLE_EFFECTS.md','docs/MENTAT_QUESTION.md','docs/BUREAUCRAT_PAYMENTS.md','docs/SMUGGLER_SHIPMENT.md','docs/SPICE_BANKER_RUNTIME.md','docs/DIPLOMAT_DEFENSE.md'] },
{ area:'Verification',status:'Partial',detail:'Focused inventory, scoring, Voice, capture, saved private setup/revival Planetologist movement/cancellation and Suk Graduate casualty/SQLite checks, plus Rihani privacy/concurrent recovery battle-effect regressions and Smuggler quote/decision/legacy recovery and Banker funding, death, traitor, privacy and concurrent settlement checks cover this boundary. Diplomat checks cover self-protection, mandatory discard, public-choice privacy, concurrent saved decisions and legacy continuation. Bureaucrat checks cover once-per-phase use, private source receipts and resumed payment custody. Sample games and browser continuation are recorded separately; full module acceptance remains open.',evidence:['tests/leader-skills-engine.test.ts','tests/leader-skills-capture.test.ts','tests/leader-skills-recovery.test.ts','tests/leader-skills-controls.test.ts','tests/suk-graduate.test.ts','tests/suk-graduate-recovery.test.ts','tests/leader-battle-effects.test.ts','tests/leader-battle-effects-recovery.test.ts','tests/leader-battle-effects-controls.test.tsx','tests/mentat-question.test.ts','tests/mentat-question-bots.test.ts','tests/mentat-question-controls.test.tsx','tests/mentat-question-recovery.test.ts','tests/bureaucrat-payment.test.ts','tests/bureaucrat-payment-controls.test.tsx','tests/bureaucrat-payment-bots.test.ts','tests/bureaucrat-payment-recovery.test.ts','tests/smuggler-shipment.test.ts','tests/smuggler-shipment-controls.test.tsx','tests/smuggler-shipment-recovery.test.ts','tests/smuggler-no-field.test.ts','tests/smuggler-no-field-controls.test.tsx','tests/smuggler-no-field-recovery.test.ts','tests/spice-banker.test.ts','tests/spice-banker-recovery.test.ts','tests/spice-banker-controls.test.tsx','tests/sandmaster-movement.test.ts','tests/sandmaster-movement-recovery.test.ts','tests/sandmaster-movement-controls.test.tsx','tests/diplomat-defense.test.ts','tests/diplomat-defense-controls.test.tsx','tests/diplomat-defense-recovery.test.ts'] },
{ area:'Verification',status:'Partial',detail:'Focused inventory, scoring, Voice, capture, saved private setup/revival Planetologist movement/cancellation and Suk Graduate casualty/SQLite checks, plus Rihani privacy/concurrent recovery battle-effect regressions and Smuggler shipment and battle collection, losing/captured survival, Sandmaster order, explosion, legacy and concurrent recovery, and Banker funding, death, traitor, privacy and concurrent settlement checks cover this boundary. Diplomat checks cover self-protection, mandatory discard, public-choice privacy, concurrent saved decisions and legacy continuation. Bureaucrat checks cover once-per-phase use, private source receipts and resumed payment custody. Sample games and browser continuation are recorded separately; full module acceptance remains open.',evidence:['tests/leader-skills-engine.test.ts','tests/leader-skills-capture.test.ts','tests/leader-skills-recovery.test.ts','tests/leader-skills-controls.test.ts','tests/suk-graduate.test.ts','tests/suk-graduate-recovery.test.ts','tests/leader-battle-effects.test.ts','tests/leader-battle-effects-recovery.test.ts','tests/leader-battle-effects-controls.test.tsx','tests/mentat-question.test.ts','tests/mentat-question-bots.test.ts','tests/mentat-question-controls.test.tsx','tests/mentat-question-recovery.test.ts','tests/bureaucrat-payment.test.ts','tests/bureaucrat-payment-controls.test.tsx','tests/bureaucrat-payment-bots.test.ts','tests/bureaucrat-payment-recovery.test.ts','tests/smuggler-battle.test.ts','tests/smuggler-battle-recovery.test.ts','tests/smuggler-shipment.test.ts','tests/smuggler-shipment-controls.test.tsx','tests/smuggler-shipment-recovery.test.ts','tests/smuggler-no-field.test.ts','tests/smuggler-no-field-controls.test.tsx','tests/smuggler-no-field-recovery.test.ts','tests/spice-banker.test.ts','tests/spice-banker-recovery.test.ts','tests/spice-banker-controls.test.tsx','tests/sandmaster-movement.test.ts','tests/sandmaster-movement-recovery.test.ts','tests/sandmaster-movement-controls.test.tsx','tests/diplomat-defense.test.ts','tests/diplomat-defense-controls.test.tsx','tests/diplomat-defense-recovery.test.ts'] },
],
},
{
+79
View File
@@ -0,0 +1,79 @@
import type { Card, Leader } from './cards';
import { faction } from './catalog';
import { splitLocation, validGameLocation } from './board';
import { leaderSkillBattleBonus, usesSurvivingSkilledLeader, type BattleLeaderSkill } from './leader-skill-combat';
export type SmugglerBattleReceipt = {
event: string; turn: number; territory: string; player: string; leader: string;
frame: string; strength: number; key: string | null; before: number; amount: number;
stage: 'pending' | 'collected' | 'void'; signature: string;
};
export function smugglerBattleModeSupported(g: {
expansions: readonly string[]; players: readonly { faction: string }[];
homeworlds?: unknown; nexusCards?: unknown; discoveries?: unknown;
discoveryEnabled?: boolean; strongholdCards?: unknown; techTokens?: unknown; ecazTreachery?: unknown;
}) {
return !g.expansions.length && g.players.every(p => faction(p.faction)?.expansion === 'base') &&
!g.homeworlds && !g.nexusCards && !g.discoveries && !g.discoveryEnabled && !g.strongholdCards && !g.techTokens && !g.ecazTreachery;
}
export type SmugglerBattlePlan = {
assignments: readonly BattleLeaderSkill[];
leader?: Pick<Leader, 'id' | 'strength'>;
weapon?: Card; defense?: Card; kwisatz?: boolean;
};
export function smugglerBattlePlanBlock(plan: SmugglerBattlePlan, supported: boolean,
pile?: { territory: string; spice: Readonly<Record<string, number>> }): string | null {
if (!usesSurvivingSkilledLeader(plan.assignments, 'smuggler', plan.leader?.id, true)) return null;
if (!supported) return 'Smuggler battle collection with expansion factions or other optional modules is still being integrated.';
if (plan.kwisatz || leaderSkillBattleBonus({ assignments: plan.assignments,
selectedLeader: { id: plan.leader!.id, kind: 'disc' }, weapon: plan.weapon,
defense: plan.defense, skilledLeaderSurvives: true }).bonus)
return 'Smuggler collection with modified leader strength awaits its ruling. Choose an unmodified plan or another leader.';
if (pile) {
try { smugglerBattlePile(pile.territory, pile.spice); }
catch (error) { return error instanceof Error ? error.message : 'Smuggler spice is unavailable.'; }
}
return null;
}
export function smugglerBattleSignature(receipt: SmugglerBattleReceipt): string {
return JSON.stringify({ ...receipt, signature: undefined });
}
export function smugglerBattlePile(territory: string, spice: Readonly<Record<string, number>>) {
const piles = Object.entries(spice).filter(([key]) => splitLocation(key).territory === territory);
for (const [key, amount] of piles) {
const at = splitLocation(key);
if (!validGameLocation({}, at.territory, at.sector) || key !== `${at.territory}:${at.sector}` ||
!Number.isSafeInteger(amount) || amount < 0) throw new Error('Smuggler needs a valid spice pile.');
}
const positive = piles.filter(([, amount]) => amount > 0);
if (positive.length > 1) throw new Error('Smuggler collection among multiple spice piles awaits its allocation ruling.');
return positive.length ? { key: positive[0][0], before: positive[0][1] } : { key: null, before: 0 };
}
export function createSmugglerBattle(input: {
event: string; turn: number; territory: string; player: string; frame: string;
plan: SmugglerBattlePlan; supported: boolean; spice: Readonly<Record<string, number>>;
}): SmugglerBattleReceipt | null {
if (!usesSurvivingSkilledLeader(input.plan.assignments, 'smuggler', input.plan.leader?.id, true)) return null;
const blocked = smugglerBattlePlanBlock(input.plan, input.supported);
if (blocked) throw new Error(blocked);
const strength = input.plan.leader!.strength;
if (!input.event || !input.player || !Number.isSafeInteger(input.turn) || input.turn < 1 ||
!Number.isSafeInteger(strength) || strength < 0) throw new Error('Smuggler needs the current battle and an unmodified leader.');
const pile = smugglerBattlePile(input.territory, input.spice);
const receipt: SmugglerBattleReceipt = { event: input.event, turn: input.turn,
territory: input.territory, player: input.player, leader: input.plan.leader!.id,
frame: input.frame, strength, ...pile, amount: Math.min(strength, pile.before), stage: 'pending', signature: '' };
receipt.signature = smugglerBattleSignature(receipt);
return receipt;
}
/** Survival controls both winning and losing leaders; this is not bank/player income. */
export function settleSmugglerBattle(receipt: SmugglerBattleReceipt, survives: boolean, spice: Readonly<Record<string, number>>) {
if (receipt.stage !== 'pending' || receipt.signature !== smugglerBattleSignature(receipt) ||
receipt.amount !== Math.min(receipt.strength, receipt.before) ||
JSON.stringify(smugglerBattlePile(receipt.territory, spice)) !== JSON.stringify({ key: receipt.key, before: receipt.before }))
throw new Error('The saved Smuggler collection changed its reveal-time spice or receipt.');
const amount = survives ? receipt.amount : 0;
const settled: SmugglerBattleReceipt = { ...receipt, stage: survives ? 'collected' : 'void', signature: '' };
settled.signature = smugglerBattleSignature(settled);
return { receipt: settled, amount, spice: receipt.key ? { ...spice, [receipt.key]: receipt.before - amount } : { ...spice } };
}