'use client'; import { useId } from 'react'; import { HelpTip } from './help-tip'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { TRUTH_CARD_NAMES } from '@/game/truthtrance'; import { planClaimText, type PlanClaim } from '@/game/battle-promises'; import { CHEAP_HERO_TRAITOR } from '@/game/traitors'; import type { Action, GameView, Plan } from '@/game/engine'; export function BattleClaimFields({ game: g, value: c, onChange, }: { game: GameView; value: PlanClaim; onChange: (c: PlanClaim) => void; }) { const amountId = useId(); const initial = (kind: string): PlanClaim => kind === 'dial' || kind === 'support' ? { kind, compare: 'eq', value: 0 } : kind === 'weapon' || kind === 'defense' ? { kind, name: null } : kind === 'leader' ? { kind, leader: g.allLeaders[0].id } : { kind: 'kwisatz', use: true }; return ( <> {(c.kind === 'dial' || c.kind === 'support') && ( <> )} {(c.kind === 'weapon' || c.kind === 'defense') && ( )} {c.kind === 'leader' && ( )} {c.kind === 'kwisatz' && ( )} ); } export function BattlePromises({ game: g, fill, act, busy, }: { game: GameView; fill: (plan: Plan) => void; act: (action: Action) => void; busy: boolean; }) { const b = g.battle; if (!b || (!b.truthPromises.length && !b.compliantPreparation)) return null; const me = g.players.find((p) => p.id === g.me)!; const name = (id: string | null) => id === null ? 'None' : (me.hand?.find((c) => c.id === id)?.name ?? g.allLeaders.find((l) => l.id === id)?.name ?? id); const plan = b.compliantPlan; return (

{b.truthPromises.length ? 'Truthtrance commitments' : 'Preparing your committed plan'}{' '}

{b.compliantPreparation && (

Preparation · private

{b.compliantPreparation.waitingForIncome && (

Revival income must resolve before this plan can be funded.

)} {b.compliantPreparation.actions.map((action, index) => (

{index + 1}.{' '} {action.mode === 'special' ? `Spend Karama and discard ${(action.cards as string[]).map(name).join(', ')} to gain ${(action.cards as string[]).length * 3} spice` : typeof action.leader === 'string' ? `Play Ghola to revive ${action.leader === 'kwisatz' ? 'Kwisatz Haderach' : name(action.leader)}` : `Play Ghola to revive ${Number(action.amount)} force${Number(action.amount) === 1 ? '' : 's'}${Number(action.elite) ? `, including ${Number(action.elite)} elite` : ''}`} .

))}

{b.compliantPreparation.actions.length ? 'The next card is still in your hand. Complete the preparation and any response before reviewing and sealing the plan.' : 'The revival is complete. Resolve its income response before reviewing and sealing the plan.'}{' '} Other legal ways to keep your answer remain available.

{b.compliantPreparation.actions[0] && ( )}
)} {plan && (
Review a compliant plan · private

Dial {plan.dial} · Support {plan.support} {!!plan.allyPayment && ` · CHOAM pays ${plan.allyPayment}`}
Leader: {name(plan.leader)}
Weapon: {name(plan.weapon)}
Defense: {name(plan.defense)}
Kwisatz: {plan.kwisatz ? 'Included' : 'Not included'}

These choices satisfy your current commitments. Review and change the other elements before sealing your plan.

)}
); }