Skip to content

Commit

Permalink
Finalizacion del juego y mostrar puntuacion
Browse files Browse the repository at this point in the history
[APP] Configurar el fin de partida (Cuando se llega a X preguntas)  #72
  • Loading branch information
uo264915 committed Mar 30, 2024
1 parent fc2de3a commit 78acdb3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ const Game = () => {


useEffect(() => {
if (isGameFinished()){
if (isGameFinished() && !isFinished){
finishGame();
}
setFinished(true)
; }
}, [correctCounter]);

// This method will call the create question service
Expand All @@ -66,7 +67,8 @@ const Game = () => {
});

// FIN DE LA PARTIDA
if (isGameFinished()){
if (isGameFinished() && !isFinished){
finishGame();
setFinished(true);
}

Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -200,7 +208,7 @@ const Game = () => {
</Typography>
<div>
<Button title='puntuacion' onMouseEnter={null} variant="contained" color="primary" disabled={true}>
Puntuación: {percentage.toFixed(2)} %
Puntuación: {percentage} %
</Button>
</div>
</Paper>
Expand Down

0 comments on commit 78acdb3

Please sign in to comment.