diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index de9b0ebf..2d8815b0 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -43,9 +43,10 @@ const Game = () => { useEffect(() => { - if (isGameFinished()){ + if (isGameFinished() && !isFinished){ finishGame(); - } + setFinished(true) +; } }, [correctCounter]); // This method will call the create question service @@ -66,7 +67,8 @@ const Game = () => { }); // FIN DE LA PARTIDA - if (isGameFinished()){ + if (isGameFinished() && !isFinished){ + finishGame(); setFinished(true); } @@ -125,8 +127,14 @@ const Game = () => { button.onmouse = null; }); console.log("finishGame " + correctCounter); - var correctas = (correctCounter / numberOfQuestions); - setPercentage(correctas * 100); + var correctas = (correctCounter / numberOfQuestions) * 100; + console.log("corr1 " + correctas); + if (!Number.isInteger(percentage)){ + correctas = correctas.toFixed(2); + console.log("dentro " + correctas); + } + console.log("corr2 " + correctas); + setPercentage(correctas); } const incrementCorrect = () => { @@ -200,7 +208,7 @@ const Game = () => {