Skip to content
Permalink
Browse files

Merge pull request #386 from lusbenjamin/bugfix-mormir-matches

Bugfixes for Mormir Matches and Lore Events
  • Loading branch information...
Manuel-777 committed May 24, 2019
2 parents b003359 + 755e30d commit fe794dfdd3030609c7014418243e47989dc4842f
@@ -668,3 +668,5 @@ exports.MANA = {
};

exports.PACK_SIZES = { "Ravnica Allegiance": 14, "Guilds of Ravnica": 14 };

exports.DEFAULT_TILE = 67003;
@@ -8,6 +8,7 @@ globals
objectClone
setsList
*/
const { DEFAULT_TILE } = require("../shared/constants.js");
const CardsList = require("./cards-list.js");
const Colors = require("./colors.js");

@@ -23,7 +24,7 @@ class Deck {
this.name = mtgaDeck.name || "";
this.id = mtgaDeck.id || "";
this.lastUpdated = mtgaDeck.lastUpdated || "";
this.tile = mtgaDeck.deckTileId ? mtgaDeck.deckTileId : 67003;
this.tile = mtgaDeck.deckTileId ? mtgaDeck.deckTileId : DEFAULT_TILE;
this._colors = undefined;
this.tags = mtgaDeck.tags || [mtgaDeck.format];
this.custom = mtgaDeck.custom || false;
@@ -244,9 +244,9 @@ var playerData = _.cloneDeep(playerDataDefault);
var currentMatch = null;

var renderer_state = 0;
var originalDeck = {};
var originalDeck = new Deck();

var currentDeck = null;
var currentDeck = new Deck();
var duringMatch = false;
var matchBeginTime = 0;
var matchGameStats = [];
@@ -10,7 +10,11 @@ globals
rankedEvents,
season_starts
*/
const { COLORS_ALL, COLORS_BRIEF } = require("../shared/constants.js");
const {
COLORS_ALL,
COLORS_BRIEF,
DEFAULT_TILE
} = require("../shared/constants.js");

// Default filter values
const DEFAULT_DECK = "All Decks";
@@ -82,7 +86,9 @@ class Aggregator {
match.playerDeck.colors = get_deck_colors(match.playerDeck);
} else {
match.playerDeck = JSON.parse(
'{"deckTileId":67003,"description":null,"format":"Standard","colors":[],"id":"00000000-0000-0000-0000-000000000000","isValid":false,"lastUpdated":"2018-05-31T00:06:29.7456958","lockedForEdit":false,"lockedForUse":false,"mainDeck":[],"name":"Undefined","resourceId":"00000000-0000-0000-0000-000000000000","sideboard":[]}'
'{"deckTileId":' +
DEFAULT_TILE +
',"description":null,"format":"Standard","colors":[],"id":"00000000-0000-0000-0000-000000000000","isValid":false,"lastUpdated":"2018-05-31T00:06:29.7456958","lockedForEdit":false,"lockedForUse":false,"mainDeck":[],"name":"Undefined","resourceId":"00000000-0000-0000-0000-000000000000","sideboard":[]}'
);
}
if (match.oppDeck && match.oppDeck.mainDeck) {
@@ -144,9 +144,17 @@ function getMatchesHistoryIndex(matchIndex) {
return undefined;
}

function getWlGate(course) {
// quick hack to handle new War of the Spark Lore Events
const wlGate =
course.ModuleInstanceData.WinLossGate ||
course.ModuleInstanceData.WinNoGate;
return wlGate;
}

// Given a courses object returns all of the matches
function getCourseStats(course) {
let wlGate = course.ModuleInstanceData.WinLossGate;
const wlGate = getWlGate(course);
let matchesList = wlGate ? wlGate.ProcessedMatchIds : undefined;
const stats = { wins: 0, losses: 0, duration: 0 };
if (!matchesList) return stats;
@@ -207,7 +215,7 @@ function attachEventData(listItem, course) {
);

let { wins, losses } = stats;
const wlGate = course.ModuleInstanceData.WinLossGate;
const wlGate = getWlGate(course);
if (filters.showArchived && wlGate) {
wins = wlGate.CurrentWins;
losses = wlGate.CurrentLosses;
@@ -318,12 +326,11 @@ function expandEvent(id) {
return;
}

var matchesList = course.ModuleInstanceData.WinLossGate.ProcessedMatchIds;
expandDiv.innerHTML = "";

if (!matchesList) {
return;
}
const wlGate = getWlGate(course);
if (!wlGate) return;
const matchesList = wlGate.ProcessedMatchIds;
if (!matchesList) return;

var matchRows = matchesList
.map(
@@ -20,7 +20,7 @@ globals
getBoosterCountEstimate,
$$
*/
const { MANA, COLORS_BRIEF } = require("../shared/constants.js");
const { MANA, COLORS_BRIEF, DEFAULT_TILE } = require("../shared/constants.js");

let filterWCC = 0;
let filterWCU = 0;
@@ -491,7 +491,7 @@ function deckLoad(_deck, index) {
try {
let a = cardsDb.get(tileGrpid).images["art_crop"];
} catch (e) {
tileGrpid = 67003;
tileGrpid = DEFAULT_TILE;
}

var tile = createDivision([index + "t", "deck_tile"]);
@@ -626,7 +626,7 @@ function eventLoad(event, index) {
try {
let a = cardsDb.get(tileGrpid).images["art_crop"];
} catch (e) {
tileGrpid = 67003;
tileGrpid = DEFAULT_TILE;
}

var tile = createDivision([index + "t", "deck_tile"]);
@@ -5,6 +5,7 @@ globals
cardsDb,
createDivision
*/
const { DEFAULT_TILE } = require("../shared/constants.js");

class ListItem {
constructor(_grpId, _id, _onClick, _onDelete = false, isArchived = false) {
@@ -26,7 +27,7 @@ class ListItem {
this.deleteButton.title = isArchived
? "restore"
: "archive (will not delete data)";
let cardObj = cardsDb.get(_grpId);
let cardObj = cardsDb.get(_grpId || DEFAULT_TILE);
this.imageContainer = createDivision(["list_item_image"]);
try {
this.imageContainer.style.backgroundImage = `url(https://img.scryfall.com/cards${

0 comments on commit fe794df

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