import React from 'react' import { GameState, CHESS_MODELS } from '../types/chess' import { VolumeSlider } from './VolumeSlider' import '../styles/GameControls.css' export const GameControls: React.FC<{ gameState: GameState audioEnabled: boolean volumeSettings: { ambient: number game: number } selectedModel: string onStartGame: () => void onResignGame: () => void onToggleColor: () => void onToggleAudio: () => void onVolumeChange: (type: "ambient" | "game", value: number) => void onModelChange: (modelId: string) => void }> = ({ gameState, audioEnabled, volumeSettings, selectedModel, onStartGame, onResignGame, onToggleColor, onToggleAudio, onVolumeChange, onModelChange }) => { const getMainButtonText = () => { if (gameState.gameActive) { return '❌ Resign Game' } return '🎮 Start Game' } const getMainButtonAction = () => { if (gameState.gameActive) { return onResignGame } return onStartGame } const getColorButtonText = () => { return `⚪ Play as ${gameState.playerColor === 'w' ? 'White' : 'Black'}` } const getAudioButtonText = () => { return `🔊 Audio: ${audioEnabled ? 'ON' : 'OFF'}` } const getGameStatus = () => { if (gameState.aiModelLoading) { return (
Loading AI model
) } if (gameState.gameActive) { if (gameState.aiThinking) { return (
AI is thinking
) } else if (gameState.board.turn() === gameState.playerColor) { return `Your turn (${gameState.playerColor === 'w' ? 'White' : 'Black'})` } else { return `AI turn (${gameState.playerColor === 'w' ? 'Black' : 'White'})` } } else if (gameState.gameResult?.isGameOver) { return gameState.gameResult.message } else { const aiStatusText = gameState.aiModelLoaded ? '' : ' (AI: Fallback mode)' return `Click 'Start Game' to begin${aiStatusText}` } } return (
{getGameStatus()}
{!gameState.gameActive && ( <>
)}
{audioEnabled && (

Audio Volume

onVolumeChange('ambient', value)} /> onVolumeChange('game', value)} />
)}
) }