2021-07-04 21:37:21 +03:00
|
|
|
// функции игры
|
|
|
|
|
2021-07-04 22:59:09 +03:00
|
|
|
// передаёт следующий квест, либо возвращает окончание кввестов
|
|
|
|
export function nextQuest(questions, questIndex, answer) {
|
|
|
|
if (questions[questIndex].rightAnswer.toLowerCase() == answer.toLowerCase())
|
|
|
|
questions[questIndex].status = true;
|
2021-07-04 21:37:21 +03:00
|
|
|
else
|
2021-07-04 22:59:09 +03:00
|
|
|
questions[questIndex].status = false;
|
2021-07-04 22:12:04 +03:00
|
|
|
|
|
|
|
if (questIndex < questions.length - 1) {
|
2021-07-04 22:59:09 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
2021-07-04 22:12:04 +03:00
|
|
|
}
|
|
|
|
}
|
2021-07-04 23:07:38 +03:00
|
|
|
|
|
|
|
export function shuffleQuestAnswer(answers) {
|
|
|
|
for (let i = answers.length - 1; i > 0; i--) {
|
|
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
|
|
[answers[i], answers[j]] = [answers[j], answers[i]];
|
|
|
|
}
|
|
|
|
}
|