organized types
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './types';
|
||||
export * from './useScore';
|
||||
export * from './useScorePaths';
|
||||
export * from './useScoreTime';
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
export type TimerManager = {
|
||||
timeValue: number;
|
||||
startTimer: () => void;
|
||||
stopTimer: () => void;
|
||||
resetTimer: () => void;
|
||||
};
|
||||
|
||||
export type ScorePathsResult = {
|
||||
entranceToKey: number;
|
||||
entranceToExit: number;
|
||||
heroToKey: number;
|
||||
heroToExit: number;
|
||||
};
|
||||
|
||||
export type ScoreManager = {
|
||||
timeValue: number;
|
||||
startTimer: () => void;
|
||||
stopTimer: () => void;
|
||||
resetTimer: () => void;
|
||||
distToKey: number;
|
||||
distToExit: number;
|
||||
keystrokes: number;
|
||||
optimalSteps: number;
|
||||
efficiency: number;
|
||||
finalScore: number | null;
|
||||
};
|
||||
@@ -2,7 +2,9 @@ import { useEffect, useRef, useState } from "react";
|
||||
import { useTimer } from "./useTimer";
|
||||
import { useScoreTime } from "./useScoreTime";
|
||||
import { useScorePaths } from "./useScorePaths";
|
||||
import type { BoardManager, GameStatusManager, UseHeroType } from "../types";
|
||||
import type { BoardManager } from "../useBoard/types";
|
||||
import type { GameStatusManager } from "../useGameStatus/types";
|
||||
import type { UseHeroType } from "../useCursor/types";
|
||||
|
||||
type UseScoreParams = {
|
||||
board: BoardManager;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import type { BoardManager, Coord, ScorePathsResult } from "../types";
|
||||
import type { BoardManager, Coord } from "../useBoard/types";
|
||||
import type { ScorePathsResult } from "./types";
|
||||
|
||||
export type { ScorePathsResult } from "../types";
|
||||
export type { ScorePathsResult } from "./types";
|
||||
|
||||
type UseScorePathsParams = {
|
||||
board: BoardManager;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import type { TimerManager, GameStatus } from "../types";
|
||||
import type { TimerManager } from "./types";
|
||||
import type { GameStatus } from "../useGameStatus/types";
|
||||
|
||||
type UseScoreTimeParams = {
|
||||
gameStatus: GameStatus;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import type { TimerManager } from '../types';
|
||||
import type { TimerManager } from './types';
|
||||
|
||||
export type { TimerManager } from '../types';
|
||||
export type { TimerManager } from './types';
|
||||
|
||||
export function useTimer(): TimerManager {
|
||||
const [timeValue, setTimeValue] = useState(0);
|
||||
|
||||
Reference in New Issue
Block a user