diff --git a/UNIFIED_API.md b/UNIFIED_API.md index 5e855f0..72b6954 100644 --- a/UNIFIED_API.md +++ b/UNIFIED_API.md @@ -50,7 +50,7 @@ type GameManager = { ### `GameStatus` ```tsx -type GameStatus = 'waiting' | 'started' | 'hasKey' | 'paused' | 'game-over' | 'game-won' +type GameStatus = 'waiting' | 'started' | 'has-key' | 'paused' | 'game-over' | 'game-won' ``` ### `Cursor` diff --git a/src/types.ts b/src/types.ts index 0ef2d55..b6fcd0e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,7 +4,7 @@ export * from './useGame'; export * from './useBoard'; export * from './useCursor'; -export type GameStatus = 'waiting' | 'started' | 'hasKey' | 'paused' | 'game-over' | 'game-won' +export type GameStatus = 'waiting' | 'started' | 'has-key' | 'paused' | 'game-over' | 'game-won' export type GameManager = { containerRef: RefObject; diff --git a/src/useCursor/useHero.ts b/src/useCursor/useHero.ts index 0c718ae..5cc2bb4 100644 --- a/src/useCursor/useHero.ts +++ b/src/useCursor/useHero.ts @@ -70,7 +70,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage ) { const m = mazeRef.current; if (!heroPos || !m.length) return; - if (gameStatus !== "started" && gameStatus !== "hasKey") return; + if (gameStatus !== "started" && gameStatus !== "has-key") return; if (animatingRef.current) return; const n = Math.max(1, steps ?? 1); @@ -88,7 +88,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage valid = false; break; } - if (m[r][c].includes("exit") && gameStatus !== "hasKey") { + if (m[r][c].includes("exit") && gameStatus !== "has-key") { valid = false; break; } @@ -141,7 +141,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage rafId = requestAnimationFrame(tick); } else { if (m[rNow][cNow].includes("key")) { - setGameStatus("hasKey"); + setGameStatus("has-key"); m[rNow][cNow] = []; const container = containerRef.current; const mazeDiv = container?.querySelector("#maze"); @@ -173,13 +173,13 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage flashInvalid(); return; } - if (m[newR][newC].includes("exit") && gameStatus !== "hasKey") { + if (m[newR][newC].includes("exit") && gameStatus !== "has-key") { flashInvalid(); return; } if (m[newR][newC].includes("key")) { - setGameStatus("hasKey"); + setGameStatus("has-key"); m[newR][newC] = []; const container = containerRef.current; const mazeDiv = container?.querySelector("#maze");