Permalink
Browse files

mana curve colors

  • Loading branch information...
Manuel-777 committed Dec 27, 2018
1 parent 4831ab6 commit a7ddba30c2bca1f3e7afd6bafd30098943ae2d55
Showing with 47 additions and 7 deletions.
  1. +17 −2 shared/util.js
  2. +23 −5 window_main/deck_details.js
  3. +7 −0 window_main/index.css
@@ -858,10 +858,20 @@ function get_deck_curve(deck) {
deck.mainDeck.forEach(function(card) {
var grpid = card.id;
var cmc = cardsDb.get(grpid).cmc;
if (curve[cmc] == undefined) curve[cmc] = 0;
if (curve[cmc] == undefined) curve[cmc] = [0,0,0,0,0,0];

let card_cost = cardsDb.get(grpid).cost;

if (cardsDb.get(grpid).type.indexOf("Land") == -1) {
curve[cmc] += card.quantity
card_cost.forEach(function(c) {
if (c.indexOf('w') !== -1) curve[cmc][1] += card.quantity;
if (c.indexOf('u') !== -1) curve[cmc][2] += card.quantity;
if (c.indexOf('b') !== -1) curve[cmc][3] += card.quantity;
if (c.indexOf('r') !== -1) curve[cmc][4] += card.quantity;
if (c.indexOf('g') !== -1) curve[cmc][5] += card.quantity;
});

curve[cmc][0] += card.quantity
}
});
/*
@@ -1157,4 +1167,9 @@ function toHHMM(sec_num) {
//
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}

//
function add(a, b) {
return a + b;
}
@@ -15,7 +15,8 @@ global
mana,
ConicGradient,
getDeckWinrate,
cardsDb
cardsDb,
add
*/

// We need to store a sorted list of card types so we create the card counts in the same order.
@@ -37,17 +38,34 @@ function deckColorBar(deck) {

function deckManaCurve(deck) {
let manaCounts = get_deck_curve(deck);
let curveMax = Math.max(...manaCounts.filter(function(v) {
let curveMax = Math.max(...manaCounts.filter((v) => {
if (v == undefined) return false;
return true;
}).map(v => v || 0));
}).map(v => v[0] || 0));

console.log('deckManaCurve', manaCounts, curveMax);

let curve = $('<div class="mana_curve"></div>');
let numbers = $('<div class="mana_curve_numbers"></div>');
manaCounts.forEach((count, i) => {
curve.append($(`<div class="mana_curve_column" style="height: ${count/curveMax*100}%"></div>`))
manaCounts.forEach((cost, i) => {
let total = cost[0];

let gradient = '';
let manaTotal = cost.reduce(add, 0) - total;
let _start = 0;
let _end = 0;
orderedManaColors.forEach((mc, ind) => {
if (ind < 5 && cost[ind+1] > 0) {
_end = Math.round(cost[ind+1] / manaTotal * 100);

if (gradient !== '') gradient += ',';
gradient += mc+' '+_start+'%, '+mc+' '+_end+'%';

_start = _end;
}
});

curve.append($(`<div class="mana_curve_column" style="height: ${total/curveMax*100}%; background-image: linear-gradient(${gradient})">${(total > 0 ? total : '')}</div>`))
numbers.append($(`<div class="mana_curve_column_number"><div style="margin: 0 auto !important" class="mana_s16 mana_${i}"></div></div>`))
})

@@ -854,7 +854,14 @@ a:hover {
width: 100%;
}
.mana_curve_column {
text-align: center;
font-size: 16px;
text-shadow: 3px 3px 3px #000000ad;
font-family: Beleren;
color: #fae5d2;
justify-content: space-around;
width: 1000px;
flex-direction: column;
margin: 0px 2px;
display: flex;
background-color: rgba(250, 229, 210, 0.8);

0 comments on commit a7ddba3

Please sign in to comment.