<template>
  <v-expansion-panel v-if="value">
    <Deck v-for="deck in decks" :deck="deck" :key="deck.id" />
  </v-expansion-panel>
</template>

<script>
import CardsDB from '@/plugins/ffdecks'

import Deck from '@/components/Deck.vue'

export default {
  name: 'DeckList',

  props: {
    value: Array
  },

  components: {
    Deck
  },

  computed: {
    decks() {
      let result = []

      for (let i = 0; i < this.value.length; i++) {
        let elem = this.value[i]
        let cards = []

        for (let j = 0; j < elem.content.cards.length; j++) {
          let card = elem.content.cards[j]

          cards.push({
            count: card.count,
            ffdecks: CardsDB[card.serial]
          })
        }

        result.push({
          id: elem.id,
          name: elem.content.name,
          note: elem.content.note,
          cards: cards
        })
      }

      return result
    }
  }
}
</script>
