Makes period optional for answer checking.
This commit is contained in:
parent
01940fb0b6
commit
911f25eb1d
2 changed files with 8 additions and 7 deletions
|
|
@ -13,7 +13,7 @@
|
||||||
v-for="answerIndex in 8"
|
v-for="answerIndex in 8"
|
||||||
:class="[
|
:class="[
|
||||||
`answer`,
|
`answer`,
|
||||||
answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase() === getObject
|
answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase().match(getObject)
|
||||||
? `correct`: ``
|
? `correct`: ``
|
||||||
]"
|
]"
|
||||||
:key="`${otherTeamID}-answer-container-${answerIndex}`"
|
:key="`${otherTeamID}-answer-container-${answerIndex}`"
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
v-for="answerIndex in 8"
|
v-for="answerIndex in 8"
|
||||||
:class="[
|
:class="[
|
||||||
`answer`,
|
`answer`,
|
||||||
answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase() === getObject
|
answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase().match(getObject)
|
||||||
? `correct`: ``
|
? `correct`: ``
|
||||||
]"
|
]"
|
||||||
:key="`${teamID}-answer-container-${answerIndex}`"
|
:key="`${teamID}-answer-container-${answerIndex}`"
|
||||||
|
|
@ -109,7 +109,7 @@ import PastQuestions from './PastQuestions';
|
||||||
export default {
|
export default {
|
||||||
name: `GameBoard`,
|
name: `GameBoard`,
|
||||||
components: {
|
components: {
|
||||||
"past-questions": PastQuestions
|
"past-questions": PastQuestions,
|
||||||
},
|
},
|
||||||
data() {return {
|
data() {return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
@ -126,9 +126,9 @@ export default {
|
||||||
},
|
},
|
||||||
getObject() {
|
getObject() {
|
||||||
if (!this.$store.state.chosen_object) {
|
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: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,11 @@ export default {
|
||||||
},
|
},
|
||||||
gameOver() {
|
gameOver() {
|
||||||
if (this.$store.state.chosen_object) {
|
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 team in this.$store.state.answers) {
|
||||||
for (var answer of this.$store.state.answers[team]) {
|
for (var answer of this.$store.state.answers[team]) {
|
||||||
if (answer.toLowerCase() === targetAnswer) {
|
if (answer.toLowerCase().match(answerRegex)) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue