feat: add custom gameOver condition to GameOptions
- Add optional gameOver field to GameOptions - Can be a boolean value or a function that receives scoreManager - Function receives current score metrics to make dynamic decisions - Enables flexible game-over conditions beyond just time limit - Example: gameOver: (sm) => sm.efficiency > 150 for efficiency threshold - Checked every frame during 'started' and 'has-key' states
This commit is contained in:
+2
-2
@@ -6,7 +6,7 @@ import { useHeroRender } from './useCursor';
|
||||
import { useScore } from './useScore';
|
||||
|
||||
export function useGame(options: GameOptions, platformHook?: unknown): GameManager {
|
||||
const { cols, rows, timeLimit = 600 } = options;
|
||||
const { cols, rows, timeLimit = 600, gameOver } = 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, timeLimit });
|
||||
const scoreManager = useScore({ board, hero, gameStatusManager, keyManager, rows, cols, timeLimit, gameOver });
|
||||
|
||||
const gameManager: GameManager = {
|
||||
containerRef,
|
||||
|
||||
Reference in New Issue
Block a user