'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { gameTerritories } from '@/game/board'; import { nexusAdvisorAction, nexusAdvisorCanAct, } from '@/game/nexus-advisor-options'; import { Button } from './ui/button'; type Props = { game: GameView; act: (action: Action) => void; busy: boolean }; export function NexusAdvisors({ game, act, busy }: Props) { const state = game.nexusAdvisors; if (state?.pending) { const places = gameTerritories(game); return (

{game.players.find((p) => p.id === state.pending!.owner)?.name ?? 'Bene Gesserit'}{' '} declared advisor conversion in{' '} {state.pending.territories .map( (id) => places.find((t) => t.id === id)?.name ?? 'an unavailable territory', ) .join(', ')} .

Karama can cancel the entire selection. The advisors become fighters together after this response.

); } if ( game.nexusCards?.card !== 'beneGesserit' || game.players.find((p) => p.id === game.me)?.faction !== 'beneGesserit' || !state?.offer ) return null; return ( ); } function AdvisorSelection({ game, act, busy }: Props) { const offer = game.nexusAdvisors!.offer!; const [selected, setSelected] = useState([]); const places = gameTerritories(game); const eligible = offer.territories.filter( (choice) => !choice.blocked && choice.count > 0, ); const disabled = busy || !nexusAdvisorCanAct(game); const action = nexusAdvisorAction(game, offer.event, selected); return (

Bene Gesserit Nexus · Cunning

Choose territories whose advisors will become fighters. Every Bene Gesserit force in each selected territory changes together, across all sectors.

This spends your Nexus card once. Karama may cancel the entire selection. It costs no spice and uses no shipment or movement allowance.

Provisional card exception: Cunning may convert freshly accompanied or storm-bound advisors in place. Ordinary flipping, storm movement and battle restrictions remain unchanged.

{offer.blocked &&

{offer.blocked}

}
{offer.territories.map((choice) => { const name = places.find((t) => t.id === choice.territory)?.name ?? 'Unavailable territory'; return (
{choice.blocked &&

{choice.blocked}

}
); })} {!eligible.length && (

No advisor group is currently available for this conversion.

)}

{selected.length} {selected.length === 1 ? 'territory' : 'territories'}{' '} selected.

); }