Mercurial > wow > itemauditor
diff Modules/Events.lua @ 46:5e981c1df761 ticket7
Changed the way items are converted to be weighted by AH value. there are no options yet.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Tue, 20 Jul 2010 00:12:44 -0700 |
parents | 1ff3b83b104c |
children | 9ff6a3b02332 |
line wrap: on
line diff
--- a/Modules/Events.lua Tue Jul 20 00:09:54 2010 -0700 +++ b/Modules/Events.lua Tue Jul 20 00:12:44 2010 -0700 @@ -224,6 +224,41 @@ self.lastInventory = self:GetCurrentInventory() end +local function distributeValueByAHValue(self, totalValue, targetItems) + + local weights = {} + local totalWeight = 0 + for link, change in pairs(targetItems) do + --[[ + If something has never been seen on the AH, it must not be very valuable. + I'm using 1c so it doesn't have much weight and I can't get a devided by zero error. + The only time I know that this is a problem is when crafting a BOP item, and it + is always crafted 1 at a time, so a weight of 1 will work. + ]] + local ap = (addon:GetAuctionPrice(link) or 1) + totalWeight = totalWeight + ap + weights[link] = ap + end + + local valuePerPoint = totalValue / totalWeight + + for link, change in pairs(targetItems) do + self:SaveValue(link, weights[link] * valuePerPoint, change) + end +end + +local function distributeValue(self, totalValue, targetItems) + if true then + return distributeValueByAHValue(self, totalValue, targetItems) + else + local valuePerItem = totalChange / positiveCount + + for link, change in pairs(targetItems) do + self:SaveValue(link, valuePerItem * change, change) + end + end +end + function addon:UpdateAudit() -- self:Debug("UpdateAudit " .. event) local currentInventory = self:GetCurrentInventory() @@ -266,11 +301,7 @@ totalChange = totalChange + (itemCost * abs(change)) end - local valuePerItem = totalChange / positiveCount - - for link, change in pairs(positive) do - self:SaveValue(link, valuePerItem * change, change) - end + distributeValue(self, totalChange, positive) else self:Debug("No match in UpdateAudit.") end