Skip to content
Permalink
Browse files

Merge pull request #459 from lusbenjamin/mastery-economy

Mastery Track Economy WIP
  • Loading branch information...
Manuel-777 committed Jul 7, 2019
2 parents c296457 + d0c4bba commit c2180b2adc61a3e2b1f1613fae0f1b0a5ece676f
BIN +6.13 KB images/card.png
Binary file not shown.
BIN +3.4 KB images/card_icon.png
Binary file not shown.
BIN +3.47 KB images/orb.png
Binary file not shown.
BIN +3.31 KB images/vault.png
Binary file not shown.
@@ -113,7 +113,13 @@ const defaultCfg = {
wcCommon: 0,
wcUncommon: 0,
wcRare: 0,
wcMythic: 0
wcMythic: 0,
trackName: "",
trackTier: 0,
currentLevel: 0,
currentExp: 0,
currentOrbCount: 0,
boosters: []
},
rank: {
constructed: {
@@ -62,6 +62,7 @@ const {
onLabelInventoryUpdated,
onLabelInPlayerInventoryGetPlayerInventory,
onLabelInPlayerInventoryGetPlayerCardsV3,
onLabelInProgressionGetPlayerProgress,
onLabelInEventDeckSubmit,
onLabelInEventDeckSubmitV3,
onLabelInEventGetActiveEvents,
@@ -75,7 +76,8 @@ const {
onLabelMatchGameRoomStateChangedEvent,
onLabelInEventGetSeasonAndRankDetail,
onLabelGetPlayerInventoryGetRewardSchedule,
onLabelRankUpdated
onLabelRankUpdated,
onLabelTrackProgressUpdated
} = require("./labels");

const toolVersion = electron.remote.app
@@ -810,6 +812,18 @@ function onLogEntryFound(entry) {
}
break;

case "Progression.GetPlayerProgress":
if (entry.arrow == "<==") {
json = entry.json();
onLabelInProgressionGetPlayerProgress(entry, json);
}
break;

case "TrackProgress.Updated":
json = entry.json();
onLabelTrackProgressUpdated(entry, json);
break;

case "Event.DeckSubmit":
if (entry.arrow == "<==") {
json = entry.json();
@@ -89,7 +89,7 @@ function processAnnotations() {
}
});
} catch (e) {
console.log(ann, e);
// console.log(ann, e);
processedOk = false;
}

@@ -116,7 +116,7 @@ function httpBasic() {
);
}

console.log("POST", _headers);
// console.log("POST", _headers);
var post_data = qs.stringify(_headers);
options.headers = {
"Content-Type": "application/x-www-form-urlencoded",
@@ -335,7 +335,7 @@ function httpBasic() {
ipc_send("ipc_log", e.message);
});
req.write(post_data);
console.log(req);
// console.log(req);
req.end();
},
function(err) {
@@ -556,7 +556,8 @@ function onLabelInPlayerInventoryGetPlayerInventory(entry, json) {
wcCommon: json.wcCommon,
wcUncommon: json.wcUncommon,
wcRare: json.wcRare,
wcMythic: json.wcMythic
wcMythic: json.wcMythic,
boosters: json.boosters
};
setData({ economy });
if (debugLog || !firstPass) store.set("economy", economy);
@@ -598,6 +599,78 @@ function onLabelInPlayerInventoryGetPlayerCardsV3(entry, json) {
setData({ cards, cardsNew });
}

//
function onLabelInProgressionGetPlayerProgress(entry, json) {
if (!json || !json.activeBattlePass) return;
logTime = parseWotcTime(entry.timestamp);
const activeTrack = json.activeBattlePass;
const economy = {
...pd.economy,
trackName: activeTrack.trackName,
trackTier: activeTrack.currentTier,
currentLevel: activeTrack.currentLevel,
currentExp: activeTrack.currentExp,
currentOrbCount: activeTrack.currentOrbCount
};
setData({ economy });
if (debugLog || !firstPass) store.set("economy", economy);
}

//
function onLabelTrackProgressUpdated(entry, json) {
if (!json) return;
// console.log(json);
const economy = { ...pd.economy };
json.forEach(entry => {
if (!entry.trackDiff) return; // ignore rewardWebDiff updates for now

const transaction = {
context: "Track Progress",
timestamp: entry.timestamp,
date: parseWotcTime(entry.timestamp),
delta: {},
...entry
};

const trackDiff = minifiedDelta(transaction.trackDiff);
if (trackDiff.inventoryDelta) {
// this is redundant data, removing to save space
delete trackDiff.inventoryDelta;
}
transaction.trackDiff = trackDiff;

if (entry.trackName) {
economy.trackName = entry.trackName;
}
if (entry.trackTier !== undefined) {
economy.trackTier = entry.trackTier;
}
if (trackDiff.currentLevel !== undefined) {
economy.currentLevel = trackDiff.currentLevel;
}
if (trackDiff.currentExp !== undefined) {
economy.currentExp = trackDiff.currentExp;
}

if (transaction.orbDiff) {
const orbDiff = minifiedDelta(transaction.orbDiff);
transaction.orbDiff = orbDiff;
if (orbDiff.currentOrbCount !== undefined) {
economy.currentOrbCount = orbDiff.currentOrbCount;
}
}

// Construct a unique ID
transaction.id = sha1(
entry.timestamp + JSON.stringify(transaction.trackDiff)
);
saveEconomyTransaction(transaction);
});
// console.log(economy);
setData({ economy });
if (debugLog || !firstPass) store.set("economy", economy);
}

function onLabelInEventDeckSubmit(entry, json) {
if (!json) return;
select_deck(json);
@@ -859,6 +932,7 @@ module.exports = {
onLabelInventoryUpdated,
onLabelInPlayerInventoryGetPlayerInventory,
onLabelInPlayerInventoryGetPlayerCardsV3,
onLabelInProgressionGetPlayerProgress,
onLabelInEventDeckSubmit,
onLabelInEventDeckSubmitV3,
onLabelInEventGetActiveEvents,
@@ -872,5 +946,6 @@ module.exports = {
onLabelMatchGameRoomStateChangedEvent,
onLabelInEventGetSeasonAndRankDetail,
onLabelGetPlayerInventoryGetRewardSchedule,
onLabelRankUpdated
onLabelRankUpdated,
onLabelTrackProgressUpdated
};

0 comments on commit c2180b2

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