'use client'; import { useState } from 'react'; import { territory, splitLocation } from '@/game/board'; import type { Action, GameView } from '@/game/engine'; import { Button } from './ui/button'; import { Input } from './ui/input'; export function FaceDanceDecision({ game: g, act, busy, }: { game: GameView; act: (a: Action) => void; busy: boolean; }) { const d = g.decision; const me = g.players.find((p) => p.id === g.me)!; const maximum = d?.kind === 'faceDance' ? Object.entries(g.players.find((p) => p.id === d.winner)!.forces) .filter(([key]) => splitLocation(key).territory === d.territory) .reduce((sum, [, count]) => sum + count, 0) : 0; const [sources, setSources] = useState>({ reserves: Math.min(me.reserves, maximum), }); const [sector, setSector] = useState( d?.kind === 'faceDance' ? 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); return ( <>

Face Dancer opportunity

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

{held ? ( <>

Return the winner’s {maximum} remaining forces to reserves. Replace up to {maximum} with your forces. Their leader goes to the tanks without a spice bounty.

{Object.entries({ reserves: me.reserves, ...me.forces }).map( ([key, available]) => ( ), )}

{total} / {maximum} replacement forces selected

) : (

You have no unrevealed Face Dancer matching the winning leader.

)} ); }