Permalink
Browse files

MAgic Set Review draft rankings

fixes #69
  • Loading branch information...
Manuel-777 committed Oct 27, 2018
1 parent 04725f9 commit fd56ae104d83a3e22c339dd456a34ba2a40a7e2e
Showing with 34 additions and 35 deletions.
  1. +2 −0 README.md
  2. +6 −1 shared/util.js
  3. +0 −9 window_background/background.js
  4. +26 −25 window_overlay/overlay.js
@@ -79,6 +79,8 @@ Please read about [our Privacy Policy and How we use your data here](https://git
[Spectrum color picker by Brian Grinstead](http://bgrins.github.io/spectrum/)
[Draft ranking by Magic Community Set Reviews](https://www.mtgcommunityreview.com/)
[Scryfall.com](http://scryfall.com) in particular, for making an absolutely stunning database of every single card in the multiverse.
### Questions?
@@ -4,7 +4,7 @@ const enums = {"CounterType":{"1":"+1\/+1","2":"-1\/-1","3":"Poison","4":"Wind",
function addCardTile(grpId, indent, quantity, element) {
if (quantity !== 0) {
var cont = $('<div class="card_tile_container"></div>');
if ((quantity+" ").indexOf("%") != -1) {
if (!isNumber(quantity)) {
var ww = 64;
var ll = 48;
cont.append('<div class="card_tile_odds"><span>'+quantity+'</span></div>');
@@ -215,6 +215,11 @@ function addCardSeparator(i, element) {
element.append(cont);
}
//
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
//
function getReadableEvent(arg) {
if (eventsList[arg] != undefined) {
@@ -1122,7 +1122,6 @@ function processLogData(data) {
}
console.log("Draft:", json);
if (json.packNumber == 0 && json.pickNumber <= 0) {
httpGetPicks(draftSet);
setDraftCards(json);
createDraft();
currentDraftPack = json.draftPack.slice(0);
@@ -2127,9 +2126,6 @@ function httpBasic() {
if (_headers.method == 'auth') {
ipc_send("auth", parsedResult);
}
if (_headers.method == 'get_picks') {
ipc_send("set_draft_picks", parsedResult);
}
} catch (e) {
console.error(e.message);
}
@@ -2230,11 +2226,6 @@ function httpDeleteData(courseId) {
httpAsync.push({'reqId': _id, 'method': 'delete_data', 'uid': playerId});
}
function httpGetPicks(set) {
var _id = makeId(6);
httpAsync.push({'reqId': _id, 'method': 'get_picks', 'uid': playerId, 'query': set});
}
function httpGetDatabase() {
var _id = makeId(6);
ipc_send("popup", {"text": "Downloading metadata", "time": 0});
@@ -218,13 +218,6 @@ ipc.on('set_cards', function (event, _cards) {
cards = _cards;
});
var picksRank = null;
ipc.on('set_draft_picks', function (event, arg) {
picksRank = arg;
console.log(arg);
});
//
ipc.on('set_deck', function (event, arg) {
var doscroll = false;
@@ -377,6 +370,21 @@ ipc.on("set_turn", function (event, _we, _phase, _step, _number, _active, _prior
}
});
var draftRanks = [];
draftRanks[12] = "A+";
draftRanks[11] = "A";
draftRanks[10] = "A-";
draftRanks[9] = "B+";
draftRanks[8] = "B";
draftRanks[7] = "B-";
draftRanks[6] = "C+";
draftRanks[5] = "C";
draftRanks[4] = "C-";
draftRanks[3] = "D+";
draftRanks[2] = "D";
draftRanks[1] = "D-";
draftRanks[0] = "F";
function setDraft() {
$(".overlay_decklist").html('');
$(".overlay_deckcolors").html('');
@@ -403,11 +411,11 @@ function setDraft() {
draftPack.sort(compare_draft_picks);
draftPack.forEach(function(grpId) {
var rank = 9;
if (picksRank != null) {
if (picksRank[grpId] != undefined) {
rank = Math.round(picksRank[grpId].average/13*9);
}
try {
var rank = cardsDb.get(grpId).rank;
}
catch (e) {
var rank = 0;
}
var od = $(".overlay_decklist");
@@ -423,7 +431,7 @@ function setDraft() {
}
cont.appendTo(od);
addCardTile(grpId, 'a', rank+1, od);
addCardTile(grpId, 'a', draftRanks[rank], od);
});
}
}
@@ -435,19 +443,12 @@ function compare_logs(a, b) {
}
function compare_draft_picks(a, b) {
var arank = 15;
var brank = 15;
if (picksRank != null) {
if (picksRank[a] != undefined) {
arank = picksRank[a].average;
}
if (picksRank[b] != undefined) {
brank = picksRank[b].average;
}
var arank = cardsDb.get(a).rank;
var brank = cardsDb.get(b).rank;
if (arank > brank) return -1;
if (arank < brank) return 1;
if (arank < brank) return -1;
if (arank > brank) return 1;
}
return 0;
}

0 comments on commit fd56ae1

Please sign in to comment.