mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
feat(web/skillcheck): fail skill check only on keys that aren't passed
This commit is contained in:
@@ -74,7 +74,8 @@ const SkillCheck: React.FC = () => {
|
|||||||
angle: -90 + getRandomAngle(120, 360 - offset),
|
angle: -90 + getRandomAngle(120, 360 - offset),
|
||||||
difficultyOffset: offset,
|
difficultyOffset: offset,
|
||||||
difficulty: gameData,
|
difficulty: gameData,
|
||||||
key: randomKey,
|
keys: data.inputs?.map((input) => input.toLowerCase()),
|
||||||
|
key: randomKey.toLowerCase(),
|
||||||
});
|
});
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
@@ -103,12 +104,13 @@ const SkillCheck: React.FC = () => {
|
|||||||
? dataRef.current.inputs[Math.floor(Math.random() * dataRef.current.inputs.length)]
|
? dataRef.current.inputs[Math.floor(Math.random() * dataRef.current.inputs.length)]
|
||||||
: 'e';
|
: 'e';
|
||||||
const offset = typeof data === 'object' ? data.areaSize : difficultyOffsets[data];
|
const offset = typeof data === 'object' ? data.areaSize : difficultyOffsets[data];
|
||||||
setSkillCheck({
|
setSkillCheck((prev) => ({
|
||||||
|
...prev,
|
||||||
angle: -90 + getRandomAngle(120, 360 - offset),
|
angle: -90 + getRandomAngle(120, 360 - offset),
|
||||||
difficultyOffset: offset,
|
difficultyOffset: offset,
|
||||||
difficulty: data,
|
difficulty: data,
|
||||||
key,
|
key: key.toLowerCase(),
|
||||||
});
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -46,11 +46,13 @@ const Indicator: React.FC<Props> = ({ angle, offset, multiplier, handleComplete,
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!keyPressed) return;
|
if (!keyPressed) return;
|
||||||
|
|
||||||
|
if (skillCheck.keys && !skillCheck.keys?.includes(keyPressed)) return;
|
||||||
|
|
||||||
interval.stop();
|
interval.stop();
|
||||||
|
|
||||||
window.removeEventListener('keydown', keyHandler);
|
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);
|
handleComplete(false);
|
||||||
else handleComplete(true);
|
else handleComplete(true);
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ export interface SkillCheckProps {
|
|||||||
angle: number;
|
angle: number;
|
||||||
difficultyOffset: number;
|
difficultyOffset: number;
|
||||||
difficulty: GameDifficulty;
|
difficulty: GameDifficulty;
|
||||||
|
keys?: string[];
|
||||||
key: string;
|
key: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user