0
0
Fork 0

Add ResetGame button when someone has the right answer.

This commit is contained in:
Oliver-Akins 2021-01-07 18:17:37 -07:00
parent c1226a81c5
commit 21bca5f468

View file

@ -1,10 +1,15 @@
<template> <template>
<div id="PlayerHand"> <div id="PlayerHand">
<div class="recentQuestion" v-if="mostRecentQuestion"> <div class="flex-center" v-if="mostRecentQuestion">
{{ mostRecentQuestion }} {{ mostRecentQuestion }}
</div> </div>
<div class="gameOver" v-else-if="gameOver"> <div class="flex-center" v-else-if="gameOver">
<button>Go to Lobby</button> <button
class="clickable"
@click.stop="endGame"
>
Go to Lobby
</button>
</div> </div>
<div class="hand" v-else> <div class="hand" v-else>
<div <div
@ -56,6 +61,11 @@ export default {
questions() { questions() {
return this.$store.state.questions; return this.$store.state.questions;
}, },
gameOver() {
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);
},
}, },
methods: { methods: {
sendCard(cardIndex) { sendCard(cardIndex) {
@ -78,6 +88,11 @@ export default {
this.$socket.client.emit(`SendCard`, data); this.$socket.client.emit(`SendCard`, data);
}, },
endGame() {
this.$socket.client.emit(`ResetGame`, {
game_code: this.$store.state.game_code
});
},
}, },
mounted() { mounted() {
if (this.isGuesser) { if (this.isGuesser) {
@ -130,7 +145,7 @@ export default {
width: 95%; width: 95%;
} }
.recentQuestion { .flex-center {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
display: flex; display: flex;