You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
60 lines
2.2 KiB
local _, addonTable = ...
|
|
|
|
--- Basic DB abstraction layer.
|
|
-- Intended to manage the currently active profile without having to worry about AceDB and its shenanigans.
|
|
local Database = {}
|
|
|
|
-- Upvalues
|
|
local L = LibStub("AceLocale-3.0"):GetLocale("Rarity")
|
|
|
|
--- These items were at one point officially part of the addon's item database, but subsequently removed (usually because they weren't actually rare drops or Blizzard never added them to the live servers).
|
|
local obsoleteItems = {
|
|
items = {
|
|
-- Removed because they aren't actually a rare drop, but guaranteed (no point in tracking them)
|
|
["Ocean Simulator"] = true,
|
|
["Eternal Palace Dining Set"] = true,
|
|
-- Removed because they were never available to begin with (Blizzard didn't add them to live servers)
|
|
["Regenerating Banana Bunch"] = true,
|
|
["Kojo's Master Matching Set"] = true,
|
|
["Jinyu Light Globe"] = true,
|
|
["Words of Akunda"] = true,
|
|
},
|
|
pets = {
|
|
["Tiny Emerald Whelpling"] = true, -- Blizzard renamed this to "Emerald Whelpling" (data is not transfered)
|
|
["Mr. Pinchy"] = true, -- Not actually removed, but moved to the items category apparently? (data is not transfered)
|
|
},
|
|
}
|
|
|
|
--- Removes unused (dangling) entries from the DB.
|
|
-- These could cause issues if kept around and keeping them in mind when working on new features isn't necessary nor helpful.
|
|
-- TODO: Direct access of the AceDB tables is kind of awkward, think of a better way to streamline the APIs
|
|
function Database:PurgeObsoleteEntries()
|
|
for groupName, items in pairs(obsoleteItems) do
|
|
for itemKey, isObsolete in pairs(items) do
|
|
Rarity:Print(format(L["Removing data for obsolete item %s"], itemKey))
|
|
Rarity.db.profile.groups[groupName][itemKey] = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
function Database.IsItemAvailableToFactionGroup(item, englishFactionGroupName)
|
|
local isHorde = (englishFactionGroupName == "Horde")
|
|
local isAlliance = (englishFactionGroupName == "Alliance")
|
|
|
|
if not item.requiresAlliance and not item.requiresHorde then
|
|
return true
|
|
end
|
|
|
|
if item.requiresAlliance and isAlliance then
|
|
return true
|
|
end
|
|
|
|
if item.requiresHorde and isHorde then
|
|
return true
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
Rarity.Database = Database
|
|
return Database
|
|
|