# HG changeset patch # User Asa Ayers # Date 1279700550 25200 # Node ID 84bfb54691891a5d8d60f32787023b554d25cfab # Parent 508110e7c8eeadb5088eef689213dc175bcc9227# Parent c0166af6e49a8be1883913324ad7fa64306fb6e7 Merged and closed ticket7 diff -r 508110e7c8ee -r 84bfb5469189 CHANGELOG.txt --- a/CHANGELOG.txt Tue Jul 20 00:20:15 2010 -0700 +++ b/CHANGELOG.txt Wed Jul 21 01:22:30 2010 -0700 @@ -1,4 +1,8 @@ -2010-07-20 Asa Ayers +2010-07-21 Asa Ayers + +- Fixed the way prices were being calculated as items were being created/destroyed/converted/crafted. see http://www.wowace.com/addons/itemauditor/tickets/7-create-options-for-how-to-distribute-value-when-creating/ + +2010-07-18 Asa Ayers - Implemented COD mail (Ticket #1) and updated the way postage was counted so that if you mail multiple items at once, they will all have the postage counted. I also removed the 30c for postage from how QA thresholds are calculated now that they will be counted every time. - Added a dialog to allow the user to send COD mail without a tracking number. diff -r 508110e7c8ee -r 84bfb5469189 Modules/DisplayInvested.lua --- a/Modules/DisplayInvested.lua Tue Jul 20 00:20:15 2010 -0700 +++ b/Modules/DisplayInvested.lua Wed Jul 21 01:22:30 2010 -0700 @@ -98,7 +98,7 @@ ItemAuditor:SaveValue(link, newValue-investedTotal, 0) end - StaticPopup_Show ("ItemAuditor_NewPrice", link, 'two'); + StaticPopup_Show ("ItemAuditor_NewPrice"); end local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) diff -r 508110e7c8ee -r 84bfb5469189 Modules/Events.lua --- a/Modules/Events.lua Tue Jul 20 00:20:15 2010 -0700 +++ b/Modules/Events.lua Wed Jul 21 01:22:30 2010 -0700 @@ -224,6 +224,29 @@ self.lastInventory = self:GetCurrentInventory() end +local function distributeValue(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 + function addon:UpdateAudit() -- self:Debug("UpdateAudit " .. event) local currentInventory = self:GetCurrentInventory() @@ -266,11 +289,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