<template>
    <v-container max-width="1400">
        <GamePreview v-model="object"></GamePreview>
    </v-container>
</template>

<script>

export default {
    data() {
        return {
            object: {},
            valid: false,
            rules: {
                required: v => v ? true : this.l.fieldRequired,
                requiredFile: v => (v?.length || this.id != 'add') ? true : this.l.fieldRequired
            },
            loading: false,
            panel: [],
            scenarios: []
        }
    },
    async mounted(){
        if (this.id && this.id != 'add') {
            this.object = (await this.$api.game.load(this.id)).data;
        }
        this.scenarios = (await this.$api.scenario.search()).data.data;
    },
    watch:{
        'object.scenario'(v){
            if (v){
                this.object.thumb = this.scenarios?.find(s=>s.id == v)?.sceneThumb?.[0];
            }
        }
    },
    computed: {
        id() {
            return this.$route.params?.id;
        }
    },
    methods:{
    }
}
</script>