Files
Dune/components/revealed-battle.tsx
T
Quintine 1380271bb6 Connect Spice Banker sealed battle spending and saved settlement
Prototype one through three own spice as a separate sealed battle commitment. Reserve funds alongside actual force support, add strength only for the surviving skilled leader, and settle once through existing versioned writes. Apply the documented card/core-rule interpretation: payment survives leader death or loss, except for the sole successful traitor caller. Keep printed disc strength and bounty unchanged. Normal income awaits its deferred-custody ruling; combined modules remain gated.

Validation: 54 focused tests; typecheck, lint, 4490 offline tests, production build and 43 HTTP tests passed. Independent rules, privacy, persistence and UI review completed. SQLite tests cover reserved-spice diversion, concurrent settlement, traitor waiver and legacy plans. Browser exercised a three-spice commitment, pending refresh, actual +3 strength and payment, and restored private cards and the next decision. Two genuine four-profile Basic/Advanced samples completed without rejected candidates but did not use Banker spending.

Following another reported outage, the server remained healthy. Preserved all 461 opening rooms and original seat/recovery rows (495 rooms after QA/HTTP). SQLite integrity and foreign keys passed. A fresh online backup captured all 495 rooms, and browser refresh restored the QA seat. No restart or reset was needed.

Verified source tree: 208bf9324ab994b5e59ed50d78998b4dbf8810b3b6799b1a577ef3b84479335f
2026-09-13 20:45:42 +10:00

125 lines
4.5 KiB
TypeScript

import type { GameView } from '@/game/engine';
import { faction } from '@/game/catalog';
import { leaderStrengthLabel } from '@/game/cards';
import { isStoneBurner } from '@/game/battle-cards';
import { stoneBurnerComparison } from '@/game/stone-burner';
import { BattleComponentInspection } from './battle-component-inspection';
export function RevealedBattle({ game }: { game: GameView }) {
const battle = game.battle;
if (!battle?.revealed) return null;
const attackerPlan = battle.plans[battle.attacker];
const defenderPlan = battle.plans[battle.defender];
const comparisons =
battle.cards.some(isStoneBurner) &&
battle.ownForces &&
attackerPlan &&
defenderPlan
? (battle.stoneBurnerContext?.opponentPools ?? []).map((opponent) =>
stoneBurnerComparison(
game.me === battle.attacker ? battle.ownForces! : opponent,
attackerPlan.dial,
attackerPlan.support,
game.me === battle.defender ? battle.ownForces! : opponent,
defenderPlan.dial,
defenderPlan.support,
),
)
: [];
const name = (id: string | null) =>
id
? (game.allLeaders.find((l) => l.id === id)?.name ??
battle.cards.find((c) => c.id === id)?.name ??
id)
: 'None';
return (
<div className="revealed-plans" aria-label="Revealed battle plans">
{Object.entries(battle.plans).map(([id, plan]) => {
const leader = game.allLeaders.find((l) => l.id === plan.leader);
const undialed = [
...new Set(
comparisons.flatMap(
(comparison) =>
comparison[id === battle.attacker ? 'attacker' : 'defender'],
),
),
].sort((a, b) => a - b);
return (
<div key={id}>
<b>{game.players.find((p) => p.id === id)?.name}</b>
<span>
Dial {plan.dial}
{game.advanced ? ` · ${plan.support} spice support` : ''}
{!!plan.allyPayment && ` (${plan.allyPayment} from CHOAM)`}
</span>
{!!plan.bankerSpice && (
<span>Spice Banker: {plan.bankerSpice} spice committed</span>
)}
{battle.native === id && !battle.cards.some(isStoneBurner) && (
<span>
Native Homeworld bonus: +{battle.nativeBattleStrength} to the
battle score, separately from the dial
</span>
)}
<span>Leader: {name(plan.leader)}</span>
{plan.kwisatz && (
<span>
Kwisatz Haderach · +2 if leader survives · protected from
traitors
</span>
)}
<span>Weapon: {name(plan.weapon)}</span>
{undialed.length > 0 && (
<span>
Stone Burner undialed tokens: {undialed.join(' or ')}
{undialed.length > 1
? ' (possible counts before casualty choice)'
: ''}
</span>
)}
{battle.stoneBurner[id] && (
<span>
Stone Burner:{' '}
{battle.stoneBurner[id] === 'kill'
? 'both leaders die'
: 'surviving leader strength ignored'}{' '}
· compare undialed force tokens
</span>
)}
{battle.poisonTooth[id] !== undefined && (
<span>
Poison Tooth: {battle.poisonTooth[id] ? 'activated' : 'unused'}
</span>
)}
<span>Defense in original plan: {name(plan.defense)}</span>
{battle.lateDefense[id] && (
<span>Added after reveal: {name(battle.lateDefense[id])}</span>
)}
<BattleComponentInspection
playerName={
game.players.find((p) => p.id === id)?.name ?? 'Player'
}
cards={battle.cards.filter((card) =>
[
plan.leader,
plan.weapon,
plan.defense,
battle.lateDefense[id],
].includes(card.id),
)}
leader={
leader
? {
name: leader.name,
factionName: faction(leader.faction).name,
strength: leaderStrengthLabel(leader),
}
: undefined
}
/>
</div>
);
})}
</div>
);
}