BREAKING CHANGES: - Remove timeLimit from GameOptions (use gameOver function instead) - Remove finalScore from ScoreManager (pure data collection only) - Remove rows/cols parameters from useScore - Remove finalScore calculation logic from useScore hook ADDITIONS: - Create calculateMazeScore() utility function - ScoreManager now only returns raw metrics: timeValue, keystrokes, optimalSteps, efficiency, distToKey, distToExit - Score calculation moved to consumer (calculateMazeScore takes scoreManager + mazeSize) - Example app now uses calculateMazeScore to compute final score on game-won BENEFITS: - ScoreManager is now a pure data collector with no side effects - Scoring algorithm is reusable and testable in isolation - Game-over conditions fully controlled via gameOver option - Clear separation of concerns: collection vs calculation
33 lines
956 B
TypeScript
33 lines
956 B
TypeScript
import type { RefObject } from 'react';
|
|
import type { CursorManager, HeroManager, HeroRenderManager } from './useCursor/types';
|
|
import type { GameStatusManager } from './useGameStatus/types';
|
|
import type { ScoreManager } from './useScore/types';
|
|
|
|
export * from './useBoard/types';
|
|
export * from './useCursor/types';
|
|
export * from './useGameStatus/types';
|
|
export * from './useScore/types';
|
|
|
|
export type GameOptions = {
|
|
rows: number;
|
|
cols: number;
|
|
gameOver?: boolean | ((scoreManager: ScoreManager) => boolean);
|
|
};
|
|
|
|
export type KeyLogEntry = { key: string; timestamp: number };
|
|
|
|
export type GameKeyManager = {
|
|
keyLog: KeyLogEntry[];
|
|
clearKeyLog: () => void;
|
|
getKeyLog: () => KeyLogEntry[];
|
|
};
|
|
|
|
export type GameManager = {
|
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
renderBoard: () => void;
|
|
cursor: CursorManager;
|
|
hero: HeroManager;
|
|
renderer: HeroRenderManager;
|
|
scoreManager: ScoreManager;
|
|
} & GameStatusManager & GameKeyManager;
|