feat(phase2.2): implement finalScore calculation
- finalScore equals current game score when gameStatus is 'game-over' or 'game-won'
- finalScore is null during active gameplay ('waiting' and 'started')
- Passed currentScore from gameManager to useScore hook
This commit is contained in:
@@ -46,7 +46,7 @@ export function useGame(optionsOrCols: GameOptions | number, rows?: number, plat
|
||||
},
|
||||
});
|
||||
|
||||
const scoreManager = useScore({ gameStatus, keyLog: keyBindings.keyLog });
|
||||
const scoreManager = useScore({ gameStatus, keyLog: keyBindings.keyLog, currentScore: score });
|
||||
|
||||
// Wrap renderBoard to match Unified API signature
|
||||
const renderBoardWrapped = () => {
|
||||
|
||||
@@ -5,18 +5,21 @@ import type { GameStatus, KeyLogEntry } from "../types";
|
||||
export type UseScoreParams = {
|
||||
gameStatus: GameStatus;
|
||||
keyLog: KeyLogEntry[];
|
||||
currentScore: number;
|
||||
};
|
||||
|
||||
export function useScore({ gameStatus, keyLog }: UseScoreParams) {
|
||||
export function useScore({ gameStatus, keyLog, currentScore }: UseScoreParams) {
|
||||
const timer = useTimer();
|
||||
const { timeValue, startTimer, stopTimer, resetTimer } = timer;
|
||||
|
||||
useScoreTime({ gameStatus, timer });
|
||||
|
||||
const finalScore = gameStatus === 'game-over' || gameStatus === 'game-won' ? currentScore : null;
|
||||
|
||||
return {
|
||||
timeValue,
|
||||
totalKeystrokes: keyLog.length,
|
||||
finalScore: null, // TODO: Calculate on game-won
|
||||
finalScore,
|
||||
startTimer,
|
||||
stopTimer,
|
||||
resetTimer,
|
||||
|
||||
Reference in New Issue
Block a user