1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-16 07:38:14 +09:00
MisskeyIO/src/client/app/common/views/components/reversi.gameroom.vue
syuilo 1ef66c962a reversi 💮 💯
2018-06-17 08:10:54 +09:00

43 lines
892 B
Vue

<template>
<div>
<x-room v-if="!g.isStarted" :game="g" :connection="connection"/>
<x-game v-else :init-game="g" :connection="connection"/>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import XGame from './reversi.game.vue';
import XRoom from './reversi.room.vue';
import { ReversiGameStream } from '../../scripts/streaming/reversi-game';
export default Vue.extend({
components: {
XGame,
XRoom
},
props: ['game'],
data() {
return {
connection: null,
g: null
};
},
created() {
this.g = this.game;
this.connection = new ReversiGameStream((this as any).os, this.$store.state.i, this.game);
this.connection.on('started', this.onStarted);
},
beforeDestroy() {
this.connection.off('started', this.onStarted);
this.connection.close();
},
methods: {
onStarted(game) {
Object.assign(this.g, game);
this.$forceUpdate();
}
}
});
</script>