feat: add timeLimit option and time-based game-over logic

- Add timeLimit to GameOptions (default 600 seconds)
- Game-over triggers when time limit exceeded
- Remove all efficiency-based game-over logic
- Pass timeLimit through to useScore
- Check time limit during started and has-key states
This commit is contained in:
2025-10-22 22:07:59 +01:00
parent 7ccf7cdd55
commit 7800acaf56
3 changed files with 16 additions and 4 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import { useHeroRender } from './useCursor';
import { useScore } from './useScore';
export function useGame(options: GameOptions, platformHook?: unknown): GameManager {
const { cols, rows } = options;
const { cols, rows, timeLimit = 600 } = options;
const board = useBoard(cols, rows);
const { containerRef, renderBoard } = board;
const gameStatusManager = useGameStatus();
@@ -14,7 +14,7 @@ export function useGame(options: GameOptions, platformHook?: unknown): GameManag
const hero = cursor.hero;
const renderer = useHeroRender({ gameStatus: gameStatusManager.gameStatus, board, hero });
const scoreManager = useScore({ board, hero, gameStatusManager, keyManager, rows, cols });
const scoreManager = useScore({ board, hero, gameStatusManager, keyManager, rows, cols, timeLimit });
const gameManager: GameManager = {
containerRef,