'use client'; import { useId, useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { territory } from '@/game/board'; import { battleCardLabel } from '@/game/battle-cards'; import { Button } from './ui/button'; import { CardInspector, CardRules } from './card-inspector'; export function MoritaniRetention({ game, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { const groupId = useId(); const [selected, setSelected] = useState(null); const decision = game.decision; if (decision?.kind !== 'moritaniRetention' || decision.player !== game.me) return null; const me = game.players.find((player) => player.id === game.me); if (!me) return null; const cards = (me.hand ?? []).filter((card) => decision.cards.includes(card.id), ); const selectedCard = cards.find((card) => card.id === selected); const owner = game.players.find((player) => player.id === decision.owner); const disabled = busy || !!game.response || !!game.truthtrance; return (

You lost the battle in {territory(decision.territory).name}. Your Moritani ally{owner ? `, ${owner.name},` : ''} lets you choose one eligible card played in that battle to keep. Using this ability is optional.

Declare one card, then the table may respond with Karama before you retain it. If the power is canceled, all these cards are discarded. Declining also discards them.

Choose one card to retain {cards.map((card) => (

{battleCardLabel(card.kind)}

))}
{!cards.length && (

No eligible card remains in your hand. Decline to continue.

)}
); }