diff --git a/src/classes.js b/src/classes.js index 75b3bb5..2353168 100644 --- a/src/classes.js +++ b/src/classes.js @@ -36,3 +36,12 @@ class Question { } }; }; + +class Answer { + answer = 0; // will take values from 0 to 3 + last_changed = 0; + constructor(answer = 0, last_changed = 0){ + this.answer = answer; + this.last_changed = last_changed; + }; +} diff --git a/src/main.js b/src/main.js index e176568..03c73a3 100644 --- a/src/main.js +++ b/src/main.js @@ -15,8 +15,8 @@ function prepare(){ }; function startUp(){ - my.answers = questions.map(function () { return 0; }); - their.answers = questions.map(function () { return 0; }); + my.answers = questions.map(function () { return new Answer(); }); + their.answers = questions.map(function () { return new Answer(); }); my.last_changed=0; last_sent=0; their.last_changed=0; @@ -48,12 +48,12 @@ function updateHTML(){ let y = x + questions[x].corresponds_to; console.log(questions[x].question()); console.log("x="+x+"; y="+x+"+"+questions[x].corresponds_to+"="+y); - console.log("my answer: "+my.answers[x]+"; their answer: "+their.answers[y]); - if (my.answers[x] * their.answers[y] > 1) { + console.log("my answer: "+my.answers[x].answer+"; their answer: "+their.answers[y].answer); + if (my.answers[x].answer * their.answers[y].answer > 1) { questions[x].color = "limegreen"; questions[x].consent_level = 1; questions[x].unlocks_tab.unlocked = true; - if (their.answers[y] == 3) questions[x].star = true; + if (their.answers[y].answer == 3) questions[x].star = true; } else { questions[x].color = "lightcoral"; questions[x].consent_level = -1; @@ -76,7 +76,7 @@ function updateHTML(){