Skip to content

Commit

Permalink
✨ Solucionado problema con temporizador
Browse files Browse the repository at this point in the history
  • Loading branch information
coral2742 committed Apr 7, 2024
1 parent 87d1d65 commit 5d8ad9e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ const Game = () => {
const handleAnswerClick = (option, index) => {
// Almacenar la opción seleccionada por el usuario en gameUserOptions
setGameUserOptions(prevUserOptions => [...prevUserOptions, option]);

// parar el temporizador
stopTimer();
if(option === correctOption) {
const buttonId = `button_${index}`;
const correctButton = document.getElementById(buttonId);
Expand All @@ -169,9 +170,6 @@ const Game = () => {
const incorrectButton = document.getElementById(buttonId);
incorrectButton.style.backgroundColor = "rgba(208, 22, 22, 0.952)";

// parar el temporizador
stopTimer();

// mostrar la correcta
for (let correctIndex = 0; correctIndex < 4; correctIndex++){
const buttonIdCorrect = `button_${correctIndex}`;
Expand Down Expand Up @@ -337,9 +335,17 @@ const getQuestions = () => {
<Button onClick={() => {
setTimedOut(false);
incrementIncorrect();
incrementQuestion();
decrementQuestionsToAnswer();
restartTimer();


if (!isGameFinished()) {
setTimeout(() => {
handleShowQuestion();
}, 1000);
}


}}>Cerrar</Button>
</Paper>
</Container>
Expand Down

0 comments on commit 5d8ad9e

Please sign in to comment.