1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-11-20 11:26:54 +00:00

Merge branch 'master' of github.com:exane/gwent-online

This commit is contained in:
exane 2015-06-25 21:35:06 +02:00
commit c93b5985d9
3 changed files with 38 additions and 12 deletions

View File

@ -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
});
}
},

View File

@ -14,8 +14,8 @@ module.exports = {
chooseLeader(card) {
// todo: make own leader variable
for(var item in this.deck) {
if(this.deck[item].type == 3) {
this.deck.$set(item, card);
if(this.deck[item].card.type == 3) {
this.deck.$set(item, {card});
}
}

View File

@ -38,9 +38,9 @@
<span>LEADER</span>
<div class="card-wrap-small" v-repeat="item: deck | getType [3]" track-by="$index" v-on="click: showLeaders(item.name)">
<!--div class="count-card no-select">1x</div-->
<div class="count-card no-select">{{ item.count > 1 ? item.count + 'x' : '' }}</div>
<div class="bla ani"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.img + '.png)'"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.card.img + '.png)'"></div>
<div class="shadow"></div>
<div class="overlay-card"></div>
</div>
@ -51,9 +51,9 @@
<span>CLOSE COMBAT</span>
<div class="card-wrap-small" v-repeat="item: deck | getType [0]" track-by="$index">
<div class="count-card no-select">{{ c > 1 ? c + 'x' : '' }}</div>
<div class="count-card no-select">{{ item.count > 1 ? item.count + 'x' : '' }}</div>
<div class="bla ani"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.img + '.png)'"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.card.img + '.png)'"></div>
<div class="shadow"></div>
<div class="overlay-card"></div>
</div>
@ -63,8 +63,9 @@
<span>RANGE</span>
<div class="card-wrap-small" v-repeat="item: deck | getType [1]" track-by="$index">
<div class="count-card no-select">{{ item.count > 1 ? item.count + 'x' : '' }}</div>
<div class="bla ani"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.img + '.png)'"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.card.img + '.png)'"></div>
<div class="shadow"></div>
<div class="overlay-card"></div>
</div>
@ -74,8 +75,9 @@
<span>SPECIAL</span>
<div class="card-wrap-small" v-repeat="item: deck | getType [4,5]" track-by="$index">
<div class="count-card no-select">{{ item.count > 1 ? item.count + 'x' : '' }}</div>
<div class="bla ani"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.img + '.png)'"></div>
<div class="card-img-small card-small-small" v-style="background-image: 'url(http://80.240.132.120/gwent/assets/cards/' + item.card.img + '.png)'"></div>
<div class="shadow"></div>
<div class="overlay-card"></div>
</div>