Skip to content
Snippets Groups Projects

Resolve "Split game object and add events readAnswer and questionEnd"

Files
2
+ 7
5
@@ -10,6 +10,7 @@ class Game {
this.category = {};
this.usersAnswers = new Map();
this.pot = pot;
this.usersStatus = new Map();
}
async setGameData() {
@@ -25,7 +26,7 @@ class Game {
10,
);
}
console.log(questions);
//console.log(questions);
for (let i = 0; i < questions.length; i++) {
const answers = await answerController.getAnswerForQuestion(questions[i]._id);
this.gameData[i] = {
@@ -37,16 +38,17 @@ class Game {
this.usersAnswers.set(user, []);
}
console.log(this.gameData);
//console.log(this.gameData);
return this.gameData;
}
addNewAnswer(user, answer) {
this.usersAnswers.get(user).push(answer);
return this.verifyAnswer(this.usersAnswers.get(user).length - 1, answer);
addNewAnswer(user, answer, index) {
this.usersAnswers.get(user)[index] = answer;
return this.verifyAnswer(index, answer);
}
verifyAnswer(questionNumber, answer) {
console.log(this.gameData[questionNumber]);
return this.gameData[questionNumber].answers[answer].is_correct;
}
Loading