'use client'; import { useId } from 'react'; import { Button } from '@/components/ui/button'; import { BOT_DESCRIPTIONS, DIFFICULTIES } from '@/game/bot-profiles'; import { FACTIONS } from '@/game/catalog'; import type { Action, GameView } from '@/game/engine'; import { quoteLobbyBotConfiguration, type LobbyBotConfiguration, } from '@/game/lobby-bot-configuration'; import { PLAYER_CIRCLE_SECTORS } from '@/game/player-positions'; export function LobbyBotControls({ g, target, busy, act, }: { g: GameView; target: string; busy: boolean; act: (action: Action) => void; }) { const id = useId(); const player = g.players.find((entry) => entry.id === target); if (g.status !== 'lobby' || g.host !== g.me || !player?.bot) return null; const current: LobbyBotConfiguration = { target, difficulty: player.bot, faction: player.faction, position: g.playerPositions[target], }; const context = { ...g, positions: g.playerPositions }; const quote = (change: Partial) => quoteLobbyBotConfiguration(context, g.me, { type: 'configureBot', ...current, ...change, }); const change = (update: Partial) => { const result = quote(update); if (!busy && result.ok && result.changed) act({ type: 'configureBot', ...result.configuration }); }; return (
Configure {player.name}

Changes save immediately. Human players must confirm readiness again.

{BOT_DESCRIPTIONS[current.difficulty]}

Circles determine storm order.

); }