import type { Campaign, Encounter } from '@/lib/schemas'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/cn'; import { useEncounterAdvisor } from './useEncounterAdvisor'; /** * Contextual encounter-balancing tip. Shows the detected difficulty tendency and, * on demand, a grounded recommendation (AI when configured, deterministic otherwise) * with one-click apply. Renders nothing when there's no tendency to report. */ export function EncounterTipCard({ campaign, encounter }: { campaign: Campaign; encounter: Encounter }) { const { theme, hasMonsters, currentDifficulty, state, suggestion, source, message, canUseLlm, run, apply } = useEncounterAdvisor(campaign, encounter); // Surface when there's a detected tendency, an encounter with monsters to balance, // or an in-progress/ready suggestion. Stay out of the way otherwise. if (!theme && !hasMonsters && state === 'idle') return null; return (
🧠
{theme ? ( <>
{theme.tendency}
{theme.evidence}
) : ( <>
Encounter balance
{currentDifficulty ? ( <>Currently {currentDifficulty} for the party. ) : ( 'Add a creature suggestion for your party.' )}
)} {state === 'ready' && suggestion && (
{source === 'llm' ? 'AI suggestion' : 'Suggested'} → {suggestion.targetDifficulty}

{suggestion.reasoning}

    {suggestion.add.map((a) => (
  • • Add {a.count}× {a.name}
  • ))} {(suggestion.remove ?? []).map((r) => (
  • • Remove {r.count}× {r.name}
  • ))}
{(suggestion.add.length > 0 || (suggestion.remove?.length ?? 0) > 0) && ( )}
)} {message &&

{message}

} {state !== 'ready' && (
)}
); }