-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
atr.lua
executable file
·55 lines (47 loc) · 1.26 KB
/
atr.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local Addon = select(2, ...)
local ATR = {}
Addon.ATR = ATR
local private = {}
function ATR.IsLoaded()
if Auctionator and Auctionator.API and Auctionator.API.v1 and Auctionator.API.v1.GetAuctionPriceByItemLink then
-- retail
private.isRetail = true
private.isClassic = false
local ok = pcall(function()
Auctionator.API.v1.RegisterForDBUpdate("BagAppraiser", function() Addon:UpdateData() end)
end)
if not ok then
Addon:Print("failed to register updates with Auctionator")
end
return true
elseif Atr_GetAuctionBuyout then
-- classic
private.isRetail = false
private.isClassic = true
return true
end
return false
end
function ATR.GetItemValue(itemLink, priceSource)
if not ATR.IsLoaded() then
return 0
end
if private.isRetail then
return Auctionator.API.v1.GetAuctionPriceByItemLink("BagAppraiser", itemLink)
elseif private.isClassic then
return Atr_GetAuctionBuyout(itemLink)
end
-- failsafe
return 0
end
function ATR.GetAvailablePriceSources()
if not ATR.IsLoaded() then
return
end
local ps = {}
local keys = { "ATRMarket" }
for _, v in ipairs(keys) do
ps[v] = Addon.CONST.PRICE_SOURCE[v]
end
return ps
end