comparison Modules/Events.lua @ 52:9c95158236d1

Fixed the way I was calculating the value when distributing cost among multiple items.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 21 Jul 2010 20:36:56 -0700
parents 9ff6a3b02332
children c6c98fc1be8e
comparison
equal deleted inserted replaced
51:84bfb5469189 52:9c95158236d1
233 If something has never been seen on the AH, it must not be very valuable. 233 If something has never been seen on the AH, it must not be very valuable.
234 I'm using 1c so it doesn't have much weight and I can't get a devided by zero error. 234 I'm using 1c so it doesn't have much weight and I can't get a devided by zero error.
235 The only time I know that this is a problem is when crafting a BOP item, and it 235 The only time I know that this is a problem is when crafting a BOP item, and it
236 is always crafted 1 at a time, so a weight of 1 will work. 236 is always crafted 1 at a time, so a weight of 1 will work.
237 ]] 237 ]]
238 local ap = (addon:GetAuctionPrice(link) or 1) 238 local ap = (addon:GetAuctionPrice(link) or 1) * change
239 totalWeight = totalWeight + ap 239 totalWeight = totalWeight + ap
240 weights[link] = ap 240 weights[link] = ap
241 end 241 end
242 242
243 local valuePerPoint = totalValue / totalWeight
244
245 for link, change in pairs(targetItems) do 243 for link, change in pairs(targetItems) do
246 self:SaveValue(link, weights[link] * valuePerPoint, change) 244 local value = totalValue * (weights[link]/totalWeight)
245 self:SaveValue(link, value, change)
247 end 246 end
248 end 247 end
249 248
250 function addon:UpdateAudit() 249 function addon:UpdateAudit()
251 -- self:Debug("UpdateAudit " .. event) 250 -- self:Debug("UpdateAudit " .. event)