diff --git a/webapp/src/components/FirstGame.js b/webapp/src/components/FirstGame.js
index 55638c56..a5bf771a 100644
--- a/webapp/src/components/FirstGame.js
+++ b/webapp/src/components/FirstGame.js
@@ -108,7 +108,6 @@ const Quiz = () => {
haveFailedQuestion = false;
load = true
haveEnter = false
- console.log("Calbo")
if (currentQuestionIndex === allQuestions.length ) {
console.log("Entramos aqui")
diff --git a/webapp/src/components/game/Calculator.js b/webapp/src/components/game/Calculator.js
index 6c5a13a6..dfa676b7 100644
--- a/webapp/src/components/game/Calculator.js
+++ b/webapp/src/components/game/Calculator.js
@@ -7,13 +7,21 @@ import Button from '../Button';
import {esperar} from '../Util';
let questions = [];
-const previousBackgroundColor = '#1a1a1a'
+const previousBackgroundColor = '#1a1a1a';
const Calculator = () => {
+ let questionIndex = -1
+
function generateQuestion() {
- const num1 = secureRandomNumber(10) + 1;
- const num2 = secureRandomNumber(10) + 1;
+ let num1 = secureRandomNumber(10) + 1;
+ let num2 = secureRandomNumber(10) + 1;
+
+ questionIndex++;
+ console.log(questionIndex)
+
+ num2 = secureRandomNumber(10) + 1;
+
const operator = ['+', '-', 'x', '÷'][secureRandomNumber(3)];
let correctAnswer;
@@ -41,32 +49,37 @@ const Calculator = () => {
}
shuffleArray(option);
- questions = [
+ questions.push(
{
q: `${num1} ${operator} ${num2}`,
options: option,
correctAnswer: correctAnswer
}
- ];
+ );
}
+ //CAMBIAR ESTO EN FUNCIÓN DE CÓMO QUERAMOS QUE SEA EL JUEGO
const handleOptionClick = async (selectedAnswer) => {
- const numberAnswer = questions.options.indexOf(questions.correctAnswer);
+ const numberAnswer = questions[questionIndex].options.indexOf(questions[questionIndex].correctAnswer);
+ //console.log(numberAnswer)
const botonCorrecta = document.getElementById('option-' + numberAnswer);
let botonIncorrecta = null;
botonCorrecta.style.backgroundColor = 'green';
- if (selectedAnswer !== questions.correctAnswer) {
- botonIncorrecta = document.getElementById('option-' + questions.options.indexOf(selectedAnswer));
+ if (selectedAnswer !== questions[questionIndex].correctAnswer) {
+ botonIncorrecta = document.getElementById('option-' + questions[questionIndex].options.indexOf(selectedAnswer));
botonIncorrecta.style.backgroundColor = 'red';
}
await esperar(2000);
+
+ generateQuestion();
+
+ await esperar(2000);
+
botonCorrecta.style.backgroundColor = previousBackgroundColor;
if(botonIncorrecta != null){
botonIncorrecta.style.backgroundColor = previousBackgroundColor;
}
-
- generateQuestion();
};
@@ -81,13 +94,13 @@ const Calculator = () => {