-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathahdb.lua
More file actions
executable file
·42 lines (33 loc) · 848 Bytes
/
ahdb.lua
File metadata and controls
executable file
·42 lines (33 loc) · 848 Bytes
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
local Addon = select(2, ...)
local AHDB = {}
Addon.AHDB = AHDB
function AHDB.IsLoaded()
if AuctionDB and AuctionDB.AHGetAuctionInfoByLink then
return true
end
return false
end
function AHDB.GetItemValue(itemLink, priceSource)
if not AHDB.IsLoaded() then
return 0
end
local res = AuctionDB:AHGetAuctionInfoByLink(itemLink)
if priceSource == "AHDBMinBid" and res['minBid'] then
return res['minBid']
elseif priceSource == "AHDBMinBuyout" and res['minBuyout'] then
return res['minBuyout']
end
-- failsafe
return 0
end
function AHDB.GetAvailablePriceSources()
if not AHDB.IsLoaded() then
return
end
local ps = {}
local keys = { "AHDBMinBid", "AHDBMinBuyout" }
for _, v in ipairs(keys) do
ps[v] = Addon.CONST.PRICE_SOURCE[v]
end
return ps
end