feat: implement hint system (Shift+H) with scoring penalties
- Add getHint() method to BoardManager with two-tier priority: 1. Find incorrect user-entered cells → flash red 2. Find empty cells → show correct digit green temporarily - Add Shift+H key handler in useCursor (normal mode only) - Visual feedback: - Red flash (hint-flash-error): incorrect cells, 1s duration, red bg + border - Green flash (hint-flash-correct): correct digit shown, 1s duration, green bg + border - Distinct from invalid-move (no background, 500ms) - Score penalties based on difficulty: - Easy: 25 points per hint - Medium: 50 points per hint - Hard: 100 points per hint - Track hints used in scoreboard display - Correct digit appears temporarily (1s) then disappears (player still does the work) - Update example app to show hints counter and Shift+H instruction
This commit is contained in:
+6
-2
@@ -16,11 +16,15 @@ export function useGame(options: GameOptions = {}, platformHook?: unknown): Game
|
||||
|
||||
const [keyLog, setKeyLog] = useState<{ key: string; timestamp: number }[]>([]);
|
||||
|
||||
const cursor = useCursor(gameStatusManager, containerRef, board);
|
||||
const [hintsUsedRef] = useState({ current: 0 });
|
||||
|
||||
const cursor = useCursor(gameStatusManager, containerRef, board, () => {
|
||||
hintsUsedRef.current++;
|
||||
});
|
||||
const cursorPosition = cursor.position();
|
||||
const cursorMode = cursor.mode();
|
||||
|
||||
const scoreManager = useScore({ board, gameStatusManager, keyLog, cursorMode, difficulty });
|
||||
const scoreManager = useScore({ board, gameStatusManager, keyLog, cursorMode, difficulty, hintsUsed: hintsUsedRef.current });
|
||||
|
||||
useCursorRender(containerRef, cursorPosition, cursorMode, gameStatus, boardRendered);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user