diff --git a/frontend/src/classes/Deck.js b/frontend/src/classes/Deck.js index 4d84216..2f0a2f7 100644 --- a/frontend/src/classes/Deck.js +++ b/frontend/src/classes/Deck.js @@ -187,4 +187,26 @@ export default class { count() { return this.cards.reduce((total, card) => total + card.count, 0) } + + elements() { + let elements = {} + + for (let card of this.cards) { + if (!elements[card.dbentry.element]) elements[card.dbentry.element] = 0 + + elements[card.dbentry.element] += card.count + } + + let retval = [] + + for (let element in elements) + retval.push({ + name: element, + count: elements[element] + }) + + retval.sort((element_l, element_r) => element_r.count - element_l.count) + + return retval + } } diff --git a/frontend/src/components/Card.vue b/frontend/src/components/Card.vue index 1432099..193a238 100644 --- a/frontend/src/components/Card.vue +++ b/frontend/src/components/Card.vue @@ -3,28 +3,7 @@ diff --git a/frontend/src/components/Deck.vue b/frontend/src/components/Deck.vue index 7b6516b..702b741 100644 --- a/frontend/src/components/Deck.vue +++ b/frontend/src/components/Deck.vue @@ -1,7 +1,18 @@