Skip to content
Permalink
Browse files

deck details curve by archetypes

  • Loading branch information...
Manuel-777 committed Feb 21, 2019
1 parent bdba0c0 commit 36e571d88f6aa7db029db06a113385ea8a5f34c7
Showing with 82 additions and 15 deletions.
  1. +35 −5 window_main/deck_details.js
  2. +0 −7 window_main/history.js
  3. +12 −0 window_main/index.css
  4. +35 −3 window_main/renderer.js
@@ -89,7 +89,7 @@ function colorPieChart(colorCounts, title) {
return chart;
}

function deckWinrateCurve(deck) {
function deckWinrateCurves(deck) {
// getDeckWinrate returns
// {total: winrate, wins: wins, losses: loss, lastEdit: winrateLastEdit, colors: colorsWinrates};
// or 0 if there is no data
@@ -99,12 +99,41 @@ function deckWinrateCurve(deck) {
console.log('no deck winrate data');
return;
}
let container = $('<div>');

// Archetypes
let tagsWinrates = deckWinrates.tags;
let curveMaxTags = Math.max(...tagsWinrates.map(cwr => Math.max(cwr.wins || 0, cwr.losses || 0)));
console.log('tags curve', curveMaxTags, tagsWinrates);

let curveTags = $('<div class="mana_curve"></div>');
let numbersTags = $('<div class="mana_curve_costs"></div>');

tagsWinrates.forEach(cwr => {
curveTags.append($(`<div class="mana_curve_column back_green" style="height: ${(cwr.wins/curveMaxTags*100)}%"></div>`));
curveTags.append($(`<div class="mana_curve_column back_red" style="height: ${(cwr.losses/curveMaxTags*100)}%"></div>`));

let curveNumber = $(`<div class="mana_curve_column_number">
${cwr.wins}/${cwr.losses}
<div style="margin: 0 auto !important" class=""></div>
</div>`);

let colors = cwr.colors;
curveNumber.append($(`<div class="mana_curve_tag" style="background-color: ${getTagColor(cwr.tag)};">${cwr.tag}</div>`));
colors.forEach(function(color) {
curveNumber.append($(`<div style="margin: 0 auto !important" class="mana_s16 mana_${mana[color]}"></div>`));
})
numbersTags.append(curveNumber);
});

container.append(curveTags, numbersTags);

let colorsWinrates = deckWinrates.colors

// Colors
let colorsWinrates = deckWinrates.colors;
//$('<span>w/l vs Color combinations</span>').appendTo(stats);
let curveMax = Math.max(...colorsWinrates.map(cwr => Math.max(cwr.wins || 0, cwr.losses || 0)));
console.log('curveMax', curveMax);
console.log('colors curve', curveMax, colorsWinrates);

let curve = $('<div class="mana_curve"></div>');
let numbers = $('<div class="mana_curve_costs"></div>');
@@ -126,7 +155,8 @@ function deckWinrateCurve(deck) {
numbers.append(curveNumber);
}
});
let container = $('<div>').append(curve, numbers);

container.append(curve, numbers);
return container;
}

@@ -170,7 +200,7 @@ function deckStatsSection(deck, deck_type) {


if (deck_type == 0 || deck_type == 2) {
let winrateCurveSection = deckWinrateCurve(deck);
let winrateCurveSection = deckWinrateCurves(deck);
if (winrateCurveSection) {
winrateCurveSection.appendTo(stats);
}
@@ -586,13 +586,6 @@ function deleteTag(matchid, tag) {
ipc_send("delete_history_tag", obj);
}

function getTagColor(tag) {
let tc = tags_colors[tag];
if (tc) return tc;

return "#FAE5D2";
}

function filterHistory(filter) {
filterEvent = filter;
open_history_tab(0);
@@ -903,6 +903,18 @@ a:hover {
-webkit-transition: all .2s ease-in-out;
}

.mana_curve_tag {
margin: 8px auto;
writing-mode: tb-rl;
width: 20px;
padding: 12px 0px;
border-radius: 10px;
font-size: 13px;
color: black;
font-family: var(--sub-font-name);
transform: rotate(180deg);
}

.deck_tag_close:hover {
opacity: 1;
}
@@ -178,6 +178,13 @@ ipc.on('too_slow', function () {
});
});

function getTagColor(tag) {
let tc = tags_colors[tag];
if (tc) return tc;

return "#FAE5D2";
}

//
ipc.on('set_tags_colors', function (event, arg) {
tags_colors = arg;
@@ -2541,6 +2548,7 @@ function getDeckWinrate(deckid, lastEdit) {
var winsLastEdit = 0;
var lossLastEdit = 0;
var colorsWinrates = [];
var tagsWinrates = [];

if (matchesHistory == undefined) {
return 0;
@@ -2553,7 +2561,7 @@ function getDeckWinrate(deckid, lastEdit) {
if (match.playerDeck.id == deckid) {
var oppDeckColors = get_deck_colors(match.oppDeck);
if (oppDeckColors.length > 0) {
var added = -1;
let added = -1;

colorsWinrates.forEach(function(wr, index) {
if (compare_colors(wr.colors, oppDeckColors)) {
@@ -2572,7 +2580,7 @@ function getDeckWinrate(deckid, lastEdit) {

wins++;
}
else {
if (match.player.win < match.opponent.win) {
if (index > -1) {
colorsWinrates[added].losses++;
}
@@ -2588,6 +2596,29 @@ function getDeckWinrate(deckid, lastEdit) {
}
}
}

if (match.tags !== undefined && match.tags.length > 0) {
let tag = match.tags[0];
let added = -1;

tagsWinrates.forEach(function(wr, index) {
if (wr.tag == tag) {
added = index;
}
});

if (added == -1) {
added = tagsWinrates.push({tag: tag, wins: 0, losses:0}) - 1;
}

tagsWinrates[added].colors = oppDeckColors;
if (match.player.win > match.opponent.win) {
tagsWinrates[added].wins += 1;
}
if (match.player.win < match.opponent.win) {
tagsWinrates[added].losses += 1;
}
}
}
}
}
@@ -2603,8 +2634,9 @@ function getDeckWinrate(deckid, lastEdit) {

//colorsWinrates.sort(compare_color_winrates);
colorsWinrates.sort(compare_winrates);
tagsWinrates.sort(compare_winrates);

return {total: winrate, wins: wins, losses: loss, lastEdit: winrateLastEdit, colors: colorsWinrates};
return {total: winrate, wins: wins, losses: loss, lastEdit: winrateLastEdit, colors: colorsWinrates, tags: tagsWinrates};
}

function compare_winrates(a, b) {

0 comments on commit 36e571d

Please sign in to comment.
You can’t perform that action at this time.