Add functionality to the kill/leave game buttons
This commit is contained in:
parent
956c28ed39
commit
aebbdf877e
1 changed files with 13 additions and 7 deletions
|
|
@ -38,10 +38,10 @@
|
||||||
<div v-if="is_host" class="controls">
|
<div v-if="is_host" class="controls">
|
||||||
<button v-if="is_host">Start Game</button>
|
<button v-if="is_host">Start Game</button>
|
||||||
<br>
|
<br>
|
||||||
<button>Kill Game</button>
|
<button @click.stop="handle_exit_button()">Kill Game</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="controls">
|
<div v-else class="controls">
|
||||||
<button>Leave Game</button>
|
<button @click.stop="handle_exit_button()">Leave Game</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -86,11 +86,17 @@ export default {
|
||||||
if (this.is_host) {
|
if (this.is_host) {
|
||||||
let cont = confirm(`Are you sure you want to exit`);
|
let cont = confirm(`Are you sure you want to exit`);
|
||||||
if (cont) {
|
if (cont) {
|
||||||
alert(`exiting game`)
|
this.$socket.emit(`KillGame`, {
|
||||||
|
game_code: this.game_code,
|
||||||
|
user: this.username,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.$socket.emit(`LeaveGame`, {
|
this.$socket.emit(`KickPlayer`, {
|
||||||
username: this.username
|
game_code: this.game_code,
|
||||||
|
target: this.username,
|
||||||
|
user: this.username,
|
||||||
|
ban: false,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -120,7 +126,7 @@ export default {
|
||||||
PlayerKicked(data) {
|
PlayerKicked(data) {
|
||||||
if (data.player === this.username) {
|
if (data.player === this.username) {
|
||||||
this.$emit(`alert`, {
|
this.$emit(`alert`, {
|
||||||
message: `You have been kicked from the game by the host.`,
|
message: `You have been removed from the game.`,
|
||||||
classes: [`error`],
|
classes: [`error`],
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -130,7 +136,7 @@ export default {
|
||||||
});
|
});
|
||||||
this.$emit(`go-to`, `game-type`);
|
this.$emit(`go-to`, `game-type`);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
};
|
||||||
this.players = this.players.filter(x => x !== data.player);
|
this.players = this.players.filter(x => x !== data.player);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue