'use client'; import { useState } from 'react'; import { territory, splitLocation } from '@/game/board'; import type { Action, GameView } from '@/game/engine'; import { FaceDanceActions, faceDanceForceChoices } from './face-dance-actions'; import { Input } from './ui/input'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean }; export function FaceDanceDecision(props: Props) { const { game } = props; const d = game.decision; if ( d?.kind !== 'faceDance' || d.player !== game.me || !game.players.some((player) => player.id === game.me) ) return null; return ; } function FaceDanceChoice({ game: g, act, busy, }: Props) { const d = g.decision; const me = g.players.find((p) => p.id === g.me)!; const { world, maximum, availableSources } = faceDanceForceChoices(g); const [sources, setSources] = useState>( world ? {} : { reserves: Math.min(me.reserves, maximum), }, ); const [sector, setSector] = useState( d?.kind === 'faceDance' && !world ? territory(d.territory).sectors[0] : 0, ); if (d?.kind !== 'faceDance') return null; const held = me.faceDancers?.some( (c) => !c.revealed && c.leader === d.identity, ); const total = Object.values(sources).reduce((sum, n) => sum + n, 0); const emperorReturn = g.advanced && !!g.homeworlds?.worlds && g.players.some((player) => player.faction === 'emperor' && (player.id === d.winner || d.winners?.includes(player.id))); return ( <>

Face Dancer opportunity

{g.players.find((p) => p.id === d.winner)?.name} won in{' '} {world?.name ?? territory(d.territory).name}. Their battle rewards remain theirs.

{d.blocked && ( {d.blocked} )} {emperorReturn && (

Provisional return: the Emperor’s normal forces return to Kaitain; Sardaukar return to Salusa Secundus. This is a reserve return with no revival fee or income, new battle or additional battle reward.

)} {held ? ( <>

Return the {d.winners ? 'winning allied side’s' : 'winner’s'} {maximum} remaining forces to reserves. Replace up to {maximum} with your forces. The selected winning leader goes to the tanks without a spice bounty.

{world && (

Your native forces already at {world.name} remain there. Choose any additional replacement forces from your positions on Arrakis, or reveal with zero additional forces.

)} {Object.entries(availableSources).map(([key, available]) => ( ))} {!world && ( )}

{total} / {maximum} replacement forces selected

) : (

You have no unrevealed Face Dancer matching the winning leader.

)} ); }