zhao/imports/ui/App.vue

70 lines
1.4 KiB
Vue
Raw Normal View History

2020-11-27 05:33:53 +00:00
<template>
<div>
2020-11-27 07:16:15 +00:00
<component
v-bind:is="whatScreen"
2020-11-27 08:18:29 +00:00
v-bind:roomInfo="roomInfo"
2020-11-27 07:34:12 +00:00
v-bind:players="players"
2020-11-27 08:18:29 +00:00
v-bind:currentRoom="currentRoom"
2020-11-27 07:16:15 +00:00
v-on:newGame="newGame"
v-on:joinGame="joinGame"
></component>
2020-11-27 05:33:53 +00:00
</div>
</template>
<script>
2020-11-27 07:34:12 +00:00
import Lobby from "./components/Lobby.vue"
import WaitingRoom from "./components/WaitingRoom.vue"
import Players from "../api/collections/Players";
2020-11-27 08:18:29 +00:00
import Rooms from "../api/collections/Rooms";
2020-11-27 05:33:53 +00:00
export default {
components: {
Lobby,
2020-11-27 07:16:15 +00:00
WaitingRoom,
2020-11-27 05:33:53 +00:00
},
2020-11-27 07:34:12 +00:00
meteor: {
players() {
2020-11-27 08:18:29 +00:00
if (this.roomInfo === null)
return [];
return Players.find({ roomId: this.roomInfo.roomId });
},
currentRoom() {
if (this.roomInfo === null)
return null;
return Rooms.findOne(this.roomInfo.roomId);
2020-11-27 07:34:12 +00:00
},
},
2020-11-27 05:33:53 +00:00
data() {
return {
2020-11-27 08:18:29 +00:00
roomInfo: null,
2020-11-27 05:33:53 +00:00
whatScreen: Lobby,
};
},
2020-11-27 07:16:15 +00:00
methods: {
newGame: function(args) {
2020-11-27 08:18:29 +00:00
this.roomInfo = args;
2020-11-27 07:16:15 +00:00
this.whatScreen = WaitingRoom;
2020-11-27 08:18:29 +00:00
Meteor.subscribe("players", args.roomId);
Meteor.subscribe("currentRoom", args.roomId);
2020-11-27 07:16:15 +00:00
},
joinGame: function(args) {
2020-11-27 08:18:29 +00:00
this.roomInfo = args;
2020-11-27 07:16:15 +00:00
this.whatScreen = WaitingRoom;
2020-11-27 08:18:29 +00:00
Meteor.subscribe("players", args.roomId);
Meteor.subscribe("currentRoom", args.roomId);
2020-11-27 07:16:15 +00:00
},
}
2020-11-27 05:33:53 +00:00
}
</script>
<style>
2020-11-27 06:36:02 +00:00
body {
font-family: sans-serif;
padding: 10px;
}
2020-11-27 05:33:53 +00:00
</style>