Asa@89: local ItemAuditor = select(2, ...) Asa@89: local AuctionHouse = ItemAuditor:NewModule("AuctionHouse") Asa@89: Asa@93: local Utils = ItemAuditor:GetModule("Utils") Asa@93: Asa@89: local addon_options Asa@89: local function getAddons() Asa@89: -- this will ensure that the addons are only scanned once per session. Asa@89: if not addon_options then Asa@89: addon_options = {} Asa@89: local total = 0 Asa@89: local lastKey Asa@89: if AucAdvanced and AucAdvanced.Version then Asa@89: addon_options['auctioneer'] = 'Auctioneer' Asa@89: total = total + 1 Asa@89: lastKey = 'auctioneer' Asa@89: end Asa@89: if GetAuctionBuyout ~= nil then Asa@89: addon_options['other'] = 'Other (GetAuctionBuyout compatibile)' Asa@89: total = total + 1 Asa@89: lastKey = 'other' Asa@89: end Asa@89: Asa@89: if total == 1 or not ItemAuditor.db.profile.auction_addon then Asa@89: ItemAuditor.db.profile.auction_addon = lastKey Asa@89: end Asa@89: end Asa@89: Asa@89: return addon_options Asa@89: end Asa@89: Asa@89: local function getSelected() Asa@89: -- just making sure ItemAuditor.db.profile.auction_addon is set if there is only one addon Asa@89: if not addon_options then Asa@89: getAddons() Asa@89: end Asa@89: Asa@89: return ItemAuditor.db.profile.auction_addon Asa@89: end Asa@89: Asa@90: local function setAddon(info, value) Asa@90: ItemAuditor.db.profile.auction_addon = value Asa@90: end Asa@90: Asa@90: local function getPricingMethods() Asa@90: if ItemAuditor.db.profile.auction_addon == 'other' then Asa@90: return { Asa@90: low = 'Lowest Price', Asa@90: } Asa@90: else Asa@90: return { Asa@90: low = 'Lowest Price', Asa@90: market = 'Market Price', Asa@90: } Asa@90: end Asa@90: end Asa@90: Asa@89: ItemAuditor.Options.args.auction_house = { Asa@89: name = "Auction House", Asa@89: type = 'group', Asa@89: args = { Asa@89: ah_addon = { Asa@89: type = "select", Asa@89: name = "Addon", Asa@89: desc = "", Asa@89: values = getAddons, Asa@89: get = getSelected, Asa@90: set = setAddon, Asa@89: order = 0, Asa@89: }, Asa@90: pricingMethod = { Asa@90: type = "select", Asa@90: name = "Pricing Method", Asa@90: desc = "", Asa@90: values = getPricingMethods, Asa@90: get = function() return ItemAuditor.db.profile.pricing_method end, Asa@90: set = function(info, value) ItemAuditor.db.profile.pricing_method = value end, Asa@90: order = 1, Asa@90: } Asa@93: Asa@89: }, Asa@89: } Asa@89: Asa@93: local function clearSnatch() Asa@93: ItemAuditor:Print('clearing snatch') Asa@93: local Snatch = AucAdvanced.Modules.Util.SearchUI.Searchers.Snatch Asa@93: local snatchList = Snatch.Private.snatchList Asa@93: Asa@93: for itemLink in pairs(snatchList) do Asa@93: local link = select(2, GetItemInfo('item:'..itemLink)) Asa@93: Snatch.RemoveSnatch(link) Asa@93: end Asa@93: end Asa@93: Asa@93: function AuctionHouse.Snatch() Asa@93: if not AucAdvanced or not AucAdvanced.Version then Asa@93: ItemAuditor:Print("The snatch command requires Auctioneer.") Asa@93: return Asa@93: end Asa@93: Asa@93: local Snatch = AucAdvanced.Modules.Util.SearchUI.Searchers.Snatch Asa@93: if not Snatch.Private.frame then Asa@93: ItemAuditor:Print("You must visit the Auction House before you can update Auctioneer's snatch list.") Asa@93: return Asa@93: end Asa@93: clearSnatch() Asa@93: Asa@94: local snatchList = {} Asa@93: local function Export(data) Asa@127: if data.haveMaterials < data.queue then Asa@94: for id, reagent in pairs(data.reagents) do Asa@94: if reagent.need > 0 and not snatchList[reagent.link] then Asa@94: snatchList[reagent.link] = true Asa@94: ItemAuditor:Print("Adding %s for %s", reagent.link, Utils.FormatMoney(reagent.price)) Asa@94: Snatch.AddSnatch(reagent.link, reagent.price) Asa@94: end Asa@94: end Asa@93: end Asa@93: end Asa@93: ItemAuditor:UpdateCraftingTable() Asa@93: ItemAuditor:GetModule("Crafting").Export(Export) Asa@93: end Asa@93: Asa@93: ItemAuditor.Options.args.snatch = { Asa@93: type = "execute", Asa@93: handler = AuctionHouse, Asa@93: name = "snatch", Asa@93: desc = "Replace Auctioner's snatch list with all the reagents you need for crafting.", Asa@93: func = "Snatch", Asa@93: guiHidden = true, Asa@93: } Asa@93: Asa@89: function AuctionHouse:GetAuctionPrice(itemLink) Asa@89: local link = select(2, GetItemInfo(itemLink)) Asa@89: assert(link, 'Invalid item link: '..itemLink) Asa@89: local addon = getSelected() Asa@90: local prices = ItemAuditor.db.profile.pricing_method or 'low' Asa@89: if GetAuctionBuyout ~= nil and addon == 'other' then Asa@89: return GetAuctionBuyout(link) Asa@89: elseif AucAdvanced and AucAdvanced.Version and addon == 'auctioneer' then Asa@90: if prices == 'low' then Asa@90: local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(link) Asa@90: return lowBuy Asa@90: else Asa@90: return AucAdvanced.API.GetMarketValue(link) Asa@90: end Asa@89: end Asa@89: return nil Asa@89: end