HandyNotes: Dragonflight

HandyNotes: Dragonflight

25M Downloads

[Feature] More support for C_QuestLog.IsQuestFlaggedCompletedOnAccount(questid)

pepedressingroom opened this issue ยท 1 comments

commented

There are many contents are unlocked by IsQuestFlaggedCompletedOnAccount instead of IsQuestFlaggedCompleted.
Is it make sense to add more support for this API?

core\requirements.lua

-------------------------------------------------------------------------------
------------------------------------ QUEST ------------------------------------
-------------------------------------------------------------------------------

local Quest = Class('Quest', Requirement, {type = L['quest']})

-- function Quest:Initialize(id, text, repeatable)
--     self.id = id
--     self.text = text
--     self.type = repeatable and L['quest_repeatable'] or self.type
-- end

-- function Quest:GetText()
--     local text = C_QuestLog.GetTitleForQuestID(self.id) or self.text or UNKNOWN
--     return ('%s (%s)'):format(text, self.type)
-- end

-- function Quest:IsMet() return C_QuestLog.IsQuestFlaggedCompleted(self.id) end

function Quest:Initialize(id, text, repeatable, warband)
    self.id = id
    self.text = text
    self.type = repeatable and L['quest_repeatable'] or self.type
    self.warband = warband
end

function Quest:GetText()
    local text = C_QuestLog.GetTitleForQuestID(self.id) or self.text or UNKNOWN
    local types = self.warband and _G.ACCOUNT_QUEST_LABEL or self.type
    return ('%s (%s)'):format(text, types)
end

function Quest:IsMet()
    return self.warband and C_QuestLog.IsQuestFlaggedCompletedOnAccount(self.id)
    or C_QuestLog.IsQuestFlaggedCompleted(self.id)
end

core\nodes.lua

--[[
Return the prerequisite state of this node. A node has its prerequisites met if
all quests defined in the `questDeps` attribute are completed. This method can
be overridden to check for other prerequisite criteria.
--]]

-- function Node:PrerequisiteCompleted()
--     -- Prerequisite not met if any dependent quest ids are false
--     if not self.questDeps then return true end
--     for i, quest in ipairs(self.questDeps) do
--         if not C_QuestLog.IsQuestFlaggedCompleted(quest) then
--             return false
--         end
--     end
--     return true
-- end

function Node:PrerequisiteCompleted()
    -- Prerequisite not met if any dependent quest ids are false
    if not self.questDeps and not self.accountDeps then return true end
    if self.questDeps then
        for i, quest in ipairs(self.questDeps) do 
            if not C_QuestLog.IsQuestFlaggedCompleted(quest) then
                return false
            end
        end
    end
    if self.accountDeps then
        for i, quest in ipairs(self.accountDeps) do 
            if not C_QuestLog.IsQuestFlaggedCompletedOnAccount(quest) then
                return false
            end
        end
    end
    return true
end

Here are 2 examples:
This vendor in Undermine is unlocked account wide, when one character complete the quest line.

map.nodes[30723890] = Vendor({
    id = 231396,
    sublabel = format(L['quartermaster'], '{faction:2669}'),
    location = L['in_sewer'],
    requires = ns.requirement.Quest(86961, _, _, true), -- ![Diversified Investments] (warband)
    rewards = {}
}) -- Sitch Lowdown <Darkfuse Solutions Quartermaster>

In zul_gurub.lua, the contents are also unlocked account wide, many nodes are hidden when your alts did not do the quest line under questDeps = 74576,

-------------------------------------------------------------------------------
------------------------------ ZANDALARI BIJOUS -------------------------------
-------------------------------------------------------------------------------

local BigBagOBijous = Class('BigBagOBijous', Collectible, {
    label = '{item:203774}',
    icon = 132528,
    -- questDeps = 74576, -- Restored Hakkari Bijou
    accountDeps = 74576, -- Restored Hakkari Bijou
    group = ns.groups.SECRETS_OF_ZULGURUB,
    fgroup = 'offering_bone_pile',
    IsEnabled = function() return true end,
    pois = {
        Path({Circle({origin = 51675708, radius = 3})}), -- Offering of Fangs
        Path({Circle({origin = 61398279, radius = 3})}), -- Offering of Blood
        Path({Circle({origin = 47722377, radius = 3})}), -- Offering of Claws
        Path({Circle({origin = 30031935, radius = 3})}) -- Offering of Mojo
    }
}) -- Big Bag o' Bijous
commented

i see you already added this in your PR #481