types
This commit is contained in:
@@ -90,7 +90,6 @@ export type SnakeCursorManager = CursorManager & {
|
|||||||
export type ScoreManager = {
|
export type ScoreManager = {
|
||||||
timeValue: number;
|
timeValue: number;
|
||||||
totalKeystrokes: number;
|
totalKeystrokes: number;
|
||||||
finalScore: number | null;
|
|
||||||
startTimer: () => void;
|
startTimer: () => void;
|
||||||
stopTimer: () => void;
|
stopTimer: () => void;
|
||||||
resetTimer: () => void;
|
resetTimer: () => void;
|
||||||
|
|||||||
@@ -8,18 +8,15 @@ export type UseScoreParams = {
|
|||||||
currentScore: number;
|
currentScore: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useScore({ gameStatus, keyLog, currentScore }: UseScoreParams) {
|
export function useScore({ gameStatus, keyLog }: UseScoreParams) {
|
||||||
const timer = useTimer();
|
const timer = useTimer();
|
||||||
const { timeValue, startTimer, stopTimer, resetTimer } = timer;
|
const { timeValue, startTimer, stopTimer, resetTimer } = timer;
|
||||||
|
|
||||||
useScoreTime({ gameStatus, timer });
|
useScoreTime({ gameStatus, timer });
|
||||||
|
|
||||||
const finalScore = gameStatus === 'game-over' || gameStatus === 'game-won' ? currentScore : null;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
timeValue,
|
timeValue,
|
||||||
totalKeystrokes: keyLog.length,
|
totalKeystrokes: keyLog.length,
|
||||||
finalScore,
|
|
||||||
startTimer,
|
startTimer,
|
||||||
stopTimer,
|
stopTimer,
|
||||||
resetTimer,
|
resetTimer,
|
||||||
|
|||||||
Reference in New Issue
Block a user