'use client'; import { useId, useState } from 'react'; import { Bot, UserRound } from 'lucide-react'; import { Button } from '@/components/ui/button'; import type { Action, GameView } from '@/game/engine'; import { BOT_DESCRIPTIONS, DIFFICULTIES, type Difficulty, } from '@/game/bot-profiles'; export type SeatAutopilotProps = { game: GameView; act: (action: Action) => void; busy: boolean; }; /** Voluntary control of the current human seat; the action never names another player. */ export function SeatAutopilot({ game, act, busy }: SeatAutopilotProps) { const id = useId(); const [difficulty, setDifficulty] = useState('Medium'); const own = game.players.find((player) => player.id === game.me); if (!own || own.bot || !['setup', 'playing'].includes(game.status)) return null; if (game.roomControl?.closed) return

The room is closed. AI play and changes to its control are stopped until an administrator reopens it.

; if (own.autopilot) return (

{game.roomControl?.paused ? 'AI decisions are paused with the room. On resume, AI uses only this seat’s available information, with about 1.5 seconds between decisions. You can take back control now.' : <>AI is making this seat’s decisions using only its available information, with about 1.5 seconds between decisions. You keep the seat and its recovery setup. Taking back control stops future AI decisions; completed decisions remain in the game.}

); if (game.roomControl?.paused) return

The room is paused. AI can be enabled after an administrator resumes play.

; return (
Let AI play for me

Autopilot makes setup and game decisions for your seat using only information that seat can see, with about 1.5 seconds between decisions. It may make irreversible decisions, including spending spice, moving forces and committing battle plans. You retain your seat and recovery setup and can take back control. Completed decisions cannot be undone by turning autopilot off.

{BOT_DESCRIPTIONS[difficulty]}

); }