diff --git a/Baggins.toc b/Baggins.toc index 4c7ee59..798ffd8 100644 --- a/Baggins.toc +++ b/Baggins.toc @@ -97,6 +97,7 @@ src\filters\Empty.lua src\filters\EquipLocation.lua src\filters\EquipmentSet.lua src\filters\EquipmentSlot.lua +src\filters\Expansion.lua src\filters\ItemBind.lua src\filters\ItemID.lua src\filters\ItemLevel.lua diff --git a/src/filters/Expansion.lua b/src/filters/Expansion.lua new file mode 100644 index 0000000..3f3b926 --- /dev/null +++ b/src/filters/Expansion.lua @@ -0,0 +1,69 @@ +--[[ ========================================================================== + +Expansion.lua + +========================================================================== ]]-- + +local AddOnName, _ = ... +local AddOn = _G[AddOnName] + +-- Libs +--local LibStub = _G.LibStub +--local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName) + +local GetContainerItemLink = _G.C_Container and _G.C_Container.GetContainerItemLink or _G.GetContainerItemLink +local GetItemInfo = _G.C_Item and _G.C_Item.GetItemInfo or _G.GetItemInfo + +local itemExpansion = { + [0] = "Classic", + [1] = "The Burning Crusade", + [2] = "Wrath of the Lich King", + [3] = "Cataclysm", + [4] = "Mists of Pandaria", + [5] = "Warlords of Draenor", + [6] = "Legion", + [7] = "Battle for Azeroth", + [8] = "Shadowlands", + [9] = "Dragonflight", +} + + +local function Matches(bag, slot, rule) + local status = rule.status + if not status then return end + local itemLink = GetContainerItemLink(bag, slot) + local expansionID = itemLink and select(15,GetItemInfo(itemLink)) + return status == itemExpansion[expansionID] +end + +-- Clean rule +local function CleanRule(rule) + + rule.bagid=0 + +end + +AddOn:AddCustomRule("Expansion", { + DisplayName = "Expansion", + Description = "Matches all items originating from chosen expansion.", + Matches = Matches, + Ace3Options = { + status = { + name = "Expansion", + desc = "", + type = 'select', + values = { + ["Classic"] = "Classic", + ["The Burning Crusade"] = "The Burning Crusade", + ["Wrath of the Lich King"] = "Wrath of the Lich King", + ["Cataclysm"] = "Cataclysm", + ["Mists of Pandaria"] = "Mists of Pandaria", + ["Warlords of Draenor"] = "Warlords of Draenor", + ["Legion"] = "Legion", + ["Battle for Azeroth"] = "Battle for Azeroth", + ["Shadowlands"] = "Shadowlands", + ["Dragonflight"] = "Dragonflight", + } + }, + }, +}) \ No newline at end of file