yumechi-no-kuni/src/server/web/app/common/views/components/othello.gameroom.vue

43 lines
892 B
Vue
Raw Normal View History

2018-03-08 02:57:57 -06:00
<template>
<div>
<x-room v-if="!g.is_started" :game="g" :connection="connection"/>
2018-03-11 03:23:59 -05:00
<x-game v-else :init-game="g" :connection="connection"/>
2018-03-08 02:57:57 -06:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import XGame from './othello.game.vue';
import XRoom from './othello.room.vue';
import { OthelloGameStream } from '../../scripts/streaming/othello-game';
export default Vue.extend({
components: {
XGame,
XRoom
},
props: ['game'],
data() {
return {
connection: null,
g: null
};
},
created() {
this.g = this.game;
2018-03-15 05:53:46 -05:00
this.connection = new OthelloGameStream((this as any).os, (this as any).os.i, this.game);
2018-03-08 02:57:57 -06:00
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>