/// import * as React from 'react'; const { useState, useEffect } = React; import { startNewGame, undoMove, resignGame, NewGameOptions } from '../services/api'; import { setSoundEnabled, playSound } from '../services/soundService'; interface GameControlsProps { // Theme props removed but kept in comments for future reference // onThemeChange: (theme: 'brown' | 'grey') => void; // currentTheme: 'brown' | 'grey'; } const GameControls: React.FC = () => { const [showNewGameOptions, setShowNewGameOptions] = useState(false); const [soundOn, setSoundOn] = useState(true); const [gameOptions, setGameOptions] = useState({ player_color: 'white', difficulty: 'medium', time_limit: 1.0, use_opening_book: true, enable_analysis: true, }); // Initialize sound settings useEffect(() => { setSoundEnabled(soundOn); }, [soundOn]); const handleNewGame = async () => { try { await startNewGame(gameOptions); setShowNewGameOptions(false); window.location.reload(); // Refresh to reset the board state } catch (error) { console.error('Error starting new game:', error); } }; const handleUndo = async () => { try { await undoMove(); window.location.reload(); // Refresh to update the board state } catch (error) { console.error('Error undoing move:', error); } }; const handleResign = async () => { if (window.confirm('Are you sure you want to resign?')) { try { await resignGame(); window.location.reload(); // Refresh to update the game state } catch (error) { console.error('Error resigning game:', error); } } }; return (
{showNewGameOptions && (

New Game Options

setGameOptions({ ...gameOptions, time_limit: parseFloat(e.target.value) })} />
setGameOptions({ ...gameOptions, use_opening_book: e.target.checked })} className="w-5 h-5 mr-3" />
setGameOptions({ ...gameOptions, enable_analysis: e.target.checked })} className="w-5 h-5 mr-3" />
)}
); }; export default GameControls;