This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/frontend/src/components/Deck.vue

82 lines
1.9 KiB
Vue
Raw Normal View History

2019-05-14 15:59:36 +00:00
<template>
<v-expansion-panel-content>
<template v-slot:header>
2019-05-14 22:27:42 +00:00
<span class="subheading">{{ deck.name }}</span>
2019-05-14 15:59:36 +00:00
</template>
2019-05-14 22:27:42 +00:00
<v-alert :value="deck.note" type="info">
{{ deck.note }}
</v-alert>
<v-container grid-list-md fluid>
<v-layout row wrap>
2019-05-14 23:13:44 +00:00
<v-flex v-for="part in deck_parts" :key="part.heading" xs12 sm6 md4>
2019-05-14 22:27:42 +00:00
<v-card>
<v-card-title>{{ part.count }} {{ part.heading }}</v-card-title>
<v-list dense subheader>
2019-05-14 23:13:44 +00:00
<Card
v-for="card in part.cards"
:key="card.serial"
:count="card.count"
:serial="card.serial"
:dbentry="card.dbentry"
></Card>
2019-05-14 22:27:42 +00:00
</v-list>
</v-card>
</v-flex>
</v-layout>
</v-container>
2019-05-14 15:59:36 +00:00
</v-expansion-panel-content>
</template>
<script>
2019-05-14 23:13:44 +00:00
import Card from './Card.vue'
2019-05-14 15:59:36 +00:00
export default {
name: 'Deck',
props: {
deck: Object
},
2019-05-14 23:13:44 +00:00
components: {
Card
},
2019-05-14 15:59:36 +00:00
computed: {
2019-05-14 22:27:42 +00:00
deck_parts() {
let retval = {
forwards: {
heading: 'Forwards',
cards: this.deck.cards.filter(card => card.dbentry.type === 'Forward')
},
backups: {
heading: 'Backups',
cards: this.deck.cards.filter(card => card.dbentry.type === 'Backup')
},
rest: {
heading: 'Summons, Monsters & more',
cards: this.deck.cards.filter(
card =>
card.dbentry.type != 'Forward' && card.dbentry.type != 'Backup'
)
}
}
for (let i = 0; i < Object.keys(retval).length; i++) {
let key = Object.keys(retval)[i]
retval[key].count = retval[key].cards.reduce(
(result, card) => result + card.count,
0
)
retval[key].cards.sort(
(card_l, card_r) => card_l.dbentry.cost - card_r.dbentry.cost
)
}
return retval
2019-05-14 15:59:36 +00:00
}
}
}
</script>