Permalink
Browse files

missing wildcards in my decks

  • Loading branch information...
Manuel-777 committed Dec 27, 2018
1 parent a4e3b8d commit a849d1a325b235484c9a4ba3a394ee7c8175a11e
Showing with 50 additions and 46 deletions.
  1. +1 −6 window_main/deck_details.js
  2. +42 −40 window_main/decks.js
  3. +7 −0 window_main/renderer.js
@@ -15,18 +15,13 @@ global
mana,
ConicGradient,
getDeckWinrate,
economyHistory,
cardsDb,
add
*/

// We need to store a sorted list of card types so we create the card counts in the same order.
var orderedCardTypes = ['cre', 'lan', 'ins', 'sor', 'enc', 'art', 'pla'];
var orderedCardTypesDesc = ['Creatures', 'Lands', 'Instants', 'Sorceries', 'Enchantments', 'Artifacts', 'Planeswalkers'];
var orderedCardRarities = ['common', 'uncommon', 'rare', 'mythic'];
var orderedColorCodes = ['w', 'u', 'b', 'r', 'g', 'c'];
var orderedManaColors = ['#E7CA8E', '#AABEDF', '#A18E87', '#DD8263', '#B7C89E', '#E3E3E3'];
var currentOpenDeck = null;
let rarityBooster = {common: 3, uncommon: 3, rare: 6, mythic: 13};

function deckColorBar(deck) {
let deckColors = $('<div class="deck_top_colors" style="align-self: center;"></div>');
@@ -108,10 +108,15 @@ function open_decks_tab() {
var flc = document.createElement("div");
flc.classList.add('flex_item');
flc.style.flexDirection = "column";
flc.style.whiteSpace = "nowrap";

var flcf = document.createElement("div");
flcf.classList.add('deck_tags_container');

var flcfwc = document.createElement("div");
//flcfwc.style.flexGrow = 2;
flcfwc.classList.add('flex_item');

let t = createTag(null, flcf, false);
jQuery.data(t, "deck", deck.id);
if (deck.tags) {
@@ -121,6 +126,42 @@ function open_decks_tab() {
});
}

// Deck crafting cost section
let ownedWildcards = {
common: economyHistory.wcCommon,
uncommon: economyHistory.wcUncommon,
rare: economyHistory.wcRare,
mythic: economyHistory.wcMythic
};

let missingWildcards = get_deck_missing(deck);

let wc;
let n = 0;
let boosterCost = 0;
orderedCardRarities.forEach(cardRarity => {
if (missingWildcards[cardRarity]) {
n++;
let bc = rarityBooster[cardRarity] * (missingWildcards[cardRarity] - ownedWildcards[cardRarity]);
if (bc > boosterCost) {
boosterCost = bc;
}
wc = document.createElement("div");
wc.classList.add("wc_explore_cost");
wc.classList.add("wc_"+cardRarity);
wc.title = cardRarity.capitalize()+" wldcards needed.";
wc.innerHTML = (ownedWildcards[cardRarity] > 0 ? ownedWildcards[cardRarity] + '/' : '') + missingWildcards[cardRarity];
flcfwc.appendChild(wc);
}
});
if (n !== 0) {
let bo = document.createElement("div");
bo.classList.add("bo_explore_cost");
bo.innerHTML = boosterCost;
bo.title = "Aproximate boosters needed";
flcfwc.appendChild(bo);
}

var flr = document.createElement("div");
flr.classList.add('flex_item');
flr.style.flexDirection = "column";
@@ -140,46 +181,6 @@ function open_decks_tab() {
d.innerHTML = deck.name;
flt.appendChild(d);

var missingCards = false;
deck.mainDeck.forEach(function(card) {
var grpId = card.id;
//var type = cardsDb.get(grpId).type;
if (cardsDb.get(grpId).type.indexOf("Basic Land") == -1) {
var quantity = card.quantity;
if (grpId == 67306 && quantity > 4) {
quantity = 4;
}
if (cards[grpId] == undefined) {
missingCards = true
}
else if (quantity > cards[grpId]) {
missingCards = true;
}
}
});
deck.sideboard.forEach(function(card) {
var grpId = card.id;
//var type = cardsDb.get(grpId).type;
if (cardsDb.get(grpId).type.indexOf("Basic Land") == -1) {
var quantity = card.quantity;
if (grpId == 67306 && quantity > 4) {
quantity = 4;
}
if (cards[grpId] == undefined) {
missingCards = true
}
else if (quantity > cards[grpId]) {
missingCards = true;
}
}
});

if (missingCards) {
d = document.createElement("div");
d.classList.add('decklist_not_owned');
flt.appendChild(d);
}

deck.colors.forEach(function(color) {
var d = document.createElement("div");
d.classList.add('mana_s20');
@@ -229,6 +230,7 @@ function open_decks_tab() {
fll.appendChild(tile);
div.appendChild(flc);
div.appendChild(flcf);
div.appendChild(flcfwc);
flc.appendChild(flt);
flc.appendChild(flb);
div.appendChild(flr);
@@ -37,6 +37,13 @@ const open_collection_tab = require('./collection').open_collection_tab;
const open_economy_tab = require('./economy').open_economy_tab;
const set_economy_history = require('./economy').set_economy_history;

var orderedCardTypes = ['cre', 'lan', 'ins', 'sor', 'enc', 'art', 'pla'];
var orderedCardTypesDesc = ['Creatures', 'Lands', 'Instants', 'Sorceries', 'Enchantments', 'Artifacts', 'Planeswalkers'];
var orderedCardRarities = ['common', 'uncommon', 'rare', 'mythic'];
var orderedColorCodes = ['w', 'u', 'b', 'r', 'g', 'c'];
var orderedManaColors = ['#E7CA8E', '#AABEDF', '#A18E87', '#DD8263', '#B7C89E', '#E3E3E3'];
var rarityBooster = {common: 3, uncommon: 3, rare: 6, mythic: 13};

let shell = electron.shell;
let ipc = electron.ipcRenderer;
let decks = null;

0 comments on commit a849d1a

Please sign in to comment.