-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogic.lua
More file actions
80 lines (68 loc) · 2.06 KB
/
Logic.lua
File metadata and controls
80 lines (68 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
local addonName, addon = ...
-- Cache and state
local questCompletionCache = {}
function addon:IsInValidZone()
local mapID = C_Map.GetBestMapForUnit("player")
return mapID and addon.VALID_ZONES[mapID] or false
end
function addon:HasCHETTList()
return C_Item.GetItemCount(addon.C_HETT_LIST_ITEM, false) > 0
end
function addon:IsWeeklyCompleted()
return C_QuestLog.IsQuestFlaggedCompleted(addon.WEEKLY_QUEST_ID)
end
function addon:IsSideGigCompleted()
for questID, _ in pairs(addon.SIDE_GIG_QUESTS) do
if C_QuestLog.IsQuestFlaggedCompleted(questID) or questCompletionCache[questID] then
return true
end
end
return false
end
function addon:IsSideGigReady()
for questID, _ in pairs(addon.SIDE_GIG_QUESTS) do
if C_QuestLog.IsOnQuest(questID) and C_QuestLog.ReadyForTurnIn(questID) then
return true
end
end
return false
end
function addon:GetCompletedCount()
local count = 0
for _, quest in ipairs(addon.QUESTS) do
if quest.key == "gig" then
if self:IsSideGigCompleted() then count = count + 1 end
elseif C_QuestLog.IsQuestFlaggedCompleted(quest.id) or questCompletionCache[quest.id] then
count = count + 1
end
end
return count
end
function addon:GetReadyCount()
local count = 0
for _, quest in ipairs(addon.QUESTS) do
if quest.key == "gig" then
if self:IsSideGigReady() then count = count + 1 end
elseif C_QuestLog.IsOnQuest(quest.id) and C_QuestLog.ReadyForTurnIn(quest.id) then
count = count + 1
end
end
return count
end
function addon:CacheQuestCompletion(questID)
questCompletionCache[questID] = true
end
function addon:ClearQuestCache()
questCompletionCache = {}
end
function addon:IsQuestCached(questID)
return questCompletionCache[questID]
end
function addon:CheckQuestInList(questID)
for _, quest in ipairs(addon.QUESTS) do
if quest.id == questID then
return true
end
end
return addon.SIDE_GIG_QUESTS[questID] ~= nil
end