'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { homeworldRevivalDeploymentCanAct, homeworldRevivalDeploymentChoice, homeworldRevivalDeploymentQuantities, } 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 [amount, setAmount] = useState(offer.allocation !== undefined ? 1 : offer.normal + offer.elite); const canAct = homeworldRevivalDeploymentCanAct(game); const quantities = homeworldRevivalDeploymentQuantities(game); const choice = homeworldRevivalDeploymentChoice(game, destination, amount); const allocation = offer.allocation; return (

{offer.kind === 'fedaykin' ? 'Place revived Fedaykin' : 'Place revived forces'}

{allocation !== undefined ? <>

Choose how many remaining starred forces to place now. After this placement's native arrival effects finish, you may place another portion at a different legal destination, or leave all remaining stars in reserves. The eligible batch is fixed by this one original revival.

Provisional per-star interpretation: Southern's face says “forces”; the individual allocation has no publisher clarification.

{allocation &&

{allocation.remaining} starred remaining of {allocation.total} · {allocation.placed} placed · {allocation.kept} kept in reserves

} :

Place the entire eligible revived group in one destination, or leave it in reserves.

}

{offer.normal} ordinary · {offer.elite} starred · {offer.normal + offer.elite} total

{offer.kind === 'fedaykin' ? 'Southern placement uses a sector outside the storm.' : 'Tleilax placement keeps the storm restriction.'} {game.players.some(player => player.faction === 'ixians') && (offer.kind === 'fedaykin' ? ' It does not grant the Force Movement route needed to enter the Hidden Mobile Stronghold.' : ' It does not grant the Ixian route directly into the Hidden Mobile Stronghold.')}

{game.players.some(player => player.faction === 'beneGesserit') &&

{offer.kind === 'tleilax' ? 'Arrakis placement is followed by the normal Bene Gesserit free-force choice.' : 'In Advanced play, entry into Bene Gesserit fighters permits Intrusion.'} {' '}The revived group is already placed before those responses. Preventing a Bene Gesserit power does not undo your revival or use your ordinary shipment.

} {game.players.some(player => player.faction === 'moritani') &&

Entry into an eligible Terror territory gives Moritani its normal choice after the group is placed. Your original revival waits for that effect and any Ambassador reaction; no ordinary shipment is used.

} {allocation !== undefined && } {choice.blocked && (

{choice.blocked}

)}
); } /** Submit the current native choice only; the engine owns arrival and allocation. */ export function HomeworldRevivalDeploymentButtons(props: Props & { destination: string; amount: number }) { const { game, destination, amount } = props; const offer = game.homeworldRevivalDeployment, event = offer?.event, actor = game.me, act = props.act; const signature = JSON.stringify(offer); const current = () => !props.busy && props.game === game && props.act === act && game.me === actor && !!offer && game.homeworldRevivalDeployment === offer && offer.event === event && JSON.stringify(offer) === signature && homeworldRevivalDeploymentCanAct(game); const choice = homeworldRevivalDeploymentChoice(game, destination, amount); return
; }