working on unified API and major refactoring

This commit is contained in:
2025-10-19 01:48:20 +01:00
parent 8f62c6c2b5
commit 4db86e1cfe
14 changed files with 1306 additions and 54 deletions
+1
View File
@@ -0,0 +1 @@
export * from './useGameStatus';
+31
View File
@@ -0,0 +1,31 @@
import { useState } from 'react';
import type { GameStatus } from '../types';
export function useGameStatus() {
const [gameStatus, setGameStatus] = useState<GameStatus>('waiting');
function startGame() {
setGameStatus('started');
}
function togglePause(pause?: boolean) {
if (typeof pause === 'boolean') {
setGameStatus(pause ? 'paused' : 'started');
return;
}
setGameStatus(prevStatus => prevStatus === 'paused' ? 'started' : 'paused');
}
function quitGame() {
setGameStatus('waiting');
}
return {
gameStatus,
setGameStatus,
startGame,
togglePause,
quitGame,
};
}