better deck parts splitter
This commit is contained in:
parent
296ab79bd6
commit
323d6d2f35
1 changed files with 28 additions and 26 deletions
|
@ -24,7 +24,7 @@
|
|||
</v-list>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
|
||||
|
||||
<v-btn fab absolute bottom right @click.native="editing = true">
|
||||
<v-icon>edit</v-icon>
|
||||
</v-btn>
|
||||
|
@ -60,34 +60,36 @@ export default {
|
|||
|
||||
computed: {
|
||||
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'
|
||||
)
|
||||
}
|
||||
}
|
||||
let retval = ['Forwards', 'Backups', 'Summons, Monsters & more'].map(
|
||||
item => ({
|
||||
heading: item,
|
||||
cards: [],
|
||||
count: 0
|
||||
})
|
||||
)
|
||||
|
||||
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(
|
||||
this.deck.cards.forEach(card => {
|
||||
let target
|
||||
switch (card.dbentry.type) {
|
||||
case 'Forward':
|
||||
target = 0
|
||||
break
|
||||
case 'Backup':
|
||||
target = 1
|
||||
break
|
||||
default:
|
||||
target = 2
|
||||
break
|
||||
}
|
||||
retval[target].cards.push(card)
|
||||
retval[target].count += card.count
|
||||
})
|
||||
|
||||
retval.forEach(part =>
|
||||
part.cards.sort(
|
||||
(card_l, card_r) => card_l.dbentry.cost - card_r.dbentry.cost
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
return retval
|
||||
}
|
||||
|
|
Reference in a new issue