Implement StartGame caller and listener.
This commit is contained in:
parent
2a18c59f1a
commit
5adefc7df3
1 changed files with 18 additions and 4 deletions
|
|
@ -30,7 +30,7 @@
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="clickable"
|
class="clickable"
|
||||||
@click.stop=""
|
@click.stop="startGame()"
|
||||||
>
|
>
|
||||||
Click to Start the Game
|
Click to Start the Game
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -56,7 +56,10 @@ export default {
|
||||||
return this.$store.state.name;
|
return this.$store.state.name;
|
||||||
},
|
},
|
||||||
gameURL() {
|
gameURL() {
|
||||||
return `${window.location.protocol}//${window.location.host}/?game=${this.$store.state.game_code}`;
|
return `${window.location.protocol}//${window.location.host}/?game=${this.gameCode}`;
|
||||||
|
},
|
||||||
|
gameCode() {
|
||||||
|
return this.$store.state.game_code;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -75,17 +78,22 @@ export default {
|
||||||
// everyone from the game.
|
// everyone from the game.
|
||||||
if (this.$store.state.is_host) {
|
if (this.$store.state.is_host) {
|
||||||
this.$socket.client.emit(`DeleteGame`, {
|
this.$socket.client.emit(`DeleteGame`, {
|
||||||
game_code: this.$store.state.game_code
|
game_code: this.gameCode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just a normal user, they can leave the game just fine
|
// Just a normal user, they can leave the game just fine
|
||||||
else {
|
else {
|
||||||
this.$socket.client.emit(`LeaveGame`, {
|
this.$socket.client.emit(`LeaveGame`, {
|
||||||
game_code: this.$store.state.game_code
|
game_code: this.gameCode
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
startGame() {
|
||||||
|
this.$socket.client.emit(`StartGame`, {
|
||||||
|
game_code: this.gameCode
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sockets: {
|
sockets: {
|
||||||
GameLeft(data) {
|
GameLeft(data) {
|
||||||
|
|
@ -94,6 +102,12 @@ export default {
|
||||||
};
|
};
|
||||||
this.$store.commit(`resetState`);
|
this.$store.commit(`resetState`);
|
||||||
},
|
},
|
||||||
|
GameStarted(data) {
|
||||||
|
if (data.status < 200 || 300 <= data.status) {
|
||||||
|
return this.$emit(`error`, data);
|
||||||
|
};
|
||||||
|
this.$store.commit(`view`, `in-game`);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue