diff --git a/web/src/features/skillcheck/index.tsx b/web/src/features/skillcheck/index.tsx index 1452360..dac4d51 100644 --- a/web/src/features/skillcheck/index.tsx +++ b/web/src/features/skillcheck/index.tsx @@ -74,7 +74,8 @@ const SkillCheck: React.FC = () => { angle: -90 + getRandomAngle(120, 360 - offset), difficultyOffset: offset, difficulty: gameData, - key: randomKey, + keys: data.inputs?.map((input) => input.toLowerCase()), + key: randomKey.toLowerCase(), }); setVisible(true); @@ -103,12 +104,13 @@ const SkillCheck: React.FC = () => { ? dataRef.current.inputs[Math.floor(Math.random() * dataRef.current.inputs.length)] : 'e'; const offset = typeof data === 'object' ? data.areaSize : difficultyOffsets[data]; - setSkillCheck({ + setSkillCheck((prev) => ({ + ...prev, angle: -90 + getRandomAngle(120, 360 - offset), difficultyOffset: offset, difficulty: data, - key, - }); + key: key.toLowerCase(), + })); }; return ( diff --git a/web/src/features/skillcheck/indicator.tsx b/web/src/features/skillcheck/indicator.tsx index 674f644..2385736 100644 --- a/web/src/features/skillcheck/indicator.tsx +++ b/web/src/features/skillcheck/indicator.tsx @@ -46,11 +46,13 @@ const Indicator: React.FC = ({ angle, offset, multiplier, handleComplete, useEffect(() => { if (!keyPressed) return; + if (skillCheck.keys && !skillCheck.keys?.includes(keyPressed)) return; + interval.stop(); window.removeEventListener('keydown', keyHandler); - if (keyPressed !== skillCheck.key.toLowerCase() || indicatorAngle < angle || indicatorAngle > angle + offset) + if (keyPressed !== skillCheck.key || indicatorAngle < angle || indicatorAngle > angle + offset) handleComplete(false); else handleComplete(true); diff --git a/web/src/typings/skillcheck.ts b/web/src/typings/skillcheck.ts index 8b52ad2..372a4d8 100644 --- a/web/src/typings/skillcheck.ts +++ b/web/src/typings/skillcheck.ts @@ -9,5 +9,6 @@ export interface SkillCheckProps { angle: number; difficultyOffset: number; difficulty: GameDifficulty; + keys?: string[]; key: string; }