'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { biddingEndCanAct, biddingEndDiscardChoice, } from '@/game/bidding-end-options'; import { Button } from '@/components/ui/button'; import { CardInspector } from './card-inspector'; export function BiddingEnd({ game, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { if (!game.biddingEnd) return null; return ( ); } function BiddingEndChoice({ game: g, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { const [selected, setSelected] = useState([]); const end = g.biddingEnd!; const me = g.players.find((p) => p.id === g.me)!; const canAct = biddingEndCanAct(g); const heldSelection = selected.filter((id) => me.hand?.some((card) => card.id === id), ); const choice = biddingEndDiscardChoice(g, heldSelection); const market = g.choamMarket?.owner === g.me ? g.choamMarket : null; const kaitain = end.kaitain?.owner === g.me; const send = (action: Action) => act({ ...action, type: 'biddingEnd', event: end.event }); return (

End of Bidding

Optional card actions remain available until everyone below is ready. A new action clears readiness so the table can respond to the change.

    {end.owners.map((id) => (
  • {g.players.find((p) => p.id === id)?.name}:{' '} {end.ready.includes(id) ? 'Ready' : 'Choosing'}
  • ))}
{kaitain && ( <>

Kaitain paid discards

Pay 2 spice per chosen Treachery Card. Discarding a card does not play its effect.

{!end.kaitain!.eligible && (

Kaitain must have high population to use paid discards.

)}
{me.hand?.map((card) => (
))}

{heldSelection.length} selected · {choice.cost} spice · You have{' '} {me.spice ?? 0} spice.

{choice.blocked &&

{choice.blocked}

} )} {market && ( <>

CHOAM card market

Sales reveal the card and give the table a Karama response. Trade offers stay private to you and your ally.

{market.worthlessSaleBlocked && (

{market.worthlessSaleBlocked}

)} {market.sales?.map((sale) => ( ))} {!market.sales?.length && (

No eligible sales remain this phase.

)} {market.canTrade && ( <>

Offer your ally a card

{me.hand?.map((card) => (
))} )} )} {end.owners.includes(g.me) && ( )}
); }