'use client'; import { useState } from 'react'; import type { Action, Decision } from '@/game/engine'; import type { SukReserveDestinations, SukRescueOption } from '@/game/suk-graduate'; import { splitLocation } from '@/game/board'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; export function sukRescueLabel(option: SukRescueOption): string { const total = option.normal + option.elite; if (!total) return 'Do not rescue any forces'; const kept = option.kept ? `keep 1 ${option.kept.kind === 'normal' ? 'ordinary' : 'elite'} ${option.kept.key.startsWith('homeworld:') ? 'in the original Homeworld pool' : `in sector ${splitLocation(option.kept.key).sector}`}; ` : ''; const origins = option.eliteReserves ? ` (cyborgs: ${Object.entries(option.eliteReserves) .map(([key, count]) => `${count} from sector ${splitLocation(key).sector}`).join(', ')})` : ''; return `Save ${option.normal} ordinary + ${option.elite} elite: ${kept}return ${total - (option.kept ? 1 : 0)} to reserves${origins}`; } export function SukGraduatePanel({ decision, act, busy }: { decision: Extract; act: (action: Action) => void; busy: boolean; }) { const [choice, setChoice] = useState(null); const [secondaryAllocation, setSecondaryAllocation] = useState({ normal: 0, elite: 0 }); const option = choice === null ? null : decision.options[choice]; const returned = { normal: (option?.normal ?? 0) - (option?.kept?.kind === 'normal' ? 1 : 0), elite: (option?.elite ?? 0) - (option?.kept?.kind === 'elite' ? 1 : 0), }; const primary = decision.reserveHomes?.find(home => !home.secondary); const secondary = decision.reserveHomes?.find(home => home.secondary); const allocate = !!primary && !!secondary && returned.normal + returned.elite > 0; const allocationValid = !allocate || (['normal', 'elite'] as const).every(kind => Number.isSafeInteger(secondaryAllocation[kind]) && secondaryAllocation[kind] >= 0 && secondaryAllocation[kind] <= returned[kind]); return

Suk Graduate rescue

{decision.mode === 'normal' ? 'Your skilled leader remained face up. Return one of your selected casualties to reserves instead of the Tanks.' : 'Your skilled leader survived. You may save up to three selected casualties. One stays in its original battle pool; the rest return to reserves.'}

Ordinary and elite counters keep their identity. Your paid battle support is unchanged.

{decision.territory.startsWith('homeworld:') &&

Saved counters already in your own Homeworld reserves stay in that same pool. This rescue does not move them between Homeworlds.

} {choice !== null &&

{sukRescueLabel(decision.options[choice])}

} {allocate && primary && secondary &&
Rescue return destinations

Choose how many returning counters go to {secondary.name}. The remainder goes to {primary.name}. The visible default sends all returning counters to {primary.name}; this is a placement choice, not the Emperor revival rule.

{(['normal', 'elite'] as const).map(kind => )}
}
; }