feat: prepare vim-sudoku for unified API implementation
- Archive previous implementation attempt (src -> src_failed) - Create comprehensive IMPLEMENTATION_PLAN.md with phased approach - Create IMPLEMENTATION.md to track implementation progress - Update example app to match vim-maze patterns: - Simplify UI to desktop-only (no mobile support) - Add score metrics display (time, keystrokes, final score) - Update instructions for sudoku-specific keys (hjkl, i for edit) - Remove unnecessary mobile hooks Phase 5 complete. Ready to begin Phase 10 (Setup & Core Types).
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import type { GameStatusManager, GameStatus } from './types';
|
||||
|
||||
export function useGameStatus(): GameStatusManager {
|
||||
const [gameStatus, setGameStatus] = useState<GameStatus>('waiting');
|
||||
|
||||
const startGame = useCallback(() => {
|
||||
setGameStatus('started');
|
||||
}, []);
|
||||
|
||||
const togglePause = useCallback((pause?: boolean) => {
|
||||
setGameStatus(current => {
|
||||
if (current === 'started' || current === 'paused') {
|
||||
return pause !== undefined ? (pause ? 'paused' : 'started') :
|
||||
(current === 'started' ? 'paused' : 'started');
|
||||
}
|
||||
return current;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const quitGame = useCallback(() => {
|
||||
setGameStatus('waiting');
|
||||
}, []);
|
||||
|
||||
return {
|
||||
gameStatus,
|
||||
setGameStatus,
|
||||
startGame,
|
||||
togglePause,
|
||||
quitGame
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user