Add Lobby #43
6 changed files with 44 additions and 49 deletions
|
@ -1,18 +1,22 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
<head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="//cdn.materialdesignicons.com/2.0.46/css/materialdesignicons.min.css">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
<title>mcgvue</title>
|
<link rel="stylesheet" href="//cdn.materialdesignicons.com/2.0.46/css/materialdesignicons.min.css">
|
||||||
</head>
|
<title>MLPCARDGAME</title>
|
||||||
<body>
|
</head>
|
||||||
<noscript>
|
|
||||||
<strong>We're sorry but mcgvue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
<body>
|
||||||
</noscript>
|
<noscript>
|
||||||
<div id="app"></div>
|
<strong>We're sorry but mcgvue doesn't work properly without JavaScript enabled. Please enable it to
|
||||||
<!-- built files will be auto injected -->
|
continue.</strong>
|
||||||
</body>
|
</noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -45,11 +45,6 @@ export default new Router({
|
||||||
topnav: "Lobby"
|
topnav: "Lobby"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/room",
|
|
||||||
name: "room",
|
|
||||||
component: RoomView
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "/settings",
|
path: "/settings",
|
||||||
name: "settings",
|
name: "settings",
|
||||||
|
|
|
@ -15,6 +15,16 @@ const getters: GetterTree<NetworkState, AppState> = {
|
||||||
|
|
||||||
connectionType(state): "client" | "server" | "none" {
|
connectionType(state): "client" | "server" | "none" {
|
||||||
return state.peerType;
|
return state.peerType;
|
||||||
|
},
|
||||||
|
|
||||||
|
inRoom(state): boolean {
|
||||||
|
if (state.peerType == "client") {
|
||||||
|
return state.connectionStatus == "connected";
|
||||||
|
}
|
||||||
|
if (state.peerType == "server") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,15 @@ import { LocalClient, PeerServer, PeerClient } from "@/network";
|
||||||
|
|
||||||
const mutations: MutationTree<NetworkState> = {
|
const mutations: MutationTree<NetworkState> = {
|
||||||
becomeServer(state, payload: { local: LocalClient; server: PeerServer }) {
|
becomeServer(state, payload: { local: LocalClient; server: PeerServer }) {
|
||||||
state = {
|
state.peerType = "server";
|
||||||
...state,
|
(state as ServerNetworkState).local = payload.local;
|
||||||
peerType: "server",
|
(state as ServerNetworkState).server = payload.server;
|
||||||
local: payload.local,
|
|
||||||
server: payload.server
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
becomeClient(state, payload: { peer: PeerClient }) {
|
becomeClient(state, payload: { peer: PeerClient }) {
|
||||||
state = {
|
state.peerType = "client";
|
||||||
...state,
|
(state as ClientNetworkState).connectionStatus = "connecting";
|
||||||
connectionStatus: "connecting",
|
(state as ClientNetworkState).peer = payload.peer;
|
||||||
peerType: "client",
|
|
||||||
peer: payload.peer
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
connected(state) {
|
connected(state) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<section class="lobby">
|
<section class="lobby">
|
||||||
<TopNav />
|
<TopNav />
|
||||||
<section class="body">
|
<section v-if="!inRoom" class="body">
|
||||||
<section id="info">
|
<section id="info">
|
||||||
<b-field label="Your name">
|
<b-field label="Your name">
|
||||||
<b-input :disabled="busy" v-model="playerName"></b-input>
|
<b-input :disabled="busy" v-model="playerName"></b-input>
|
||||||
|
@ -78,6 +78,9 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="room" v-else>
|
||||||
|
<section class="info"></section>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -183,7 +186,7 @@
|
||||||
import { Component, Vue } from "vue-property-decorator";
|
import { Component, Vue } from "vue-property-decorator";
|
||||||
import TopNav from "@/components/Navigation/TopNav.vue";
|
import TopNav from "@/components/Navigation/TopNav.vue";
|
||||||
import { StartServerOptions, ConnectOptions } from "@/store/network/types";
|
import { StartServerOptions, ConnectOptions } from "@/store/network/types";
|
||||||
import { Action } from "vuex-class";
|
import { Action, Getter } from "vuex-class";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
@ -203,6 +206,9 @@ export default class Lobby extends Vue {
|
||||||
@Action("connect", { namespace: "network" })
|
@Action("connect", { namespace: "network" })
|
||||||
private connect!: (options: ConnectOptions) => void;
|
private connect!: (options: ConnectOptions) => void;
|
||||||
|
|
||||||
|
@Getter("inRoom", { namespace: "network" })
|
||||||
|
private inRoom!: boolean;
|
||||||
|
|
||||||
private data() {
|
private data() {
|
||||||
return {
|
return {
|
||||||
playerName:
|
playerName:
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<template>
|
|
||||||
<section class="room"></section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { Component, Vue } from "vue-property-decorator";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
components: {}
|
|
||||||
})
|
|
||||||
export default class RoomView extends Vue {}
|
|
||||||
</script>
|
|
Loading…
Reference in a new issue