Make game joining actually function for players
This commit is contained in:
parent
5262cbbd00
commit
4e746e7b78
1 changed files with 18 additions and 2 deletions
|
|
@ -43,13 +43,29 @@ export default {
|
|||
methods: {
|
||||
try_game_code() {
|
||||
if (this.game_code.length > 0) {
|
||||
alert('The game code you have entered is invalid.');
|
||||
this.game_code = ``;
|
||||
this.$socket.emit(`JoinGame`, {
|
||||
game_code: this.game_code,
|
||||
username: this.username,
|
||||
})
|
||||
} else {
|
||||
alert(`Please a enter game code before proceeding.`)
|
||||
}
|
||||
},
|
||||
},
|
||||
sockets: {
|
||||
GameJoined(data) {
|
||||
if (!data.success) {
|
||||
this.$emit(`alert`, {
|
||||
message: data.message,
|
||||
classes: [`warning`],
|
||||
});
|
||||
return;
|
||||
};
|
||||
sessionStorage.setItem(`game-code`, this.game_code);
|
||||
sessionStorage.setItem(`is-host`, false);
|
||||
this.$emit(`go-to`, `lobby`);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue