<template lang="html">
  <div ref="game" />
</template>

<script>
export default {
  name: 'Game',

  mounted() {
    this.$nextTick(function() {
      try {
        // framework
        require('craftyjs/dist/crafty')

        // initialize on ref="game"
        window.Crafty.init(this.$refs.game)
        window.Crafty.stage.fullscreen = true

        // load fftcg
        require('@/crafty/Game.coffee')
      } catch (e) {
        window.location.reload()
      }
    })
  },

  beforeDestroy() {
    window.Crafty.stop(true)
    delete window.Crafty
  }
}
</script>
