Add StartGame handling

This commit is contained in:
Oliver-Akins 2020-10-22 23:37:24 -06:00
parent b7df92a06e
commit 17bec179cd

View file

@ -36,8 +36,7 @@
</div> </div>
</div> </div>
<div v-if="is_host" class="controls"> <div v-if="is_host" class="controls">
<button v-if="is_host">Start Game</button> <button @click.stop="start_game()">Start Game</button>
<br>
<button @click.stop="handle_exit_button()">Kill Game</button> <button @click.stop="handle_exit_button()">Kill Game</button>
</div> </div>
<div v-else class="controls"> <div v-else class="controls">
@ -108,6 +107,12 @@ export default {
ban: false, ban: false,
}); });
}, },
start_game() {
this.$socket.emit(`StartGame`, {
game_code: this.game_code,
user: this.username,
});
},
}, },
sockets: { sockets: {
PlayerList(data) { PlayerList(data) {
@ -156,6 +161,19 @@ export default {
}, 3000); }, 3000);
}; };
}, },
Starting(data) {
if (!data.success) {
this.$emit(`alert`, {
message: data.message,
classes: [`error`]
});
setTimeout(() => {
this.$emit(`alert`, { message: ``, classes: [] }, 3000)
})
} else {
this.$emit(`go-to`, `in-game`);
};
}
}, },
} }
</script> </script>