'use client'; import { useId, useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { CardInspector, CardRules } from './card-inspector'; import { DistransTransferAction } from './distrans-transfer-action'; export function Distrans({ game, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { const id = useId(); const [target, setTarget] = useState(''); const [selection, setSelection] = useState(''); const distrans = game.distrans; if (!distrans) return null; const choice = distrans.choices.find((candidate) => candidate.recipient === target) ?? distrans.choices.find( (candidate) => !candidate.blocked && candidate.cards.length > 0, ) ?? distrans.choices[0]; const recipient = game.players.find( (player) => player.id === choice?.recipient, ); const given = choice?.cards.find((card) => card.id === selection) ?? choice?.cards[0]; const reason = distrans.blocked ?? choice?.blocked ?? (!choice ? 'No recipient is available.' : !given ? 'No other card is available to transfer to this player.' : null); return (
Distrans: transfer a card

Give one other card from your hand to another player with room, then discard Distrans. No spice is paid. The transfer happens immediately, without a recipient confirmation or Karama response.

Provisional bid timing: you may transfer before the first bid or pass on an ordinary auction lot. Once anyone bids or passes, that lot stays blocked while unresolved. Special auctions keep their existing restrictions.

{choice && ( <> {choice.cards.length > 0 && ( <> {given && (
)} )} )} {reason && (

{reason}

)} {!!choice?.unavailable.length && (

Your cards unavailable for this transfer

    {choice.unavailable.map(({ card, reason: blocked }) => (
  • {card.name}

    {blocked}

  • ))}
)}
); }