2018-03-08 08:57:57 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-03-29 05:48:47 +00:00
|
|
|
<x-room v-if="!g.isStarted" :game="g" :connection="connection"/>
|
2018-08-05 04:40:26 +00:00
|
|
|
<x-game v-else :init-game="g" :connection="connection" :self-nav="selfNav" @go-index="goIndex"/>
|
2018-03-08 08:57:57 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 18:44:35 +00:00
|
|
|
import i18n from '../../../../../i18n';
|
2018-06-16 23:10:54 +00:00
|
|
|
import XGame from './reversi.game.vue';
|
|
|
|
import XRoom from './reversi.room.vue';
|
2018-03-08 08:57:57 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 18:44:35 +00:00
|
|
|
i18n: i18n('common/views/components/games/reversi/reversi.gameroom.vue'),
|
2018-03-08 08:57:57 +00:00
|
|
|
components: {
|
|
|
|
XGame,
|
|
|
|
XRoom
|
|
|
|
},
|
2018-08-05 04:40:26 +00:00
|
|
|
props: {
|
|
|
|
game: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
selfNav: {
|
|
|
|
type: Boolean,
|
|
|
|
require: true
|
|
|
|
}
|
|
|
|
},
|
2018-03-08 08:57:57 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
connection: null,
|
|
|
|
g: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.g = this.game;
|
2018-11-08 23:13:34 +00:00
|
|
|
this.connection = this.$root.stream.connectToChannel('gamesReversiGame', {
|
2018-10-07 02:06:17 +00:00
|
|
|
gameId: this.game.id
|
|
|
|
});
|
2018-03-08 08:57:57 +00:00
|
|
|
this.connection.on('started', this.onStarted);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-10-07 02:06:17 +00:00
|
|
|
this.connection.dispose();
|
2018-03-08 08:57:57 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onStarted(game) {
|
|
|
|
Object.assign(this.g, game);
|
|
|
|
this.$forceUpdate();
|
2018-08-05 04:40:26 +00:00
|
|
|
},
|
|
|
|
goIndex() {
|
|
|
|
this.$emit('go-index');
|
2018-03-08 08:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|