Skip to content

Commit

Permalink
Fix Experience Calculation for Shadowlands 9.0.1 Quest Log API (#12 #13)
Browse files Browse the repository at this point in the history
* fix max level and quest log scanning for 9.0.1

* fix scanning through all quest log entries
  • Loading branch information
shururuun authored Oct 14, 2020
1 parent bf24c07 commit e7234bb
Showing 1 changed file with 19 additions and 38 deletions.
57 changes: 19 additions & 38 deletions modules/experience.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function module:ResetSession()
end

function module:IsPlayerMaxLevel(level)
return MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] == (level or UnitLevel("player"));
return GetMaxLevelForPlayerExpansion() == (level or UnitLevel("player"));
end

function module:CalculateHourlyXP()
Expand Down Expand Up @@ -506,44 +506,25 @@ end

function module:CalculateQuestLogXP()
local completeXP, incompleteXP = 0, 0;
local _, numQuests = GetNumQuestLogEntries();
if (numQuests == 0) then return 0, 0, 0; end

local index = 1;
local lastSelected = GetQuestLogSelection();
repeat
local title, _, _, isHeader, _, isComplete, _, questID, _, displayQuestID, isOnMap, hasLocalPOI, isTask, isBounty, isStory, isHidden, isScaling = GetQuestLogTitle(index);
if (title and not isHeader and not isHidden) then
SelectQuestLogEntry(index);

local validEntry = true;

local questTagID, tagName = GetQuestTagInfo(questID);
if (questTagID == 102 and not self.db.global.QuestXP.IncludeAccountWide) then
validEntry = false;
end

if (validEntry) then
local requiredMoney = GetQuestLogRequiredMoney(index);
local numObjectives = GetNumQuestLeaderBoards(index);

if (isComplete and isComplete < 0) then
isComplete = false;
elseif (numObjectives == 0 and GetMoney() >= requiredMoney) then
isComplete = true;
end

if (isComplete) then
completeXP = completeXP + GetQuestLogRewardXP();
else
incompleteXP = incompleteXP + GetQuestLogRewardXP();
end
end

local numEntries, _ = C_QuestLog.GetNumQuestLogEntries();
if (numEntries == 0) then return 0, 0, 0; end

for index = 1, numEntries do repeat
local qinfo = C_QuestLog.GetInfo(index)
local questID = qinfo["questID"]
if (questID == 0 or qinfo["isHeader"] or qinfo["isHidden"]) then
break
end
index = index + 1;
until (title == nil);

SelectQuestLogEntry(lastSelected);
if (not self.db.global.QuestXP.IncludeAccountWide and C_QuestLog.IsAccountQuest(questID)) then
break
end
if (C_QuestLog.ReadyForTurnIn(questID)) then
completeXP = completeXP + GetQuestLogRewardXP(questID);
else
incompleteXP = incompleteXP + GetQuestLogRewardXP(questID);
end
until true end

local multiplier = module:CalculateXPMultiplier();
return completeXP * multiplier, incompleteXP * multiplier, (completeXP + incompleteXP) * multiplier;
Expand Down

0 comments on commit e7234bb

Please sign in to comment.