<!--
    Copyright © 2021 Adrien Agez <adrien.agez@pm.me>

    This file is part of Nexus Timers.

    Nexus Timers is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Nexus Timers is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with Nexus Timers.  If not, see <https://www.gnu.org/licenses/>.
-->

<template>
  <div class="battleground" v-if="battleground">
    <div class="battleground-background" :style="backgroundCss"/>
    <div class="battleground-content">
      <div id="objectives" class="objectives">
        <div class="objectives-row" v-for="objectiveRow in battleground.objectives">
          <template v-for="objective in objectiveRow">
            <Objective :objective="objective"></Objective>
          </template>
        </div>
      </div>
      <router-link to="/battlegrounds">Back to selector</router-link>
    </div>
  </div>
</template>

<style lang="sass" scoped>
  $border-style: 1px solid $blizzard-font-color

  .battleground
    &-background, &-content
      height: 100vh
      width: 100vw

    &-background
      position: absolute
      background-size: cover
      background-position: center
      filter: blur(2px) brightness(70%)
      z-index: -10

  .objectives
    display: flex
    flex-direction: column
    height: 100%

    &-row
      display: flex
      justify-content: space-between
      flex-grow: 1
      &:first-child
        border-top: $border-style
      border-bottom: $border-style
  .objective
    &:first-child
      border-left: $border-style
    border-right: $border-style
</style>

<script>
  import BATTLEGROUNDS from '@/gameInfos/battlegrounds'
  import Timer from '@/components/Timer'
  import Objective from '@/components/Objective'

  export default {
    name: 'Battleground',
    data () {
      return {
      }
    },
    computed: {
      battlegroundId () {
        return this.$route.params.battlegroundId
      },
      battleground () {
        return BATTLEGROUNDS[this.battlegroundId]
      },
      backgroundCss () {
        return {
          backgroundImage: `url(${this.battleground.backgroundUrl})`
        }
      }
    },
    watch: {
      $route (to) {
        this.battlegroundId = to.params.battlegroundId
      }
    },
    components: {
      Timer,
      Objective
    }
  }
</script>
