starting new structure

This commit is contained in:
2025-10-19 17:59:12 +01:00
parent 4c6bd0d4d4
commit d0a51d7079
50 changed files with 2219 additions and 432 deletions
+30
View File
@@ -0,0 +1,30 @@
import { useEffect, useRef } from "react";
import type { UseTimerReturn } from "./hooks/useTimer";
import type { GameStatus } from "../types";
type UseScoreTimeParams = {
gameStatus: GameStatus;
timer: UseTimerReturn;
};
export function useScoreTime({ gameStatus, timer }: UseScoreTimeParams) {
const prevStatusRef = useRef<GameStatus | null>(null);
const { startTimer, stopTimer, resetTimer } = timer;
useEffect(() => {
prevStatusRef.current = gameStatus;
switch (gameStatus) {
case "started":
resetTimer();
startTimer();
break;
case "game-over":
case "game-won":
case "waiting":
stopTimer();
break;
}
}, [gameStatus, startTimer, stopTimer, resetTimer]);
}