Asa@89
|
1 local ItemAuditor = select(2, ...)
|
Asa@89
|
2 local AuctionHouse = ItemAuditor:NewModule("AuctionHouse")
|
Asa@89
|
3
|
Asa@89
|
4 local addon_options
|
Asa@89
|
5 local function getAddons()
|
Asa@89
|
6 -- this will ensure that the addons are only scanned once per session.
|
Asa@89
|
7 if not addon_options then
|
Asa@89
|
8 addon_options = {}
|
Asa@89
|
9 local total = 0
|
Asa@89
|
10 local lastKey
|
Asa@89
|
11 if AucAdvanced and AucAdvanced.Version then
|
Asa@89
|
12 addon_options['auctioneer'] = 'Auctioneer'
|
Asa@89
|
13 total = total + 1
|
Asa@89
|
14 lastKey = 'auctioneer'
|
Asa@89
|
15 end
|
Asa@89
|
16 if GetAuctionBuyout ~= nil then
|
Asa@89
|
17 addon_options['other'] = 'Other (GetAuctionBuyout compatibile)'
|
Asa@89
|
18 total = total + 1
|
Asa@89
|
19 lastKey = 'other'
|
Asa@89
|
20 end
|
Asa@89
|
21
|
Asa@89
|
22 if total == 1 or not ItemAuditor.db.profile.auction_addon then
|
Asa@89
|
23 ItemAuditor.db.profile.auction_addon = lastKey
|
Asa@89
|
24 end
|
Asa@89
|
25 end
|
Asa@89
|
26
|
Asa@89
|
27 return addon_options
|
Asa@89
|
28 end
|
Asa@89
|
29
|
Asa@89
|
30 local function getSelected()
|
Asa@89
|
31 -- just making sure ItemAuditor.db.profile.auction_addon is set if there is only one addon
|
Asa@89
|
32 if not addon_options then
|
Asa@89
|
33 getAddons()
|
Asa@89
|
34 end
|
Asa@89
|
35
|
Asa@89
|
36 return ItemAuditor.db.profile.auction_addon
|
Asa@89
|
37 end
|
Asa@89
|
38
|
Asa@90
|
39 local function setAddon(info, value)
|
Asa@90
|
40 ItemAuditor.db.profile.auction_addon = value
|
Asa@90
|
41 end
|
Asa@90
|
42
|
Asa@90
|
43 local function getPricingMethods()
|
Asa@90
|
44 if ItemAuditor.db.profile.auction_addon == 'other' then
|
Asa@90
|
45 return {
|
Asa@90
|
46 low = 'Lowest Price',
|
Asa@90
|
47 }
|
Asa@90
|
48 else
|
Asa@90
|
49 return {
|
Asa@90
|
50 low = 'Lowest Price',
|
Asa@90
|
51 market = 'Market Price',
|
Asa@90
|
52 }
|
Asa@90
|
53 end
|
Asa@90
|
54 end
|
Asa@90
|
55
|
Asa@89
|
56 ItemAuditor.Options.args.auction_house = {
|
Asa@89
|
57 name = "Auction House",
|
Asa@89
|
58 type = 'group',
|
Asa@89
|
59 args = {
|
Asa@89
|
60 ah_addon = {
|
Asa@89
|
61 type = "select",
|
Asa@89
|
62 name = "Addon",
|
Asa@89
|
63 desc = "",
|
Asa@89
|
64 values = getAddons,
|
Asa@89
|
65 get = getSelected,
|
Asa@90
|
66 set = setAddon,
|
Asa@89
|
67 order = 0,
|
Asa@89
|
68 },
|
Asa@90
|
69 pricingMethod = {
|
Asa@90
|
70 type = "select",
|
Asa@90
|
71 name = "Pricing Method",
|
Asa@90
|
72 desc = "",
|
Asa@90
|
73 values = getPricingMethods,
|
Asa@90
|
74 get = function() return ItemAuditor.db.profile.pricing_method end,
|
Asa@90
|
75 set = function(info, value) ItemAuditor.db.profile.pricing_method = value end,
|
Asa@90
|
76 order = 1,
|
Asa@90
|
77 }
|
Asa@89
|
78 },
|
Asa@89
|
79 }
|
Asa@89
|
80
|
Asa@89
|
81 function AuctionHouse:GetAuctionPrice(itemLink)
|
Asa@89
|
82 local link = select(2, GetItemInfo(itemLink))
|
Asa@89
|
83 assert(link, 'Invalid item link: '..itemLink)
|
Asa@89
|
84 local addon = getSelected()
|
Asa@90
|
85 local prices = ItemAuditor.db.profile.pricing_method or 'low'
|
Asa@89
|
86 if GetAuctionBuyout ~= nil and addon == 'other' then
|
Asa@89
|
87 return GetAuctionBuyout(link)
|
Asa@89
|
88 elseif AucAdvanced and AucAdvanced.Version and addon == 'auctioneer' then
|
Asa@90
|
89 if prices == 'low' then
|
Asa@90
|
90 local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(link)
|
Asa@90
|
91 return lowBuy
|
Asa@90
|
92 else
|
Asa@90
|
93 return AucAdvanced.API.GetMarketValue(link)
|
Asa@90
|
94 end
|
Asa@89
|
95 end
|
Asa@89
|
96 return nil
|
Asa@89
|
97 end |