'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { TERROR_DEFINITIONS } from '@/game/moritani-terror'; import { grummanCollectionCanAct, grummanCollectionChoice, } from '@/game/grumman-collection-options'; import { Button } from './ui/button'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean }; export function GrummanCollection({ game, act, busy }: Props) { if ( !game.grummanCollection || game.grummanCollection.player !== game.me || game.decision?.kind !== 'grummanCollection' || game.decision.player !== game.me ) return null; return ( ); } function CollectionChoice({ game, act, busy }: Props) { const offer = game.grummanCollection!; const [token, setToken] = useState(offer.tokens[0]?.id ?? ''); const [destination, setDestination] = useState( offer.destinations[0]?.id ?? '', ); const canAct = grummanCollectionCanAct(game); const choice = grummanCollectionChoice(game, token, destination); const disabled = busy || !canAct || !!offer.blocked; return ( Add one available Terror token to a stronghold to collect 4 spice. You receive the spice only after the addition resolves. Your Terror token setToken(event.target.value)} > {!offer.tokens.length && No available token} {offer.tokens.map((candidate) => ( {TERROR_DEFINITIONS[candidate.kind].name} ))} Destination stronghold setDestination(event.target.value)} > {!offer.destinations.length && ( No available stronghold )} {offer.destinations.map((target) => ( {target.name} ))} {choice.blocked && ( {choice.blocked} )} Removal unavailable: {offer.removeBlocked} { if (choice.action) act(choice.action); }} > Add token and collect 4 spice act({ type: 'decision', event: offer.event, decline: true }) } > Pass Grumman collection ); }
Add one available Terror token to a stronghold to collect 4 spice. You receive the spice only after the addition resolves.
{choice.blocked}
Removal unavailable: {offer.removeBlocked}