From 911f25eb1d5445d4599902375debfb8fd25057e1 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Tue, 12 Jan 2021 15:34:51 -0700 Subject: [PATCH] Makes period optional for answer checking. --- web/src/components/GameBoard.vue | 10 +++++----- web/src/components/Hand.vue | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web/src/components/GameBoard.vue b/web/src/components/GameBoard.vue index 3780643..7136a7f 100644 --- a/web/src/components/GameBoard.vue +++ b/web/src/components/GameBoard.vue @@ -13,7 +13,7 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase() === getObject + answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase().match(getObject) ? `correct`: `` ]" :key="`${otherTeamID}-answer-container-${answerIndex}`" @@ -58,7 +58,7 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase() === getObject + answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase().match(getObject) ? `correct`: `` ]" :key="`${teamID}-answer-container-${answerIndex}`" @@ -109,7 +109,7 @@ import PastQuestions from './PastQuestions'; export default { name: `GameBoard`, components: { - "past-questions": PastQuestions + "past-questions": PastQuestions, }, data() {return { visible: false, @@ -126,9 +126,9 @@ export default { }, getObject() { if (!this.$store.state.chosen_object) { - return ``; + return /\n/; }; - return this.$store.state.chosen_object.toLowerCase() + `.`; + return new RegExp(`${this.$store.state.chosen_object.toLowerCase()}\\.?`); }, }, methods: { diff --git a/web/src/components/Hand.vue b/web/src/components/Hand.vue index b68e3d5..7a31aa8 100644 --- a/web/src/components/Hand.vue +++ b/web/src/components/Hand.vue @@ -73,10 +73,11 @@ export default { }, gameOver() { if (this.$store.state.chosen_object) { - let targetAnswer = this.$store.state.chosen_object.toLowerCase()+`.`; + let answerRegex = new RegExp(`${this.$store.state.chosen_object.toLowerCase()}\\.?`); + for (var team in this.$store.state.answers) { for (var answer of this.$store.state.answers[team]) { - if (answer.toLowerCase() === targetAnswer) { + if (answer.toLowerCase().match(answerRegex)) { return true; }; };