starting new structure
This commit is contained in:
+32
-17
@@ -1,20 +1,35 @@
|
||||
import { useGame } from "./useGame";
|
||||
import { useScore } from "./useScore";
|
||||
import type { RefObject } from 'react';
|
||||
|
||||
export type UseGameType = ReturnType<typeof useGame>;
|
||||
export type UseScoreType = ReturnType<typeof useScore>;
|
||||
export type { Coord, SudokuBoard, SudokuCell, Difficulty } from './useBoard/types';
|
||||
export type { CursorManager, CursorMode, GameKeyManager, KeyLogEntry } from './useCursor/types';
|
||||
export type { GameStatus, GameStatusManager } from './useGameStatus/types';
|
||||
export type { ScoreManager, TimerManager } from './useScore/types';
|
||||
|
||||
export type {
|
||||
Difficulty,
|
||||
DifficultyName,
|
||||
} from "./lib/Sudoku";
|
||||
export type GameOptions = {
|
||||
difficulty?: Difficulty;
|
||||
};
|
||||
|
||||
export type GamePhase = "idle" | "playing";
|
||||
export type PlayStatus = "started" | "game-over" | "game-won";
|
||||
export type GameStatus = "waiting" | "started" | "game-over" | "game-won";
|
||||
|
||||
export const isPlaying = (status: GameStatus): status is PlayStatus =>
|
||||
status === "started" || status === "game-over" || status === "game-won";
|
||||
|
||||
export const getGamePhase = (status: GameStatus): GamePhase =>
|
||||
status === "waiting" ? "idle" : "playing";
|
||||
export type GameManager = {
|
||||
containerRef: RefObject<HTMLDivElement | null>;
|
||||
renderBoard: () => void;
|
||||
gameStatus: GameStatus;
|
||||
setGameStatus: (status: GameStatus) => void;
|
||||
startGame: () => void;
|
||||
togglePause: (pause?: boolean) => void;
|
||||
quitGame: () => void;
|
||||
cursor: CursorManager;
|
||||
scoreManager: ScoreManager;
|
||||
keyLog: KeyLogEntry[];
|
||||
clearKeyLog: () => void;
|
||||
getKeyLog: () => KeyLogEntry[];
|
||||
board: {
|
||||
generateBoard: (difficulty: Difficulty) => void;
|
||||
solveBoard: () => boolean;
|
||||
resetBoard: () => void;
|
||||
getCell: (row: number, col: number) => any;
|
||||
setCell: (row: number, col: number, value: string) => boolean;
|
||||
canEditCell: (row: number, col: number) => boolean;
|
||||
isComplete: () => boolean;
|
||||
isFullyValid: () => boolean;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user