<template>
  <v-expansion-panel-content>
    <template v-slot:header>
      <div>{{ deck.name }}</div>
    </template>

    <v-card>
      <v-card-text>
        {{ deck.note }} <br />
        Forwards:
        <ul>
          <li v-for="card in forwards" :key="card.ffdecks.serial_number">
            {{ card.ffdecks.serial_number }}: {{ card.ffdecks.name }}
          </li>
        </ul>
        Backups:
        <ul>
          <li v-for="card in backups" :key="card.ffdecks.serial_number">
            {{ card.ffdecks.serial_number }}: {{ card.ffdecks.name }}
          </li>
        </ul>
        Summons/Monsters:
        <ul>
          <li v-for="card in rest" :key="card.ffdecks.serial_number">
            {{ card.ffdecks.serial_number }}: {{ card.ffdecks.name }}
          </li>
        </ul>
      </v-card-text>
    </v-card>
  </v-expansion-panel-content>
</template>

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

  props: {
    deck: Object
  },

  computed: {
    forwards() {
      return this.deck.cards.filter(card => card.ffdecks.type === 'Forward')
    },
    backups() {
      return this.deck.cards.filter(card => card.ffdecks.type === 'Backup')
    },
    rest() {
      return this.deck.cards.filter(
        card => card.ffdecks.type != 'Forward' && card.ffdecks.type != 'Backup'
      )
    }
  }
}
</script>
