loot table: finalizing touches for reversed lookup table, modified "GetSource" function for revLUT and added function for fetching items of multiple sources. (old loot table remains for the search function to work)
This commit is contained in:
@@ -9,16 +9,21 @@ local BI = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
|
||||
local WHITE = "|cFFFFFFFF"
|
||||
local GREEN = "|cFF00FF00"
|
||||
|
||||
local lootTable, lootTableRev
|
||||
do
|
||||
local lootTable, lootTableRev_Single, lootTableRev_Multi
|
||||
local LootSourceTooltipDB = {}
|
||||
local LootSourceTooltip_VERSION = 2
|
||||
|
||||
|
||||
local DataProviders
|
||||
|
||||
addon.Loots = {}
|
||||
|
||||
local ns = addon.Loots -- ns = namespace
|
||||
|
||||
|
||||
-- Simplified loot table containing item ID's only, based on AtlasLoot v5.09.00
|
||||
lootTable = {
|
||||
|
||||
-- to do: HardModeArena & HardModeArena2 from sets_en.lua
|
||||
-- to do : wotlk crafts
|
||||
-- to do : pvp non set 80, line 3000 in wotlk.lua of AL 5.04
|
||||
-- tier 8
|
||||
|
||||
-- ** Miscellaneous **
|
||||
[L["Bash'ir Landing"]] = {
|
||||
[L["Skyguard Raid"]] = { 32596, 32600, 32599, 32597, 32634, 32637, 32635, 32636, 32639, 32638,
|
||||
@@ -3533,47 +3538,104 @@ do
|
||||
|
||||
}
|
||||
|
||||
lootTableRev = {}
|
||||
|
||||
|
||||
function ns:setupLootTable()
|
||||
LootSourceTooltipDB = Altoholic.db.global.LootSourceTooltip
|
||||
|
||||
if not LootSourceTooltipDB.version or LootSourceTooltipDB.version ~= LootSourceTooltip_VERSION then
|
||||
|
||||
|
||||
local lootSecundary = { -- these items are only considered second after all other sources
|
||||
L["Emblem of Frost"],
|
||||
L["Emblem of Triumph"],
|
||||
L["Emblem of Conquest"],
|
||||
L["Emblems of Valor"],
|
||||
L["Emblems of Heroism"],
|
||||
L["Badge of Justice"],
|
||||
BZ["Vault of Archavon"],
|
||||
}
|
||||
local lootSecundaryCheck = {}
|
||||
for k,v in pairs(lootSecundary) do lootSecundaryCheck[v]= true; end
|
||||
|
||||
|
||||
|
||||
local lastZone = {}
|
||||
|
||||
local lootTable_names = {}
|
||||
|
||||
for zName, _ in pairs(lootTable) do
|
||||
tinsert( lootTable_names, zName )
|
||||
end
|
||||
sort(lootTable_names)
|
||||
local zTable
|
||||
|
||||
lootTableRev_Single = {}
|
||||
lootTableRev_Multi = {}
|
||||
-- PRIMARY
|
||||
for _, zName in pairs(lootTable_names) do
|
||||
if not lootSecundaryCheck[zName] then -- check primary sources first
|
||||
zTable = lootTable[zName]
|
||||
for encounterName, encounterTable in pairs(zTable) do
|
||||
for _, item_id in pairs(encounterTable) do
|
||||
if not lootTableRev[item_id] then
|
||||
lootTableRev[item_id] = format("%s, %s", zName, encounterName)
|
||||
else
|
||||
if lastZone[item_id] and lastZone[item_id] == zName then
|
||||
lootTableRev[item_id] = format("%s/ %s", lootTableRev[item_id], encounterName)
|
||||
else
|
||||
lootTableRev[item_id] = format("%s; %s, %s", lootTableRev[item_id], zName, encounterName)
|
||||
end
|
||||
if not lootTableRev_Single[item_id] then -- insert only once
|
||||
lootTableRev_Single[item_id] = format("%s\1%s", zName, encounterName)
|
||||
end
|
||||
|
||||
if not lootTableRev_Multi[item_id] then
|
||||
lootTableRev_Multi[item_id] = format("%s, %s", zName, encounterName)
|
||||
else
|
||||
if lastZone[item_id] and lastZone[item_id] == zName then
|
||||
lootTableRev_Multi[item_id] = format("%s/ %s", lootTableRev_Multi[item_id], encounterName)
|
||||
else
|
||||
lootTableRev_Multi[item_id] = format("%s; %s, %s", lootTableRev_Multi[item_id], zName, encounterName)
|
||||
end
|
||||
end
|
||||
lastZone[item_id] = zName
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DEBUG_HELP_TEST_1 = lootTableRev
|
||||
DEBUG_HELP_TEST_2 = lootTable
|
||||
wipe(lastZone)
|
||||
wipe(lootTable_names)
|
||||
end
|
||||
-- SECUNDARY
|
||||
for _, zName in pairs(lootTable_names) do
|
||||
if lootSecundaryCheck[zName] then -- check secundary sources next
|
||||
zTable = lootTable[zName]
|
||||
for encounterName, encounterTable in pairs(zTable) do
|
||||
for _, item_id in pairs(encounterTable) do
|
||||
if not lootTableRev_Single[item_id] then -- insert only once
|
||||
lootTableRev_Single[item_id] = format("%s\1%s", zName, encounterName)
|
||||
end
|
||||
|
||||
local DataProviders
|
||||
if not lootTableRev_Multi[item_id] then
|
||||
lootTableRev_Multi[item_id] = format("%s, %s", zName, encounterName)
|
||||
else
|
||||
if lastZone[item_id] and lastZone[item_id] == zName then
|
||||
lootTableRev_Multi[item_id] = format("%s/ %s", lootTableRev_Multi[item_id], encounterName)
|
||||
else
|
||||
lootTableRev_Multi[item_id] = format("%s; %s, %s", lootTableRev_Multi[item_id], zName, encounterName)
|
||||
end
|
||||
end
|
||||
lastZone[item_id] = zName
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
addon.Loots = {}
|
||||
-- LootSourceTooltip = { version = 0, single={}, multi={}, },
|
||||
wipe(LootSourceTooltipDB.multi)
|
||||
wipe(LootSourceTooltipDB.single)
|
||||
LootSourceTooltipDB.multi = lootTableRev_Multi
|
||||
LootSourceTooltipDB.single = lootTableRev_Single
|
||||
|
||||
local ns = addon.Loots -- ns = namespace
|
||||
LootSourceTooltipDB.version = LootSourceTooltip_VERSION
|
||||
|
||||
wipe(lastZone)
|
||||
wipe(lootTable_names)
|
||||
else -- ################################################################################################
|
||||
|
||||
end
|
||||
|
||||
lootTable[ BZ["Vault of Archavon"] ] = nil -- we ignore this one, cuz its confusing
|
||||
end
|
||||
|
||||
function ns:GetSource(searchedID)
|
||||
DataProviders = DataProviders or { -- list of sources that have a :GetSource() method
|
||||
@@ -3582,6 +3644,37 @@ function ns:GetSource(searchedID)
|
||||
DataStore_Inventory,
|
||||
}
|
||||
|
||||
-- LootSourceTooltipDB.single
|
||||
if LootSourceTooltipDB.single[searchedID] then
|
||||
local txt,domain, subDomain
|
||||
txt = LootSourceTooltipDB.single[searchedID]
|
||||
domain, subDomain = strmatch(txt, "(.+)\1(.+)")
|
||||
return domain, subDomain
|
||||
end
|
||||
|
||||
local domain, subDomain
|
||||
for _, provider in pairs(DataProviders) do
|
||||
domain, subDomain = provider:GetSource(searchedID)
|
||||
if domain and subDomain then
|
||||
return domain, subDomain
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function ns:GetSource_multi(searchedID)
|
||||
-- LootSourceTooltipDB.multi
|
||||
return LootSourceTooltipDB.multi[searchedID]
|
||||
end
|
||||
|
||||
function ns:GetSource_OLD(searchedID) -- old version
|
||||
DataProviders = DataProviders or { -- list of sources that have a :GetSource() method
|
||||
DataStore_Reputations,
|
||||
DataStore_Crafts,
|
||||
DataStore_Inventory,
|
||||
}
|
||||
|
||||
-- extremely fast: takes from 0.3 to 3 ms max, depends on the location of the item in the table (obviously longer if the item is at the end)
|
||||
for Instance, BossList in pairs(lootTable) do
|
||||
for Boss, LootList in pairs(BossList) do
|
||||
|
||||
Reference in New Issue
Block a user