Skip to content
Permalink
Browse files

Merge pull request #532 from AnnanFay/mythic-signifiers

Added recording of mythic leaderboard and display in UI.
  • Loading branch information...
AnnanFay committed Aug 16, 2019
2 parents 57bca5d + bcd68ee commit 674cb69af30cf8f2a8b77e14d26bbcc87b879641
@@ -791,3 +791,15 @@ function deckTypesStats(deck) {
});
return typesContainer;
}

// pass in playerData.constructed / limited / historic objects
function formatRank(rank) {
if (rank.leaderboardPlace) {
return `Mythic #${rank.leaderboardPlace}`;
}
if (rank.percentile) {
return `Mythic ${rank.percentile}%`;
}
return `${rank.rank} ${rank.tier}`;
}
exports.formatRank = formatRank;
@@ -79,6 +79,7 @@ const {
onLabelInEventGetSeasonAndRankDetail,
onLabelGetPlayerInventoryGetRewardSchedule,
onLabelRankUpdated,
onLabelMythicRatingUpdated,
onLabelTrackProgressUpdated,
onLabelTrackRewardTierUpdated
} = require("./labels");
@@ -760,6 +761,13 @@ function onLogEntryFound(entry) {
}
break;

case "MythicRating.Updated":
{
json = entry.json();
onLabelMythicRatingUpdated(entry, json);
}
break;

