From acb1884b1551d49a0f61ef00f7c1cf6a0ba57098 Mon Sep 17 00:00:00 2001 From: TheOnlyFastCoder2 Date: Fri, 6 Sep 2024 23:57:39 +0400 Subject: [PATCH] fix: fix restart state --- src/games/Matrix/logic.js | 8 +++++--- src/games/RandNum/index.jsx | 2 +- src/games/RandNum/logic.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/games/Matrix/logic.js b/src/games/Matrix/logic.js index 22fd880..c20e4cc 100644 --- a/src/games/Matrix/logic.js +++ b/src/games/Matrix/logic.js @@ -48,13 +48,15 @@ export function checkMove (target, state) { } } + + if(successes === state.sequence.curr) { + resault = "WIN"; + } + if(fails >= getMaxFails(state.sequence.curr, state.maxFails)) { resault = "LOSE"; } - if(successes === state.sequence.curr) { - resault = "WIN"; - } return resault; } \ No newline at end of file diff --git a/src/games/RandNum/index.jsx b/src/games/RandNum/index.jsx index d389142..d256d77 100644 --- a/src/games/RandNum/index.jsx +++ b/src/games/RandNum/index.jsx @@ -117,7 +117,7 @@ export function Game () { function restartGame(changedState) { const newState = { - ...logic.startData, + ...state, ...changedState, stateId: [Math.random()], }; diff --git a/src/games/RandNum/logic.js b/src/games/RandNum/logic.js index 1394632..b3a3b32 100644 --- a/src/games/RandNum/logic.js +++ b/src/games/RandNum/logic.js @@ -22,11 +22,11 @@ export function checkСorrectness (variableVal, state) { ? "CORRECT" : "INCORRECT" ); - console.log(state.fails ,state.quantity) + if(state.quantity === state.currentInd+1) { res += "_"+( - state.fails+1 >= getMaxFails(state.quantity, state.maxFails) + state.fails >= getMaxFails(state.quantity, state.maxFails) ? "LOSE" : "WIN" )