import { harassWithdrawNeedsAllocation, quoteHarassWithdraw, type HarassWithdrawPreview, } from '@/game/harass-withdraw'; export function harassWithdrawControlState( preview: HarassWithdrawPreview | null | undefined, selected: boolean, dial: number, support: number, ) { if (!selected) return { blocked: null, returned: null }; if (!preview) return { blocked: 'Harass & Withdraw is not available in this battle.', returned: null, }; try { if ( preview.allowAllocation && harassWithdrawNeedsAllocation(preview, dial, support) ) return { blocked: null, returned: null }; return { blocked: null, returned: quoteHarassWithdraw(preview, dial, support).returned, }; } catch (error) { return { blocked: error instanceof Error ? error.message : 'Choose a supported force commitment.', returned: null, }; } } export function HarassWithdrawGuide({ preview, state, }: { preview: HarassWithdrawPreview | null | undefined; state: ReturnType; }) { if (!preview) return null; return (

Harass & Withdraw

{preview.blocked || state.blocked ? ( {preview.blocked ?? state.blocked} ) : state.returned ? (

Return {state.returned.normal} ordinary and {state.returned.elite}{' '} elite undialed forces to reserves when plans resolve.

) : preview.allowAllocation ? (

After plans are revealed, choose exactly which undialed ordinary and elite forces return to reserves.

) : (

Select this card in either battle-card slot. Your undialed forces return to reserves.

)}

Your leader can still die. An opponent’s successful traitor call cancels the withdrawal. Discard this card after use.

); }