Permalink
Browse files

remote sets data loading

  • Loading branch information...
Manuel-777 committed Sep 25, 2018
1 parent f08ef96 commit ce4e4e3040d876af0e692234f0da2b2b025e18e4
Showing with 40 additions and 66 deletions.
  1. +3 −62 shared/util.js
  2. +4 −3 window_background/background.js
  3. +33 −1 window_main/renderer.js
@@ -352,68 +352,8 @@ function compare_draft_cards(a, b) {
}
var setsList = {
"Oath of the Gatewatch": {
"scryfall": "ogw",
"code": "OGW",
"tile": 67106
},
"Kaladesh": {
"scryfall": "kld",
"code": "KLD",
"tile": 63859
},
"Aether Revolt": {
"scryfall": "aer",
"code": "AER",
"tile": 64647
},
"Welcome Deck 2017": {
"scryfall": "w17",
"code": "W17",
"tile": 67106
},
"Amonkhet": {
"scryfall": "akh",
"code": "AKH",
"tile": 64827
},
"Hour of Devastation": {
"scryfall": "hou",
"code": "hou",
"tile": 65759
},
"Ixalan": {
"scryfall": "xln",
"code": "XLN",
"tile": 66433
},
"Rivals of Ixalan": {
"scryfall": "rix",
"code": "RIX",
"tile": 66937
},
"Dominaria": {
"scryfall": "dom",
"code": "DAR",
"tile": 67106
},
"Magic 2019": {
"scryfall": "m19",
"code": "M19",
"tile": 65947
},
"Arena": {
"scryfall": "mtga",
"code": "ANA",
"tile": 67106
}/*,
"Guilds of Ravnica": {
"scryfall": "grn",
"code": "GRN",
"tile": 67106
}*/
};
//
var setsList = null;
//
function get_set_scryfall(set) {
@@ -476,6 +416,7 @@ function get_collection_stats() {
card = cardsDb.get(grpId);
if (card.rarity !== "token" && card.rarity !== "land" && card.set !== "Oath of the Gatewatch" && card.dfc != "DFC_Front" && card.dfc != "SplitCard") {
// add to totals
//console.log(card, card.set);
stats[card.set].totalCards += 4;
stats.totalCards += 4;
stats.totalSingles += 1;
@@ -406,7 +406,6 @@ console.log(logUri);
var file;
setTimeout(logLoop, 500);
function logLoop() {
//console.log("logLoop() start");
@@ -1546,6 +1545,7 @@ function finishLoading() {
var httpAsync = [];
httpBasic();
httpGetDatabase();
function httpBasic() {
var httpAsyncNew = httpAsync.slice(0);
@@ -1609,7 +1609,9 @@ function httpBasic() {
}
if (_headers.method == 'get_database') {
cardsDb.set(parsedResult);
setTimeout(logLoop, 1);
delete parsedResult.ok;
setsList = parsedResult.sets;
ipc_send("set_db", parsedResult);
}
}
@@ -1705,11 +1707,10 @@ function httpGetPicks(set) {
function httpGetDatabase() {
var _id = makeId(6);
ipc_send("popup", "Downloading metadata");
httpAsync.push({'reqId': _id, 'method': 'get_database', 'uid': playerId});
}
httpGetDatabase();
//
function get_deck_colors(deck) {
deck.colors = [];
@@ -64,6 +64,8 @@ process.on('uncaughtException', (err) => {
//
ipc.on('set_db', function (event, arg) {
setsList = arg.sets;
delete arg.sets;
cardsDb.set(arg);
});
@@ -1332,6 +1334,36 @@ function drawDeck(div, deck) {
//
function drawDeckVisual(_div, _stats, deck) {
// attempt at sorting visually..
var newMainDeck = [];
for (var cmc = 0; cmc < 21; cmc++) {
for (var qq = 4; qq > -1; qq--) {
deck.mainDeck.forEach(function(c) {
var grpId = c.id;
var card = cardsDb.get(grpId);
if (card.type.indexOf("Land") == -1) {
if (card.cmc == cmc) {
var quantity = c.quantity;
if (quantity == qq) {
newMainDeck.push(c);
}
}
}
else if (cmc == 20) {
var quantity = c.quantity;
if (qq == 0 && quantity > 4) {
newMainDeck.push(c);
}
if (quantity == qq) {
newMainDeck.push(c);
}
}
});
}
}
_stats.hide();
_div.css("display", "flex");
_div.css("width", "auto");
@@ -1359,7 +1391,7 @@ function drawDeckVisual(_div, _stats, deck) {
var tileNow;
var _n = 0;
deck.mainDeck.forEach(function(c) {
newMainDeck.forEach(function(c) {
var grpId = c.id;
var card = cardsDb.get(grpId);

0 comments on commit ce4e4e3

Please sign in to comment.