HandyNotes: Mechagon & Nazjatar

HandyNotes: Mechagon & Nazjatar

878k Downloads

Suggestion/Feature Request: "ns.requirement.ItemAny"

pepedressingroom opened this issue ยท 2 comments

commented

Hi developers, how about adding a requirement that hints requiring any of several items?

There are some examples:

-- DISTURBED DIRT
-- SMELLY TREASURE CHEST
ns.requirement.Item(191294) -- Small Expedition Shovel
ns.requirement.ItemAny(L['expedition_shovel'], 191294, 191304) -- Small/Sturdy Expedition Shovel

-- ELUSIVE CREATURES
ns.requirement.Item(193906) -- Elusive Creature Bait
ns.requirement.ItemAny(L['creature_bait'], 193906, 198804, 198805, 198806, 198807) -- Elusive /Frost-/Earth-/Decay-/Titan-Infused Creature Bait

-- DREAMSEED SOIL
ns.requirement.Item(208066) -- Small Dreamseed
ns.requirement.ItemAny('{spell:429182}', 208066, 208067, 208047) -- Small/Plump/Gigantic Dreamseed

-- RICH SOIL
ns.requirement.ItemAny('{item:200506}', 200506, 200508, 200507, 200509) -- Roused Seedling, Propagating /Decayed / Agitated Roused Seedling

It requires common strings of names to be set, and sometimes you have to localize the common strings.
Do you think it reasonable and necessary?

----------------------------------- ITEMANY -----------------------------------

local ItemAny = Class('ItemAny', Requirement, {type = L['item']})

function ItemAny:Initialize(name, ...)
    self.text, self.ids = name, {...}
end

function ItemAny:IsMet()
    local x = false
    for i = 1, #self.ids do
        x = x or ns.PlayerHasItem(self.ids[i])
    end
    return x
end
commented

cant we just add a any = true feature to the existing Item Requirement?

ns.requirement.Item({123, 456, 789}, any = true) something like that?

commented

I agree with Ioney here. If we need this feature we would probably enhance the existing Item() class. I'm going to close this for now but if this comes up as we put more nodes into the plugins we'll have an idea of where to start on this feature.