diff --git a/src/context/GameContext.js b/src/context/GameContext.js index 899fe97..7c536a8 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -20,6 +20,7 @@ export function GameContextProvider({ children }) { const [answers, setAnswers] = useState(null); const [score, setScore] = useState(null); const [gameTime, setGameTime] = useState(0); + const [remainingQuestionsAmount, setRemainingQuestionsAmount] = useState(null); // ##### INTERFACE ##### const [hasCheckedTutorial, setHasCheckedTutorial] = useState(false); @@ -34,6 +35,7 @@ export function GameContextProvider({ children }) { useEffect(() => { if (!contextGameDatas) return; initAnswers(); + setRemainingQuestionsAmount(contextGameDatas.gameObjects.length); }, [contextGameDatas]); function initAnswers() { @@ -53,7 +55,7 @@ export function GameContextProvider({ children }) { newAnswers[answerKey].userAnswer = answer; newAnswers[answerKey].userAnsweredCorrectly = answer === newAnswers[answerKey].correctAnswer; setAnswers(newAnswers); - + setRemainingQuestionsAmount(remainingQuestionsAmount - 1); const newScore = calculateScore(answers); setScore(newScore); setCurrentGameModal(); @@ -117,6 +119,7 @@ export function GameContextProvider({ children }) { initAnswers, isSoundOn, setIsSoundOn, + remainingQuestionsAmount, buildGameStatsObject, answerQuestion, hasCheckedTutorial,