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: {
|
methods: {
|
||||||
try_game_code() {
|
try_game_code() {
|
||||||
if (this.game_code.length > 0) {
|
if (this.game_code.length > 0) {
|
||||||
alert('The game code you have entered is invalid.');
|
this.$socket.emit(`JoinGame`, {
|
||||||
this.game_code = ``;
|
game_code: this.game_code,
|
||||||
|
username: this.username,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
alert(`Please a enter game code before proceeding.`)
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue