refactor: make all GameOptions optional with sensible defaults
- cols defaults to 30 (was required)
- rows defaults to 20 (was required)
- timeLimit and startingLevel remain optional
- Can now call useGame() with no arguments
- Example: useGame(), useGame({}), useGame({ startingLevel: 5 })
This commit is contained in:
@@ -7,8 +7,8 @@ import { useGameStatus } from "../useGameStatus";
|
||||
import { useKeyBindings, type UseKeyBindingsType } from "./useKeyBindings";
|
||||
import { useScore } from "../useScore";
|
||||
|
||||
export function useGame(options: GameOptions, platformHook?: unknown): GameManager {
|
||||
const { cols, rows, startingLevel } = options;
|
||||
export function useGame(options?: GameOptions, platformHook?: unknown): GameManager {
|
||||
const { cols = 30, rows = 20, startingLevel } = options ?? {};
|
||||
|
||||
const boardManager = useBoard();
|
||||
const { containerRef, renderBoard } = boardManager;
|
||||
|
||||
Reference in New Issue
Block a user