Skip to content
Permalink
Browse files

Fixed broken economy labels.

  • Loading branch information...
AnnanFay committed Apr 26, 2019
1 parent c26ad45 commit d07903aa56301e2b934ca1e481b51493fb45ef37
Showing with 20 additions and 5 deletions.
  1. +7 −0 shared/util.js
  2. +13 −5 window_main/economy.js
@@ -1150,6 +1150,13 @@ function getReadableEvent(arg) {
return arg;
}

function getReadableQuest(questCode) {
// FIXME: Can we get a human readable quest name?
// For now lets just use a small portion of the ID.
return `#${questCode.substring(0, 6)}`
}


//
function getEventId(arg) {
var ret = arg;
@@ -59,6 +59,7 @@ const economyTransactionContextsMap = {
"PlayerReward.OnMatchCompletedWeekly": "Weekly rewards"
};


function getPrettyContext(context, full = true) {
if (context.startsWith("Event.Prize")) {
var eventCode = context.substring(12);
@@ -67,7 +68,7 @@ function getPrettyContext(context, full = true) {

if (context.startsWith("Quest.Completed")) {
var questCode = context.substring(16);
return full ? `Quest Completed: ${questCode}` : "Quest Completed";
return full ? `Quest Completed: ${getReadableQuest(questCode)}` : "Quest Completed";
}

var pretty = economyTransactionContextsMap[context];
@@ -590,7 +591,7 @@ function createChangeRow(change, economyId) {
flexTop.appendChild(
createDivision(
[],
`<span title="${change.originalContext || ""}">${change.context}</span>`
`<span title="${change.originalContext}">${change.contextPretty}</span>`
)
);

@@ -628,9 +629,16 @@ function createEconomyUI(mainDiv) {
console.log("new day", change.date);
}

let ctx = change.originalContext || change.context;
change.contextPretty = getPrettyContext(ctx);
change.context = getPrettyContext(ctx, false);

// IMPORTANT:
// Some old data stores the raw original context in ".originalContext"
// All NEW data stores this in ".context" and ".originalContext" is blank.

// In the below code all three of these values are used.
change.originalContext = change.originalContext || change.context;
change.contextPretty = getPrettyContext(change.originalContext);
change.context = getPrettyContext(change.originalContext, false);

if (!selectItems.includes(change.context)) {
selectItems.push(change.context);
}

0 comments on commit d07903a

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