'use client'; import { useId, useState } from 'react'; import type { Action } from '@/game/engine'; import type { MoritaniSpecialKaramaView } from '@/game/moritani-special-karama'; import { Button } from './ui/button'; import { CardInspector, CardRules } from './card-inspector'; type Props = { quote: MoritaniSpecialKaramaView | null; act: (action: Action) => void; busy: boolean; /** The engine owns the opportunity's decline action; no Karama is spent. */ declineAction: Action; }; type Disposition = 'unchanged' | 'keep' | 'discard'; export function MoritaniSpecialKarama({ quote, act, busy, declineAction }: Props) { if (!quote) return null; return ( ); } function MoritaniSpecialKaramaChoice({ quote, act, busy, declineAction }: Omit & { quote: MoritaniSpecialKaramaView; }) { const id = useId(); const [activation, setActivation] = useState(''); const [choices, setChoices] = useState>({}); const karama = quote.karamas.find(card => card.id === activation) ?? quote.karamas[0]; const keep = quote.playedCards .filter(card => choices[card.id] === 'keep' && quote.keepableIds.includes(card.id)) .map(card => card.id); const discard = quote.playedCards.filter(card => choices[card.id] === 'discard').map(card => card.id); const reason = !karama ? 'You need an available Karama Card.' : keep.length + discard.length === 0 ? 'Force at least one card to be kept or discarded, or decline without spending a Karama.' : null; return (

Moritani special Karama: opponent’s played cards

After your battle loss, spend one of your Karama Cards to force your opponent to keep or discard selected publicly revealed cards they played. Unchanged cards remain their choice. This uses your once-per-game special power.

{quote.boundary}

{karama && } {quote.playedCards.map((card, index) => { const keepable = quote.keepableIds.includes(card.id); const selected = choices[card.id] ?? 'unchanged'; const disposition = selected === 'keep' && !keepable ? 'unchanged' : selected; return (
{!keepable &&

Force keep is unavailable under the provisional mandatory-disposal precedence.

}
); })} {reason &&

{reason}

}
); }