'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { homeworldRevivalDeploymentCanAct, homeworldRevivalDeploymentChoice, } from '@/game/homeworld-revival-deployment-options'; import { Button } from './ui/button'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean; }; export function HomeworldRevivalDeployment({ game, act, busy }: Props) { if ( !game.homeworldRevivalDeployment || game.homeworldRevivalDeployment.player !== game.me || game.decision?.kind !== 'homeworldRevivalDeployment' || game.decision.player !== game.me ) return null; return ( ); } function DeploymentChoice({ game, act, busy }: Props) { const offer = game.homeworldRevivalDeployment!; const [destination, setDestination] = useState( offer.destinations.find((target) => !target.blocked)?.id ?? '', ); const canAct = homeworldRevivalDeploymentCanAct(game); const choice = homeworldRevivalDeploymentChoice(game, destination); const amount = offer.normal + offer.elite; return ( {offer.kind === 'fedaykin' ? 'Place revived Fedaykin' : 'Place revived forces'} Place the entire eligible revived group in one destination, or leave it in reserves. {offer.normal} ordinary · {offer.elite} starred · {amount} total Revival destination setDestination(event.target.value)} > {!offer.destinations.some((target) => !target.blocked) && ( No legal revival destination )} {offer.destinations.map((target) => ( {target.name} {target.blocked ? ` — ${target.blocked}` : ''} ))} {choice.blocked && ( {choice.blocked} )} { if (choice.action) act(choice.action); }} > Place {amount} revived {amount === 1 ? 'force' : 'forces'} act({ type: 'decision', event: offer.event, decline: true }) } > Leave in reserves ); }
Place the entire eligible revived group in one destination, or leave it in reserves.
{offer.normal} ordinary · {offer.elite} starred · {amount} total
{choice.blocked}