Add code to kick a player
This commit is contained in:
parent
3ae75b6102
commit
2efaae5153
1 changed files with 24 additions and 0 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue