diff --git a/TODO.md b/TODO.md index 1896257..b03c8d0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,9 @@ -- loading all quest images with loading -- splash (loading) screen - several correct answer - change quest animation - button hover animation - make docs/ -- google: if webpack mode production remove DEBUG code - ## done +- loading all quest images with loading [b8aa4b6] +- splash (loading) screen [b8aa4b6] - add quest progress [aac38ec] diff --git a/app/gameData.json b/app/gameData.json index 20114be..631ef7c 100644 --- a/app/gameData.json +++ b/app/gameData.json @@ -1,10 +1,10 @@ { "questions": [ { - "question": "Выбери вариант МОСТ", + "question": "Выбери вариант МОСТ или РЕКА", "image": "image_land.jpg", "answer": [ "Мост", "Рудник", "Река", "Солнце" ], - "rightAnswer": "мост" + "rightAnswer": [ "мОст", "РЕКА" ] }, { "question": "Что горит?", diff --git a/js/game.js b/js/game.js index cbc4701..99c4925 100644 --- a/js/game.js +++ b/js/game.js @@ -19,11 +19,25 @@ export function imagePreloader(images, callback) { } export function checkAnswer(quest, answer) { - if (quest.rightAnswer.toLowerCase() == answer.toLowerCase()) { - quest.status = true; + if (Array.isArray(quest.rightAnswer)) { + let lowerCaseArray = []; + + quest.rightAnswer.forEach(item => lowerCaseArray.push(item.toLowerCase())) + + if (lowerCaseArray.includes(answer.toLowerCase())) { + quest.status = true; + } + else { + quest.status = false; + } + } + else { + if (quest.rightAnswer.toLowerCase() == answer.toLowerCase()) { + quest.status = true; + } + else + quest.status = false; } - else - quest.status = false; } export function shuffle(array) {