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 (
{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 (
{game.players.find((p) => p.id === id)?.name} Dial {plan.dial} {game.advanced ? ` · ${plan.support} spice support` : ''} {!!plan.allyPayment && ` (${plan.allyPayment} from CHOAM)`} {battle.native === id && !battle.cards.some(isStoneBurner) && ( Native Homeworld bonus: +{battle.nativeBattleStrength} to the battle score, separately from the dial )} Leader: {name(plan.leader)} {plan.kwisatz && ( Kwisatz Haderach · +2 if leader survives · protected from traitors )} Weapon: {name(plan.weapon)} {undialed.length > 0 && ( Stone Burner undialed tokens: {undialed.join(' or ')} {undialed.length > 1 ? ' (possible counts before casualty choice)' : ''} )} {battle.stoneBurner[id] && ( Stone Burner:{' '} {battle.stoneBurner[id] === 'kill' ? 'both leaders die' : 'surviving leader strength ignored'}{' '} · compare undialed force tokens )} {battle.poisonTooth[id] !== undefined && ( Poison Tooth: {battle.poisonTooth[id] ? 'activated' : 'unused'} )} Defense in original plan: {name(plan.defense)} {battle.lateDefense[id] && ( Added after reveal: {name(battle.lateDefense[id])} )} 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 } />
); })}
); }