changeset 89:54b917340283

Ticket 27 - Added the ability to select your preferred auction adodn if multiple are available.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 10 Aug 2010 23:25:48 -0700
parents 2112f71c4237
children fab2c4341602
files CHANGELOG.txt ItemAuditor.toc Modules/AuctionHouse.lua Modules/QuickAuctions.lua
diffstat 4 files changed, 71 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Tue Aug 10 23:19:18 2010 -0700
+++ b/CHANGELOG.txt	Tue Aug 10 23:25:48 2010 -0700
@@ -1,6 +1,7 @@
-2010-08-08  Asa Ayers  <Asa.Ayers@Gmail.com>
+2010-08-10  Asa Ayers  <Asa.Ayers@Gmail.com>
 
 - Changed the ArkInventory rule to consider items with no competition to be profitable.
+- Ticket 27 - Added the ability to select your preferred auction adodn if multiple are available.
 
 2010-08-08  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/ItemAuditor.toc	Tue Aug 10 23:19:18 2010 -0700
+++ b/ItemAuditor.toc	Tue Aug 10 23:25:48 2010 -0700
@@ -13,6 +13,7 @@
 
 
 Core.lua
+Modules\AuctionHouse.lua
 Modules\Utils.lua
 Modules\Options.lua
 Modules\Frames.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/AuctionHouse.lua	Tue Aug 10 23:25:48 2010 -0700
@@ -0,0 +1,66 @@
+local ItemAuditor = select(2, ...)
+local AuctionHouse = ItemAuditor:NewModule("AuctionHouse")
+
+local addon_options
+local function getAddons()
+	-- this will ensure that the addons are only scanned once per session.
+	if not addon_options then
+		addon_options = {}
+		local total = 0
+		local lastKey
+		if AucAdvanced and AucAdvanced.Version then
+			addon_options['auctioneer'] = 'Auctioneer'
+			total = total + 1
+			lastKey = 'auctioneer'
+		end
+		if GetAuctionBuyout ~= nil then
+			addon_options['other'] = 'Other (GetAuctionBuyout compatibile)'
+			total = total + 1
+			lastKey = 'other'
+		end
+
+		if total == 1 or not ItemAuditor.db.profile.auction_addon then
+			ItemAuditor.db.profile.auction_addon = lastKey
+		end
+	end
+
+	return addon_options
+end
+
+local function getSelected()
+	-- just making sure ItemAuditor.db.profile.auction_addon is set if there is only one addon
+	if not addon_options then
+		getAddons()
+	end
+
+	return ItemAuditor.db.profile.auction_addon
+end
+
+ItemAuditor.Options.args.auction_house = {
+	name = "Auction House",
+	type = 'group',
+	args = {
+		ah_addon = {
+			type = "select",
+			name = "Addon",
+			desc = "",
+			values = getAddons,
+			get = getSelected,
+			set = function(info, value) ItemAuditor.db.profile.auction_addon = value end,
+			order = 0,
+		},
+	},
+}
+
+function AuctionHouse:GetAuctionPrice(itemLink)
+	local link = select(2, GetItemInfo(itemLink))
+	assert(link, 'Invalid item link: '..itemLink)
+	local addon = getSelected()
+	if GetAuctionBuyout ~= nil and addon == 'other' then
+		return GetAuctionBuyout(link)
+	elseif AucAdvanced and AucAdvanced.Version and addon == 'auctioneer' then
+		local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(link)
+		return lowBuy
+	end
+	return nil
+end
\ No newline at end of file
--- a/Modules/QuickAuctions.lua	Tue Aug 10 23:19:18 2010 -0700
+++ b/Modules/QuickAuctions.lua	Tue Aug 10 23:25:48 2010 -0700
@@ -2,6 +2,7 @@
 local QuickAuctions= ItemAuditor:NewModule("QuickAuctions")
 local Crafting = ItemAuditor:GetModule("Crafting")
 local Utils = ItemAuditor:GetModule("Utils")
+local AuctionHouse = ItemAuditor:GetModule("AuctionHouse")
 
 local PT = LibStub("LibPeriodicTable-3.1")
 
@@ -166,15 +167,7 @@
 end
 
 function ItemAuditor:GetAuctionPrice(itemLink)
-	local link = select(2, GetItemInfo(itemLink))
-	assert(link, 'Invalid item link: '..itemLink)
-	if GetAuctionBuyout ~= nil then
-		return GetAuctionBuyout(link)
-	elseif AucAdvanced and AucAdvanced.Version then
-		local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(link)
-		return lowBuy
-	end
-	return nil
+	return AuctionHouse:GetAuctionPrice(itemLink)
 end
 
 function ItemAuditor:AddToQueue(skillId,skillIndex, toQueue)