- 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
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import type { RefObject } from 'react';
|
|
import { MazeRenderer, MazeGenerator } from "./useBoard";
|
|
export * from './useGame';
|
|
export * from './useBoard';
|
|
export * from './useCursor';
|
|
|
|
export type GameStatus = 'waiting' | 'started' | 'has-key' | 'paused' | 'game-over' | 'game-won'
|
|
|
|
export type GameManager = {
|
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
renderBoard: () => void;
|
|
cursor: Cursor;
|
|
} & GameStatusManager & GameKeyManager;
|
|
|
|
|
|
export type BoardManager = {
|
|
containerRef: RefObject<HTMLDivElement | null>
|
|
mazeRef: RefObject<MazeCell[][]>
|
|
mazeInstanceRef: RefObject<MazeGenerator | null>
|
|
rendererRef: RefObject<MazeRenderer | null>
|
|
renderBoard: () => void
|
|
}
|
|
|
|
|
|
export type PositionTag = "entrance" | "exit" | "key" | "hero";
|
|
|
|
export type Coord = { row: number, col: number };
|
|
|
|
export type CellTag = "wall" | "door" | PositionTag;
|
|
|
|
export type MazeCell = CellTag[];
|
|
|
|
export interface MazeData {
|
|
maze: MazeCell[][];
|
|
width: number;
|
|
height: number;
|
|
cols: number;
|
|
rows: number;
|
|
totalSteps: number;
|
|
}
|
|
|
|
|
|
export type GameOptions = {
|
|
rows: number;
|
|
cols: number;
|
|
};
|
|
|
|
export type KeyLogEntry = { key: string; timestamp: number };
|
|
|
|
export type GameKeyManager = {
|
|
keyLog: KeyLogEntry[];
|
|
clearKeyLog: () => void;
|
|
getKeyLog: () => KeyLogEntry[];
|
|
};
|
|
|
|
export type GameStatusManager = {
|
|
gameStatus: GameStatus;
|
|
setGameStatus: (status: GameStatus) => void;
|
|
startGame: () => void;
|
|
togglePause: (pause?: boolean) => void;
|
|
quitGame: () => void;
|
|
};
|
|
|
|
//Cursor Stuff
|
|
export type CursorMode = 'normal' | 'insert' | 'replace' | 'visual' | 'visual-line';
|
|
export type UseHeroType = {
|
|
heroPos: Coord | null;
|
|
setHeroPos: (pos: Coord | null) => void;
|
|
moveHero: (dr: number, dc: number, steps: number, gameStatus: GameStatus, setGameStatus: (s: GameStatus) => void) => void;
|
|
};
|
|
|
|
export type Cursor = { //return type of useCursor (currently useHero)
|
|
position: () => Coord;
|
|
mode: () => CursorMode;
|
|
move: (dCols: number, dRows: number, count: number) => void;
|
|
moveLeft: (count?: number) => void;
|
|
moveRight: (count?: number) => void;
|
|
moveUp: (count?: number) => void;
|
|
moveDown: (count?: number) => void;
|
|
moveToStart: () => void;
|
|
moveToEnd: () => void;
|
|
moveToTop: () => void;
|
|
moveToBottom: () => void;
|
|
repeatLastMotion: () => void;
|
|
resetCount: () => void;
|
|
getCount: () => string;
|
|
setCount: (digit: string) => void;
|
|
setLastKey: (key: string) => void;
|
|
getLastKey: () => string;
|
|
hero?: UseHeroType;
|
|
}
|