working on useGame

This commit is contained in:
2025-10-15 17:47:41 +01:00
parent 8acc16fc1c
commit da8ca2c289
5 changed files with 153 additions and 38 deletions
+17 -11
View File
@@ -15,6 +15,21 @@ export function useGame(platformHook?: unknown) {
const boardManager = useBoardState(cursorManager);
const { board, initialBoard, solution, setDigit, erase, reset, solveBoard } = boardManager;
// ---------------------------
// Keybindings
// ---------------------------
const keyBindings = useKeyBindings({
moveCursor,
setDigit,
erase,
stopGame,
cursor,
board,
initialBoard,
});
const { editMode } = keyBindings;
// ---------------------------
// Rendering
// ---------------------------
@@ -27,18 +42,9 @@ export function useGame(platformHook?: unknown) {
renderEmptyBoard();
} else {
renderBoard(board, initialBoard);
highlightCursor(cursor.r, cursor.c);
highlightCursor(cursor.r, cursor.c, editMode === "edit");
}
}, [gameStatus, board, initialBoard, cursor, renderEmptyBoard, renderBoard, highlightCursor]);
// ---------------------------
// Keybindings
// ---------------------------
const keyBindings = useKeyBindings({
moveCursor,
setDigit,
erase,
});
}, [gameStatus, board, initialBoard, cursor, editMode, renderEmptyBoard, renderBoard, highlightCursor]);
// ---------------------------
// Game Control