comparison Core.lua @ 13:8c83d5f6e306

OPTIONS! QuickAuctions is now an optional dependency. I have also added some configuration options for it. If you have QA but don't want IA to update your thresholds you can shut off the integration. I have also added other options so you can select your faction or the neutral AH and it will update the tooltip.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Fri, 02 Jul 2010 21:39:24 -0700
parents 6a6296dd249f
children 44e70a3fdb19
comparison
equal deleted inserted replaced
12:6a6296dd249f 13:8c83d5f6e306
15 local GOLD = "|cFFFFD700" 15 local GOLD = "|cFFFFD700"
16 16
17 function addon:OnInitialize() 17 function addon:OnInitialize()
18 local DB_defaults = { 18 local DB_defaults = {
19 char = { 19 char = {
20 debug = false 20 debug = false,
21 ah = 1,
22 use_quick_auctions = false,
21 }, 23 },
22 factionrealm = { 24 factionrealm = {
23 item_account = {}, 25 item_account = {},
24 items = {}, 26 items = {},
25 AHCut = 0.05,
26 }, 27 },
27 } 28 }
28 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) 29 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true)
29 addonTable.db= self.db 30 addonTable.db= self.db
30 self.items = self.db.factionrealm.items 31 self.items = self.db.factionrealm.items
47 48
48 for link, data in pairs(self.db.factionrealm.items) do 49 for link, data in pairs(self.db.factionrealm.items) do
49 if self:GetItem(link).count == 0 or self:GetItem(link).invested == 0 then 50 if self:GetItem(link).count == 0 or self:GetItem(link).invested == 0 then
50 self:RemoveItem(link) 51 self:RemoveItem(link)
51 end 52 end
52 -- addon:UpdateQAThreshold(link)
53 end 53 end
54 54
55 self:RefreshQAGroups() 55 self:RefreshQAGroups()
56 end
57
58 function addon:RefreshQAGroups()
59 for groupName in pairs(QAAPI:GetGroups()) do
60 self:UpdateQAGroup(groupName)
61 end
62 end 56 end
63 57
64 function addon:GetCurrentInventory() 58 function addon:GetCurrentInventory()
65 local i = {} 59 local i = {}
66 local bagID 60 local bagID
252 if realLink ~= nil then 246 if realLink ~= nil then
253 addon:UpdateQAThreshold(realLink) 247 addon:UpdateQAThreshold(realLink)
254 end 248 end
255 end 249 end
256 250
257 function addon:UpdateQAThreshold(link)
258 _, link= GetItemInfo(link)
259
260 self:UpdateQAGroup(QAAPI:GetItemGroup(link))
261 end
262
263 function addon:UpdateQAGroup(groupName)
264 if groupName then
265 local threshold = 0
266
267 for link in pairs(QAAPI:GetItemsInGroup(groupName)) do
268 local _, itemCost= ItemAuditor:GetItemCost(link, 0)
269
270 threshold = max(threshold, itemCost)
271 end
272
273 if threshold == 0 then
274 threshold = 10000
275 end
276
277 -- add my minimum profit margin
278 threshold = threshold * 1.10
279
280 -- Adding the cost of mailing every item once.
281 threshold = threshold + 30
282
283 -- add AH Cut
284 local keep = 1 - self.db.factionrealm.AHCut
285 threshold = threshold/keep
286
287 QAAPI:SetGroupThreshold(groupName, ceil(threshold))
288 end
289 end
290 251
291 local defaultBagDelay = 0.2 252 local defaultBagDelay = 0.2
292 253
293 function addon:WatchBags(delay) 254 function addon:WatchBags(delay)
294 delay = delay or defaultBagDelay 255 delay = delay or defaultBagDelay