<template>
  <div class="page-play">
    <EngineDebug />
    <div class="page-play__gamecontrols">
      <GameControls />
    </div>
    <div class="page-play__area">
      <div v-if="gameState === 'idle'" class="page-play__waiting">
        waiting for gamemaster to start game ...
      </div>
      <ReadySet v-if="gameState === 'ready-set'" :text="gamePhase" />
      <Play v-if="gameState === 'play'" />
    </div>
  </div>
</template>

<script>
export default {
  async mounted() {
    await this.$engine.start()
  },
  async beforeDestroy() {
    await this.$engine.stop()
  },
  computed: {
    gameState() {
      return this.$store.state.game.state
    },
    gamePhase() {
      return this.$store.state.game.phase
    },
  },
}
</script>

<style lang="scss">
.page-play {
  display: flex;
  flex-direction: column;

  &__controls {
    flex: 0 1 auto;
  }

  &__area {
    flex: 1 1 auto;
  }

  &__waiting {
    margin-top: 60px;
    text-align: center;
    font-family: Dosis;
    font-size: 24px;
    color: #ffffff;
  }
}
</style>
