2018-03-08 02:57:57 -06:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-03-29 00:48:47 -05:00
|
|
|
<x-room v-if="!g.isStarted" :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';
|
2018-06-16 18:10:54 -05:00
|
|
|
import XGame from './reversi.game.vue';
|
|
|
|
import XRoom from './reversi.room.vue';
|
2018-07-10 23:47:01 -05:00
|
|
|
import { ReversiGameStream } from '../../../../scripts/streaming/games/reversi-game';
|
2018-03-08 02:57:57 -06:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XGame,
|
|
|
|
XRoom
|
|
|
|
},
|
|
|
|
props: ['game'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
connection: null,
|
|
|
|
g: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.g = this.game;
|
2018-06-16 18:10:54 -05:00
|
|
|
this.connection = new ReversiGameStream((this as any).os, this.$store.state.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>
|