Permalink
Browse files

Combine cards

Fixes #66
  • Loading branch information...
Manuel-777 committed Oct 15, 2018
1 parent 7775f74 commit 75c87a1ecd8cdf82a7df97bb5bd7e49b018fc982
Showing with 33 additions and 1 deletion.
  1. +27 −0 shared/util.js
  2. +4 −1 window_background/background.js
  3. +2 −0 window_overlay/overlay.js
@@ -251,6 +251,8 @@ function getReadableEvent(arg) {
return "Quick Draft DOM"; break;
case "QuickDraft_M_":
return "Quick Draft M19"; break;
case "QuickDraft_GRN_":
return "Quick Draft GRN"; break;
case "QuickExploration_":
return "Quick Exploration"; break;
@@ -268,6 +270,31 @@ function getReadableEvent(arg) {
}
}
//
function removeDuplicates(decklist) {
var newList = [];
decklist.forEach(function(card) {
var cname = cardsDb.get(card.id).name;
var added = false;
newList.forEach(function(c) {
var cn = cardsDb.get(c.id).name;
if (cn == cname) {
c.quantity += card.quantity;
if (c.chance != undefined) {
c.chance += card.chance;
}
added = true;
}
});
if (!added) {
newList.push(card);
}
});
return newList;
}
//
function get_card_type_sort(a) {
if (a == undefined) return 0;
@@ -368,7 +368,8 @@ function loadPlayerConfig(playerId) {
for (let i=0; i<drafts.matches.length; i++) {
ipc_send("popup", {"text": "Reading drafts: "+i+" / "+drafts.matches.length, "time": 0});
var id = drafts.matches[i];
console.log("Read draft: ", entireConfig[id]);
if (id != null) {
var item = entireConfig[id];
if (item != undefined) {
@@ -379,6 +380,8 @@ function loadPlayerConfig(playerId) {
}
}
console.log("Done reading history");
deck_changes_index = entireConfig["deck_changes_index"];
deck_changes = entireConfig["deck_changes"];
goldHistory = entireConfig["gold_history"];
@@ -220,6 +220,8 @@ ipc.on('set_deck', function (event, arg) {
$(".overlay_deckcolors").append('<div class="mana_s20 mana_'+mana[color]+'"></div>');
});
arg.mainDeck = removeDuplicates(arg.mainDeck);
if (deckMode == 2) {
arg.mainDeck.sort(compare_chances);
}

0 comments on commit 75c87a1

Please sign in to comment.