From 0c861f070d7113c39b17e7616eaf66f6acc2c728 Mon Sep 17 00:00:00 2001 From: TheKrowi <22818581+TheKrowi@users.noreply.github.com> Date: Thu, 18 Aug 2022 17:23:53 +0200 Subject: [PATCH] tests --- Data/EventData.lua | 4 ++++ Globals.lua | 40 ++++++++++++++++++++++++++-------------- Objects/Event.lua | 18 ++++++++---------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/Data/EventData.lua b/Data/EventData.lua index e4015569..39ddba0e 100644 --- a/Data/EventData.lua +++ b/Data/EventData.lua @@ -144,13 +144,17 @@ function GetSavedWorldEvents(activeWorldEvents, currentDate) end function GetNewWorldEvents(activeWorldEvents) + -- print("GetNewWorldEvents(activeWorldEvents)") for _, event in next, data.WorldEvents do + -- print(event.Id, event.ID, event.Icon, event.Name, event.MapID, event.TotalDuration); if event.EventDetails == nil and addon.Options.db.EventReminders.WorldEvents[event.ID] then local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(event.MapID, event.ID); + -- print(poiInfo); if poiInfo then -- The event is active local secondsLeft = C_AreaPoiInfo.GetAreaPOISecondsLeft(event.ID); -- diagnostics.Debug(secondsLeft); if secondsLeft == nil or secondsLeft == 0 then + -- print("problem", event.Id) return; -- C_AreaPoiInfo is not yet properly loaded end diff --git a/Globals.lua b/Globals.lua index f580787b..12eff161 100644 --- a/Globals.lua +++ b/Globals.lua @@ -462,19 +462,6 @@ function addon.ChangeAchievementMicroButtonOnClick() end); end --- function KrowiAF_FireEvent(event, ...) --- event=event:upper();-- Events are always uppercase --- local list={GetFramesRegisteredForEvent(event)};-- Get list of frames --- for _,frame in ipairs(list) do --- local func=frame:GetScript("OnEvent");-- Get OnEvent handler --- if func then --- print(frame:GetName()); --- end-- Run it if there is one --- end --- end - --- /run KrowiAF_FireEvent("ACHIEVEMENT_EARNED"); - local cachedIsNotWotLKClassic, cachedIsWotLKClassic; function addon.IsNotWotLKClassic() if cachedIsNotWotLKClassic ~= nil then @@ -528,4 +515,29 @@ end function addon.GetCovenantName(covenantID) return C_Covenants and C_Covenants.GetCovenantData(covenantID).name or covenantID; -end \ No newline at end of file +end + +-- function KrowiAF_FireEvent(event, ...) +-- event=event:upper();-- Events are always uppercase +-- local list={GetFramesRegisteredForEvent(event)};-- Get list of frames +-- for _,frame in ipairs(list) do +-- local func=frame:GetScript("OnEvent");-- Get OnEvent handler +-- if func then +-- print(frame:GetName()); +-- end-- Run it if there is one +-- end +-- end + +-- /run KrowiAF_FireEvent("ACHIEVEMENT_EARNED"); + +-- function KrowiAF_GetAreaPOILeft() +-- for i = 1, 7216 do +-- local left = C_AreaPoiInfo.GetAreaPOISecondsLeft(i); +-- if left then +-- print(i, left); +-- end +-- end +-- print(i) +-- end + +-- /run KrowiAF_GetAreaPOILeft(); \ No newline at end of file diff --git a/Objects/Event.lua b/Objects/Event.lua index 1212b882..5f92f064 100644 --- a/Objects/Event.lua +++ b/Objects/Event.lua @@ -6,17 +6,15 @@ local event = objects.Event; event.__index = event; function event:New(id, icon, name, mapID, totalDuration) - local self = {}; - setmetatable(self, event); + local instance = setmetatable({}, event); - self.Id = id or 0; - self.ID = self.Id; - self.Icon = icon or 0; - self.Name = name; - self.MapID = mapID; - self.TotalDuration = totalDuration; - - return self; + instance.Id = id or 0; + instance.ID = instance.Id; + instance.Icon = icon or 0; + instance.Name = name; + instance.MapID = mapID; + instance.TotalDuration = totalDuration; + return instance; end function event:AddAchievement(achievement)