Skip to content

Commit

Permalink
Merge pull request #100 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Primer prototipo
  • Loading branch information
uo264915 authored Apr 8, 2024
2 parents 2124385 + 5d8ad9e commit 3fdd330
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const Game = () => {
} else {
// Se acabó el tiempo
setTimedOut(true);
const buttons = document.querySelectorAll('button[title="btnsPreg"]');
buttons.forEach(button => {
button.disabled = true;
button.onmouse = null;
});
}
});
}
Expand Down Expand Up @@ -151,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 @@ -164,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 @@ -332,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 3fdd330

Please sign in to comment.