Add code to kick a player

This commit is contained in:
Oliver-Akins 2020-10-21 00:03:22 -06:00
parent 3ae75b6102
commit 2efaae5153

View file

@ -94,6 +94,14 @@ export default {
}); });
}; };
}, },
kick_player(player) {
this.$socket.emit(`KickPlayer`, {
game_code: this.game_code,
user: this.username,
target: player,
ban: false,
});
},
}, },
sockets: { sockets: {
PlayerList(data) { PlayerList(data) {
@ -109,6 +117,22 @@ export default {
NewPlayer(data) { NewPlayer(data) {
this.players.push(data.player); this.players.push(data.player);
}, },
PlayerKicked(data) {
if (data.player === this.username) {
this.$emit(`alert`, {
message: `You have been kicked from the game by the host.`,
classes: [`error`],
});
setTimeout(() => {
this.$emit(`alert`, {
message: ``,
classes: [],
});
this.$emit(`go-to`, `game-type`);
}, 2000);
}
this.players = this.players.filter(x => x !== data.player);
}
}, },
} }
</script> </script>