diff Modules/ArtifactPower.lua @ 136:414e37af1b1b v8.0.1-20180718

8.0.1 "pre-patch" updates - disabled PaperDoll, ArtifactPower, and Social/LFG modules
author Nenue
date Wed, 18 Jul 2018 15:31:15 -0400
parents 4979b5cca6de
children
line wrap: on
line diff
--- a/Modules/ArtifactPower.lua	Thu Jan 25 20:58:10 2018 -0500
+++ b/Modules/ArtifactPower.lua	Wed Jul 18 15:31:15 2018 -0400
@@ -70,10 +70,9 @@
       self:Update()
     elseif arg == 'reset' then
       if self.db then
-        table.wipe(self.db.cache)
-        table.wipe(self.db.fishingCache)
+        self:ResetCache()
       end
-      self:Print('Cache data reset.')
+      self:Print('Forced refresh.')
       self:Update()
     elseif arg:match('item') then
       print('name', arg:match("^item (%S.+)"))
@@ -298,6 +297,7 @@
   self.enabled = true
 
   self:ScanAllBags()
+  self:TryToShow()
   self:Reanchor()
 end
 function Module:OnHide()
@@ -342,7 +342,15 @@
   --print('|cFF00FF88OnEvent()', event, ...)
   if event == 'PLAYER_ENTERING_WORLD' then
     self:TryToShow()
+
+  elseif event == 'UNIT_LEVEL' then
+
+    if UnitLevel('player') == 110 then
+      self.profile.knowledgeMultiplier = 52
+    end
+
   elseif event == 'BAG_UPDATE' then
+
     local containerID = ...
     self:QueueBag(containerID)
   elseif event == 'ITEM_LOCK_CHANGED' then
@@ -357,16 +365,19 @@
 
   elseif event == 'PLAYER_BANKSLOTS_CHANGED' then
     self:ScanAllBags()
+    self:TryToShow()
   elseif event == 'BAG_UPDATE_DELAYED' then
     if not self.firstHit then
       -- prevent double call from login
       self.firstHit = true
     else
       self:ScanAllBags()
+      self:TryToShow()
     end
   elseif event == 'BANKFRAME_OPENED' then
     self.bankAccess = true
     self:ScanAllBags()
+    self:TryToShow()
   elseif event == 'BANKFRAME_CLOSED' then
     self.bankAccess = nil
   elseif event == 'ARTIFACT_UPDATE' then
@@ -386,10 +397,10 @@
 
     if self.queuedScan then
       self:ScanAllBags(self.backAccess)
-    else
-      self:TryToShow()
     end
 
+    self:TryToShow()
+
     if #queued_hooks >= 1 then
       CreateHook()
     end
@@ -464,10 +475,17 @@
   end
   print('|cFFFFFF00pdate()|r')
 
+
+  local level = UnitLevel('player')
+  if level ~= self.profile.playerLevel then
+    self.profile.playerLevel = level
+    self:ResetCache()
+  end
+
+
   local numButtons = 0
   local contentsHeight = 16
   local contentsWidth = 400
-  if self.profile.knowledgeMultiplier then
     local artifactsWidth = self:UpdateArtifactButtons()
 
     if artifactsWidth ~= 0 then
@@ -479,12 +497,11 @@
     local itemsWidth, itemsHeight = self:UpdateItemButtons()
     contentsHeight = contentsHeight + itemsHeight
     contentsWidth = max(contentsWidth, itemsWidth)
-  end
 
 
 
   local bankText, bagText
-  if not self.profile.knowledgeMultiplier then
+  if artifactsWidth == 0 then
     bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.'
   elseif not (self.bankAP and self.bagAP) then
     bankText = '|cFFFF0000Open bank frame to count all AP|r '
@@ -954,10 +971,9 @@
     self.queuedScan = true
     return
   end
-  if not self.profile.knowledgeMultiplier then
-    print('need to get knowledge level')
-    return
-  end
+
+
+
 
   self.queuedScan = nil
 
@@ -1002,7 +1018,6 @@
   end
   self.lastUpdate = GetTime()
   self.queuedScan = nil
-  self:TryToShow()
 end
 
 
@@ -1031,15 +1046,21 @@
   local actualXP = artifact.currentXP
   local actualLevel = artifact.level
   local actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
+  local actualTier = artifact.tier
 
   print('tier:', artifact.tier)
   print('current:', self.level, self.currentXP, '/', self.currentCost)
   while (actualXP >= actualCost) and (actualCost > 0) do
     actualXP = actualXP - actualCost
     actualLevel = actualLevel + 1
-    actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
+    if actualLevel == 35 then
+      -- accomodate the auto-empowerment that occurs at 35 as of patch 7.3
+      actualTier = 2
+      print('tier =', actualTier)
+    end
+    actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, actualTier)
 
-    print('* ', actualLevel, actualXP, actualCost, totalCost)
+    print('* ', actualLevel, actualXP, actualCost, actualCost)
   end
   print('actual:', actualLevel, actualXP, '/', actualCost)
 
@@ -1055,7 +1076,7 @@
     while (remaining >= nextCost) and (nextCost > 0) do
       totalLevel = totalLevel + 1
       remaining = remaining - nextCost
-      nextCost = C_ArtifactUI.GetCostForPointAtRank(totalLevel, artifact.tier)
+      nextCost = C_ArtifactUI.GetCostForPointAtRank(totalLevel, actualTier)
       print('|cFFFFFF00+ ', totalLevel, remaining, '/', totalCost)
     end
     totalXP = remaining
@@ -1069,10 +1090,12 @@
   self.actualCost = actualCost
   self.actualLevel = actualLevel
   self.actualXP = actualXP
+  self.actualTier = actualTier
 
   self.totalXP = totalXP
   self.totalCost = totalCost
   self.totalLevel = totalLevel
+  self.totalTier = totalTier