'use client'; import { useId, useState } from 'react'; import { splitLocation, territory } from '@/game/board'; import type { Action, GameView } from '@/game/engine'; import { Button } from './ui/button'; export function DiplomatRetreat({ game, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { const id = useId(); const [destination, setDestination] = useState(null); const [choiceIndex, setChoiceIndex] = useState(0); const decision = game.decision?.kind === 'diplomatRetreat' ? game.decision : null; if (!decision || decision.player !== game.me) return null; const selectedDestination = decision.destinations.find((offer) => offer.location === destination) ?? decision.destinations[0]; const choice = selectedDestination?.choices[choiceIndex] ?? selectedDestination?.choices[0]; const selectedLocation = selectedDestination ? splitLocation(selectedDestination.location) : null; return (

Your skilled Diplomat lost this battle. Move up to their strength in undialed physical forces to one empty adjacent non-stronghold territory, or leave the forces where they are.

{selectedDestination && choice && selectedLocation ? ( <> ) : (

No legal retreat destination and force combination is available.

)}
); }