case "Event.GetPlayerCourses":
if (entry.arrow == "<==") {
json = entry.json();
@@ -1251,6 +1259,10 @@ function createMatch(arg) {
currentMatch.opponent.name = arg.opponentScreenName;
currentMatch.opponent.rank = arg.opponentRankingClass;
currentMatch.opponent.tier = arg.opponentRankingTier;

currentMatch.opponent.percentile = arg.opponentMythicPercentile;
currentMatch.opponent.leaderboardPlace = arg.opponentMythicLeaderboardPlace;

currentMatch.opponent.cards = [];
currentMatch.eventId = arg.eventId;
currentMatch.matchId = arg.matchId + "-" + pd.arenaId;
@@ -308,8 +308,23 @@ function onLabelInEventGetCombinedRankInfo(entry, json) {
rank.limited.lost = json.limitedMatchesLost;
rank.limited.drawn = json.limitedMatchesDrawn;

rank.constructed.percentile = json.constructedPercentile;
rank.constructed.leaderboardPlace = json.constructedLeaderboardPlace;
rank.constructed.seasonOrdinal = json.constructedSeasonOrdinal;

rank.limited.percentile = json.limitedPercentile;
rank.limited.leaderboardPlace = json.limitedLeaderboardPlace;
rank.limited.seasonOrdinal = json.limitedSeasonOrdinal;

var infoLength = Object.keys(json).length - 1;
if (infoLength != Object.keys(rank).length) {
console.warn("rankInfo is not processing all data.", Object.keys(json));
}

setData({ rank });
if (debugLog || !firstPass) store.set("rank", rank);
if (debugLog || !firstPass) {
store.set("rank", rank);
}
}

function onLabelInEventGetActiveEvents(entry, json) {
@@ -323,18 +338,43 @@ function onLabelRankUpdated(entry, json) {
if (!json) return;
const rank = { ...pd.rank };

if (json.rankUpdateType === "Constructed") {
rank.constructed.rank = json.newClass;
rank.constructed.tier = json.newLevel;
rank.constructed.step = json.newStep;
} else {
rank.limited.rank = json.newClass;
rank.limited.tier = json.newLevel;
rank.limited.step = json.newStep;
// json.wasLossProtected
// json.seasonOrdinal
const updateType = json.rankUpdateType.toLowerCase();

rank[updateType].rank = json.newClass;
rank[updateType].tier = json.newLevel;
rank[updateType].step = json.newStep;
rank[updateType].seasonOrdinal = json.seasonOrdinal;

setData({ rank });
if (debugLog || !firstPass) {
store.set("rank", rank);
}
}

function onLabelMythicRatingUpdated(entry, json) {
// This is exclusive to constructed?
// Not sure what the limited event is called.

// Example data:
// (-1) Incoming MythicRating.Updated {
// "oldMythicPercentile": 100.0,
// "newMythicPercentile": 100.0,
// "newMythicLeaderboardPlacement": 77,
// "context": "PostMatchResult"
// }

if (!json) return;
const rank = { ...pd.rank };

rank.constructed.percentile = json.newMythicPercentile;
rank.constructed.leaderboardPlace = json.newMythicLeaderboardPlacement;

setData({ rank });
if (debugLog || !firstPass) store.set("rank", rank);
if (debugLog || !firstPass) {
store.set("rank", rank);
}
}

function onLabelInDeckGetDeckLists(entry, json) {
@@ -9,7 +9,8 @@ const {
get_rank_index_16,
getReadableEvent,
timeSince,
toMMSS
toMMSS,
formatRank
} = require("../shared/util");

const Aggregator = require("./aggregator");
@@ -269,7 +270,7 @@ function createMatchRow(match) {
oppRankDiv.style.backgroundPosition = `${get_rank_index_16(
match.opponent.rank
) * -16}px 0px`;
oppRankDiv.title = match.opponent.rank + " " + match.opponent.tier;
oppRankDiv.title = formatRank(match.opponent);
matchRow.rightTop.appendChild(oppRankDiv);

let timeDiv = createDiv(
@@ -17,7 +17,8 @@ const {
getReadableEvent,
makeId,
timeSince,
toMMSS
toMMSS,
formatRank
} = require("../shared/util");

const Aggregator = require("./aggregator");
@@ -296,7 +297,7 @@ function attachMatchData(listItem, match) {
oppRank.style.marginRight = "0px";
oppRank.style.backgroundPosition =
get_rank_index_16(match.opponent.rank) * -16 + "px 0px";
oppRank.title = match.opponent.rank + " " + match.opponent.tier;
oppRank.title = formatRank(match.opponent);
listItem.rightTop.appendChild(oppRank);

// Match time
@@ -286,6 +286,14 @@ relative-time, local-time {
background-position: 0px 0px;
}

.top_constructed_rank, .top_limited_rank {
/* Align leaderboard indicator to center and add text border*/
display: flex;
align-items: center;
justify-content: center;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

.top_patreon {
-webkit-app-region: no-drag;
align-self: center;
@@ -18,7 +18,8 @@ const {
get_deck_export,
get_deck_export_txt,
get_rank_index,
makeId
makeId,
formatRank
} = require("../shared/util");
const {
hypergeometricSignificance,
@@ -450,7 +451,7 @@ function renderSeat(
const rank = player.rank;
const tier = player.tier;
const rankClass = isLimited ? "top_limited_rank" : "top_constructed_rank";
const r = createDiv([rankClass], "", { title: rank + " " + tier });
const r = createDiv([rankClass], "", { title: formatRank(player) });
r.style.backgroundPosition = get_rank_index(rank, tier) * -48 + "px 0px";
fltl.appendChild(r);
flt.appendChild(fltl);
@@ -42,7 +42,8 @@ const {
compare_cards,
get_deck_colors,
get_rank_index,
removeDuplicates
removeDuplicates,
formatRank
} = require("../shared/util");

const {
@@ -163,7 +164,6 @@ function updateNavIcons() {
}
}

//
function updateTopBar() {
updateNavIcons();

@@ -182,16 +182,21 @@ function updateTopBar() {
rankOffset = get_rank_index(constructed.rank, constructed.tier);
const constructedRankIcon = $$(".top_constructed_rank")[0];
constructedRankIcon.style.backgroundPosition = rankOffset * -48 + "px 0px";
constructedRankIcon.setAttribute(
"title",
constructed.rank + " " + constructed.tier
);
constructedRankIcon.setAttribute("title", formatRank(constructed));

constructedRankIcon.innerHTML = constructed.leaderboardPlace
? formatRank(constructed).split(" ")[1]
: "";

const limited = pd.rank.limited;
rankOffset = get_rank_index(limited.rank, limited.tier);
const limitedRankIcon = $$(".top_limited_rank")[0];
limitedRankIcon.style.backgroundPosition = rankOffset * -48 + "px 0px";
limitedRankIcon.setAttribute("title", limited.rank + " " + limited.tier);
limitedRankIcon.setAttribute("title", formatRank(limited));

limitedRankIcon.innerHTML = limited.leaderboardPlace
? formatRank(limited).split(" ")[1]
: "";
}

const patreonIcon = $$(".top_patreon")[0];

0 comments on commit 674cb69

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