Permalink
Browse files

toggle limited and constructed season

  • Loading branch information...
Manuel-777 committed Dec 30, 2018
1 parent 8da15a7 commit 042631949a00b8accf4cccfab3a6d534849a9225
Showing with 86 additions and 58 deletions.
  1. +6 −6 shared/util.js
  2. +76 −51 window_main/history.js
  3. +4 −1 window_main/index.css
@@ -919,12 +919,12 @@ function get_deck_colors_ammount(deck) {
deck.mainDeck.forEach(function(card) {
if (card.quantity > 0) {
cardsDb.get(card.id).cost.forEach(function(c) {
if (c.indexOf('w') !== -1) { colors.w += 1; colors.total+=1 }
if (c.indexOf('u') !== -1) { colors.u += 1; colors.total+=1 }
if (c.indexOf('b') !== -1) { colors.b += 1; colors.total+=1 }
if (c.indexOf('r') !== -1) { colors.r += 1; colors.total+=1 }
if (c.indexOf('g') !== -1) { colors.g += 1; colors.total+=1 }
if (c.indexOf('c') !== -1) { colors.c += 1; colors.total+=1 }
if (c.indexOf('w') !== -1) { colors.w += card.quantity; colors.total+=card.quantity }
if (c.indexOf('u') !== -1) { colors.u += card.quantity; colors.total+=card.quantity }
if (c.indexOf('b') !== -1) { colors.b += card.quantity; colors.total+=card.quantity }
if (c.indexOf('r') !== -1) { colors.r += card.quantity; colors.total+=card.quantity }
if (c.indexOf('g') !== -1) { colors.g += card.quantity; colors.total+=card.quantity }
if (c.indexOf('c') !== -1) { colors.c += card.quantity; colors.total+=card.quantity }
});
}
});
@@ -19,12 +19,14 @@ globals
rankConstructed,
rankConstructedStep,
rankConstructedTier,
getReadableEvent
getReadableEvent,
getWinrateClass
*/
let loadHistory = 0;
let filterEvent = 'All';
let filteredSampleSize = 0;
let seasonView = 0;

function open_history_tab(loadMore) {
var mainDiv = document.getElementById("ux_0");
@@ -44,56 +46,7 @@ function open_history_tab(loadMore) {
div = document.createElement("div");
div.classList.add("ranks_history");

var t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = "Current contructed season:";
div.appendChild(t);

// Add ranks matchup history here
let rc = matchesHistory.rankwinrates.constructed;
let lastWinrate = Math.round(100 / rc.total.t * rc.total.w);
for (var key in rc) {
if (rc.hasOwnProperty(key)) {
var val = rc[key];
if (val.t > 0 && val.r) {
var fla = document.createElement("div");
fla.classList.add("flex_item");
//fla.style.flexDirection = "column";
fla.style.justifyContent = "center";

var v = document.createElement("div");
v.classList.add("ranks_history_title");
v.innerHTML = "Vs.";

var r = document.createElement("div");
r.classList.add("ranks_history_badge");
r.style.backgroundPosition = (get_rank_index(val.r, 1)*-48)+"px 0px";
r.title = val.r;

var s = document.createElement("div");
s.classList.add("ranks_history_title");

lastWinrate = Math.round(val.w/val.t*100);
s.innerHTML = lastWinrate+"%";

fla.appendChild(v);
fla.appendChild(r);
fla.appendChild(s);
div.appendChild(fla);
}
}
}

t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = `Total: ${Math.round(100 / rc.total.t * rc.total.w)} %`;
div.appendChild(t);

let expected = getStepsUntilNextRank(0, lastWinrate/100);
t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = `Games until ${getNextRank(0)}: ~${expected}`;
div.appendChild(t);
renderRanksStats(div);

var wrap_l = document.createElement("div");
wrap_l.classList.add("wrapper_column");
@@ -389,6 +342,78 @@ function open_history_tab(loadMore) {
loadHistory = loadEnd;
}

function renderRanksStats(div) {
$(div).html('');

let but = document.createElement("div");
but.classList.add("button_simple");
but.classList.add("button_thin");
but.classList.add("season_toggle");
but.style.marginTop = "32px !important;";
but.innerHTML = `Show ${(seasonView == 1 ? 'constructed' : 'limited')}`;
div.appendChild(but);

var t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = `Current ${(seasonView == 0 ? 'constructed' : 'limited')} season:`;
div.appendChild(t);

// Add ranks matchup history here
let rc = matchesHistory.rankwinrates.constructed;
if (seasonView == 1) rc = matchesHistory.rankwinrates.limited;

let lastWinrate = Math.round(100 / rc.total.t * rc.total.w);
for (var key in rc) {
if (rc.hasOwnProperty(key)) {
var val = rc[key];
if (val.t > 0 && val.r) {
var fla = document.createElement("div");
fla.classList.add("flex_item");
//fla.style.flexDirection = "column";
fla.style.justifyContent = "center";

var v = document.createElement("div");
v.classList.add("ranks_history_title");
v.innerHTML = "Vs.";

var r = document.createElement("div");
r.classList.add("ranks_history_badge");
r.style.backgroundPosition = (get_rank_index(val.r, 1)*-48)+"px 0px";
r.title = val.r;

var s = document.createElement("div");
s.classList.add("ranks_history_title");

lastWinrate = Math.round(val.w/val.t*100);
s.innerHTML = lastWinrate+"%";

fla.appendChild(v);
fla.appendChild(r);
fla.appendChild(s);
div.appendChild(fla);
}
}
}

t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = `Total: ${Math.round(100 / rc.total.t * rc.total.w)} %`;
div.appendChild(t);

let expected = getStepsUntilNextRank(seasonView, lastWinrate/100);
t = document.createElement("div");
t.classList.add("ranks_history_title");
t.innerHTML = `Games until ${getNextRank(seasonView)}: ~${expected}`;
div.appendChild(t);



$(but).click(() => {
seasonView = !seasonView;
renderRanksStats($('.ranks_history')[0]);
});
}

function filterHistory(filter) {
filterEvent = filter;
open_history_tab(0);
@@ -1393,7 +1393,7 @@ a:hover {
margin: auto 8px;
margin-left: 18px;
width: 28px;
height: 28px;
height: 35px;
background-size: contain;
}

@@ -1792,6 +1792,9 @@ a:hover {
}

.ranks_history {
margin-top: 16px;
display: flex;
flex-direction: column;
margin-top: 16px;
/*
justify-content: space-evenly;

0 comments on commit 0426319

Please sign in to comment.