better deck parts splitter
This commit is contained in:
parent
296ab79bd6
commit
323d6d2f35
1 changed files with 28 additions and 26 deletions
|
@ -60,34 +60,36 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
deck_parts() {
|
deck_parts() {
|
||||||
let retval = {
|
let retval = ['Forwards', 'Backups', 'Summons, Monsters & more'].map(
|
||||||
forwards: {
|
item => ({
|
||||||
heading: 'Forwards',
|
heading: item,
|
||||||
cards: this.deck.cards.filter(card => card.dbentry.type === 'Forward')
|
cards: [],
|
||||||
},
|
count: 0
|
||||||
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++) {
|
this.deck.cards.forEach(card => {
|
||||||
let key = Object.keys(retval)[i]
|
let target
|
||||||
retval[key].count = retval[key].cards.reduce(
|
switch (card.dbentry.type) {
|
||||||
(result, card) => result + card.count,
|
case 'Forward':
|
||||||
0
|
target = 0
|
||||||
)
|
break
|
||||||
retval[key].cards.sort(
|
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
|
(card_l, card_r) => card_l.dbentry.cost - card_r.dbentry.cost
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue