From daa18d6a9a3e74ad71b9458ded87759da7fc737f Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 10 Jan 2021 14:13:58 -0700 Subject: [PATCH] Fix: Character cases causing interface not recognize the game end. (closes #47) --- web/src/components/GameBoard.vue | 12 ++++++++++-- web/src/components/Hand.vue | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/web/src/components/GameBoard.vue b/web/src/components/GameBoard.vue index 8db1d70..3780643 100644 --- a/web/src/components/GameBoard.vue +++ b/web/src/components/GameBoard.vue @@ -13,7 +13,8 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase() == $store.state.chosen_object+`.` ? `correct`: `` + answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase() === getObject + ? `correct`: `` ]" :key="`${otherTeamID}-answer-container-${answerIndex}`" > @@ -57,7 +58,8 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase() == $store.state.chosen_object+`.` ? `correct`: `` + answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase() === getObject + ? `correct`: `` ]" :key="`${teamID}-answer-container-${answerIndex}`" > @@ -122,6 +124,12 @@ export default { answers() { return this.$store.state.answers; }, + getObject() { + if (!this.$store.state.chosen_object) { + return ``; + }; + return this.$store.state.chosen_object.toLowerCase() + `.`; + }, }, methods: { isCorrect(team, answerIndex) { diff --git a/web/src/components/Hand.vue b/web/src/components/Hand.vue index ba6b307..f07d3b9 100644 --- a/web/src/components/Hand.vue +++ b/web/src/components/Hand.vue @@ -74,8 +74,13 @@ export default { gameOver() { if (this.$store.state.chosen_object) { let targetAnswer = this.$store.state.chosen_object.toLowerCase()+`.`; - return this.$store.state.answers.team_1.includes(targetAnswer) - || this.$store.state.answers.team_2.includes(targetAnswer); + for (var team in this.$store.state.answers) { + for (var answer of this.$store.state.answers[team]) { + if (answer.toLowerCase() === targetAnswer) { + return true; + }; + }; + }; }; return false; },