fix cake

Leandro Silva [04-02-20 - 19:28]
fix cake
Filename
LeoDolmenRunner.lua
LeoDolmenRunner.txt
Runner.lua
Ui.lua
diff --git a/LeoDolmenRunner.lua b/LeoDolmenRunner.lua
index fe2e437..91e3ac2 100644
--- a/LeoDolmenRunner.lua
+++ b/LeoDolmenRunner.lua
@@ -1,9 +1,9 @@
 LeoDolmenRunner = {
     name = "LeoDolmenRunner",
     displayName = "Leo's Dolmen Runner",
-    version = "1.1.1",
+    version = "1.1.2",
     chatPrefix = "|c39B027LeoDolmenRunner|r: ",
-    debug = false,
+    isDebug = false,
     defaults = {
         hidden = true,
         runner = {
@@ -26,7 +26,7 @@ function LDR.log(message)
 end

 function LDR.debug(message)
-    if not LDR.debug then return end
+    if not LDR.isDebug then return end
     LDR.log("[D] " .. message)
 end

@@ -86,6 +86,7 @@ function LDR:Initialize()
         elseif options[1] == "stop" then LDR.runner:Stop()
         elseif options[1] == "cw" then LDR.runner:CW()
         elseif options[1] == "ccw" then LDR.runner:CCW()
+        elseif options[1] == "debug" and #options == 2 then LDR.isDebug = options[2] == "on"
         elseif options[1] == "ai" and #options == 2 and options[2] == "stop" then LDR.inviter:Stop()
         elseif string.len(options[1]) == 1 then LDR.inviter:Start(options[1])
         else LDR.log("Listening message must be only 1 letter (eg: x).")
diff --git a/LeoDolmenRunner.txt b/LeoDolmenRunner.txt
index 943f9e8..c33b709 100644
--- a/LeoDolmenRunner.txt
+++ b/LeoDolmenRunner.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Dolmen Runner
 ## APIVersion: 100029 100030
-## Version: 1.1.1
-## AddOnVersion: 111
+## Version: 1.1.2
+## AddOnVersion: 112
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoDolmenRunner_Data
 ## DependsOn: LibFeedback LibAddonMenu-2.0 LibSavedVars
diff --git a/Runner.lua b/Runner.lua
index 4f63dd2..f15acad 100644
--- a/Runner.lua
+++ b/Runner.lua
@@ -80,6 +80,7 @@ function Runner:Start()
     Runner.data.startedTime = GetTimeStamp()
     Runner.started = true
     LeoDolmenRunnerWindowPanelStartStopLabel:SetText("Stop")
+    LeoDolmenRunner.ui:CreateUI()
     self:GetActiveBuff()
 end

@@ -204,19 +205,25 @@ local buffs = {
     { id = 1167, from =  326, to =  403 }, -- The Pie of Misrule
     { id = 1168, from = 1217, to = 1231 }, -- Breda's Bottomless Mead Mug
     { id = 1168, from =  101, to =  105 }, -- Breda's Bottomless Mead Mug
-    { id = 7619 }, -- Jubilee Cake 2020
+    { id = 7619, abilityId = 136348 }, -- Jubilee Cake 2020
     { id = 5886 }, -- Jubilee Cake 2019
     { id = 4786 }, -- Jubilee Cake 2018
     { id = 1109 }, -- Jubilee Cake 2017
     { id =  356 }, -- Jubilee Cake 2016
 }

-local function isBuffActive(collectibleId)
+function Runner:IsBuffActive(collectible)
+    if type(collectible) ~= "table" then
+        for _, buff in ipairs(buffs) do
+            if buff.id == collectible then
+                collectible = buff
+                break
+            end
+        end
+    end
     for i = 1, GetNumBuffs("player") do
-        local buffName = GetUnitBuffInfo("player", i)
-        local referenceId = GetCollectibleReferenceId(collectibleId)
-        local abilityName = GetAbilityName(referenceId)
-        if abilityName == buffName then return true end
+        local buffName, _, _, _, _, _, _, _, _, _, abilityId = GetUnitBuffInfo("player", i)
+        if collectible.abilityId and abilityId == collectible.abilityId then return true end
     end
     return false
 end
@@ -232,14 +239,14 @@ function Runner:OnCombatState(inCombat)
             local date = tonumber(os.date("%m%d", GetTimeStamp()))
             for _, collectible in ipairs(buffs) do
                 local _, _, _, _, unlocked = GetCollectibleInfo(collectible.id)
-                if unlocked and collectible.from and collectible.from <= date and collectible.to >= date then
+                if unlocked and collectible.from and collectible.from <= date and collectible.to > date then
                     Runner.activeBuff = collectible.id
                     break
                 end
             end
         end

-        if Runner.activeBuff > 0 and not isBuffActive(Runner.activeBuff) then
+        if Runner.activeBuff > 0 and not self:IsBuffActive(Runner.activeBuff) then
             LeoDolmenRunner.log("Reapplying " .. GetCollectibleInfo(Runner.activeBuff))
             UseCollectible(Runner.activeBuff)
         end
@@ -269,7 +276,7 @@ end

 function Runner:GetActiveBuff()
     for _, collectible in pairs(buffs) do
-        if isBuffActive(collectible.id) then
+        if self:IsBuffActive(collectible) then
             Runner.activeBuff = collectible.id
             -- LeoDolmenRunner.debug("Found buff " .. Runner.activeBuff)
             return
diff --git a/Ui.lua b/Ui.lua
index 92e4e26..678a8c9 100644
--- a/Ui.lua
+++ b/Ui.lua
@@ -133,6 +133,7 @@ function Ui:Update(tick)
     LeoDolmenRunnerWindowPanelXPNext:SetText(ZO_CachedStrFormat(GetString(SI_TIME_FORMAT_HHMM_DESC_SHORT), LDR.runner.data.hoursToLevel, LDR.runner.data.minutesToLevel))

     LeoDolmenRunnerWindowInviterPanelMessage:SetText("x")
+    LeoDolmenRunnerWindowInviterPanel:SetHidden(not IsUnitSoloOrGroupLeader("player"))
 end

 function Ui:OnWindowMoveStop()