fix: rename GameStatus 'hasKey' to 'has-key'
- Update GameStatus type to use kebab-case convention - Change all occurrences in useHero.ts - Update UNIFIED_API.md documentation - Maintains consistency with other status values
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ type GameManager = {
|
|||||||
|
|
||||||
### `GameStatus`
|
### `GameStatus`
|
||||||
```tsx
|
```tsx
|
||||||
type GameStatus = 'waiting' | 'started' | 'hasKey' | 'paused' | 'game-over' | 'game-won'
|
type GameStatus = 'waiting' | 'started' | 'has-key' | 'paused' | 'game-over' | 'game-won'
|
||||||
```
|
```
|
||||||
|
|
||||||
### `Cursor`
|
### `Cursor`
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ export * from './useGame';
|
|||||||
export * from './useBoard';
|
export * from './useBoard';
|
||||||
export * from './useCursor';
|
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 = {
|
export type GameManager = {
|
||||||
containerRef: RefObject<HTMLDivElement | null>;
|
containerRef: RefObject<HTMLDivElement | null>;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
|
|||||||
) {
|
) {
|
||||||
const m = mazeRef.current;
|
const m = mazeRef.current;
|
||||||
if (!heroPos || !m.length) return;
|
if (!heroPos || !m.length) return;
|
||||||
if (gameStatus !== "started" && gameStatus !== "hasKey") return;
|
if (gameStatus !== "started" && gameStatus !== "has-key") return;
|
||||||
if (animatingRef.current) return;
|
if (animatingRef.current) return;
|
||||||
|
|
||||||
const n = Math.max(1, steps ?? 1);
|
const n = Math.max(1, steps ?? 1);
|
||||||
@@ -88,7 +88,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
|
|||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m[r][c].includes("exit") && gameStatus !== "hasKey") {
|
if (m[r][c].includes("exit") && gameStatus !== "has-key") {
|
||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
|
|||||||
rafId = requestAnimationFrame(tick);
|
rafId = requestAnimationFrame(tick);
|
||||||
} else {
|
} else {
|
||||||
if (m[rNow][cNow].includes("key")) {
|
if (m[rNow][cNow].includes("key")) {
|
||||||
setGameStatus("hasKey");
|
setGameStatus("has-key");
|
||||||
m[rNow][cNow] = [];
|
m[rNow][cNow] = [];
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
const mazeDiv = container?.querySelector("#maze");
|
const mazeDiv = container?.querySelector("#maze");
|
||||||
@@ -173,13 +173,13 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
|
|||||||
flashInvalid();
|
flashInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m[newR][newC].includes("exit") && gameStatus !== "hasKey") {
|
if (m[newR][newC].includes("exit") && gameStatus !== "has-key") {
|
||||||
flashInvalid();
|
flashInvalid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m[newR][newC].includes("key")) {
|
if (m[newR][newC].includes("key")) {
|
||||||
setGameStatus("hasKey");
|
setGameStatus("has-key");
|
||||||
m[newR][newC] = [];
|
m[newR][newC] = [];
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
const mazeDiv = container?.querySelector("#maze");
|
const mazeDiv = container?.querySelector("#maze");
|
||||||
|
|||||||
Reference in New Issue
Block a user