From e372ed1b7cc5c6c9147ba086010a3660e4e15f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 15 May 2019 00:27:42 +0200 Subject: [PATCH] nicer deck template --- frontend/src/components/Deck.vue | 94 ++++++++++++++++++---------- frontend/src/components/DeckList.vue | 3 +- 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/frontend/src/components/Deck.vue b/frontend/src/components/Deck.vue index 8546b36..ea512be 100644 --- a/frontend/src/components/Deck.vue +++ b/frontend/src/components/Deck.vue @@ -1,32 +1,37 @@ @@ -39,16 +44,37 @@ export default { }, 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' - ) + 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 } } } diff --git a/frontend/src/components/DeckList.vue b/frontend/src/components/DeckList.vue index 823cf45..921b9e8 100644 --- a/frontend/src/components/DeckList.vue +++ b/frontend/src/components/DeckList.vue @@ -33,7 +33,8 @@ export default { cards.push({ count: card.count, - ffdecks: CardsDB[card.serial] + serial: card.serial, + dbentry: CardsDB[card.serial] }) }