diff --git a/site/client/app/modules/deck-builder/components/deck-builder.js b/site/client/app/modules/deck-builder/components/deck-builder.js index 2f52725..95b3d85 100644 --- a/site/client/app/modules/deck-builder/components/deck-builder.js +++ b/site/client/app/modules/deck-builder/components/deck-builder.js @@ -29,13 +29,34 @@ module.exports = { }, filters: { + + // Iterate for correct card type and merge multiple cards. getType: function(c, type) { + var a = []; + var itemCount = {}; + var tmp = $.map(c, (item) => { - //if(item.type == type) return item; - if($.inArray(item.type, type) > -1) return item; + if($.inArray(item.card.type, type) > -1) { + if($.inArray(item.card.name, a) > -1) { + itemCount[item.card.name] = (itemCount[item.card.name] || 1) + 1; + } else { + a.push(item.card.name); + + return item; + } + } }); - return tmp; + // todo: extract to method + var tmp2 = $.map(tmp, (item) => { + if(itemCount[item.card.name]) { + item.count = itemCount[item.card.name]; + } + + return item; + }); + + return tmp2; } }, @@ -66,7 +87,10 @@ module.exports = { var _deck = deck[this.factionFilter]; for(var item in _deck) { - this.deck.push(cards[_deck[item]]); + this.deck.push({ + card: cards[_deck[item]], + count: 1 + }); } }, diff --git a/site/client/app/modules/deck-builder/views/deck-builder.html b/site/client/app/modules/deck-builder/views/deck-builder.html index 6faeb00..cbf2379 100644 --- a/site/client/app/modules/deck-builder/views/deck-builder.html +++ b/site/client/app/modules/deck-builder/views/deck-builder.html @@ -38,9 +38,9 @@ LEADER
- +
{{ item.count }}x
-
+
@@ -51,9 +51,9 @@ CLOSE COMBAT
-
{{ c > 1 ? c + 'x' : '' }}
+
{{ item.count }}x
-
+
@@ -63,8 +63,9 @@ RANGE
+
{{ item.count }}x
-
+
@@ -74,8 +75,9 @@ SPECIAL
+
{{ item.count }}x
-
+