zhao/imports/ui/components/WaitingRoom.vue

55 lines
1.2 KiB
Vue
Raw Normal View History

2020-11-27 06:36:02 +00:00
<template>
2020-11-27 07:16:15 +00:00
<div>
<h1>Waiting for players...</h1>
2020-11-27 08:18:29 +00:00
<p>Join code: {{ currentRoom.joinCode }}</p>
<p>Owner: {{ playerNames[currentRoom.owner] }}</p>
2020-11-27 08:44:06 +00:00
<p>Info: <br /><pre>{{ JSON.stringify(roomInfo, null, 2) }}</pre></p>
<p>Room: <br /><pre>{{ JSON.stringify(currentRoom, null, 2) }}</pre></p>
2020-11-27 08:18:29 +00:00
<p>
Players:
<ul>
2020-11-27 08:44:06 +00:00
<li v-for="player in players" v-bind:key="player._id">
{{ player.name }} (level {{ player.level }})
</li>
2020-11-27 08:18:29 +00:00
</ul>
</p>
2020-11-27 08:44:06 +00:00
<p><button v-if="isOwner" :disabled="!canStart">Start Game</button></p>
2020-11-27 07:16:15 +00:00
</div>
2020-11-27 06:36:02 +00:00
</template>
<script>
export default {
2020-11-27 08:44:06 +00:00
props: [
"currentRoom",
"players",
"roomInfo",
],
2020-11-27 08:18:29 +00:00
computed: {
playerNames: function() {
let names = new Map();
for (let player of this.players) {
names[player._id] = player.name;
}
return names;
},
2020-11-27 08:44:06 +00:00
isOwner: function() {
return this.currentRoom.owner === this.roomInfo.playerId;
},
canStart: function() {
let val =
// only the owner can start the game
this.isOwner
// TODO: actually calculate number of players based on decks?
&& this.players.length === 4;
return val;
},
2020-11-27 08:18:29 +00:00
},
2020-11-27 06:36:02 +00:00
}
</script>
<style scoped>
</style>