comparison Modules/Crafting.lua @ 72:8e9beb8a0330

Added options to enable or disable crafting deciders.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 28 Jul 2010 23:17:30 -0700
parents 3930518cb8d9
children 71de6e86a1a4
comparison
equal deleted inserted replaced
71:aaf9a155995b 72:8e9beb8a0330
63 name = "Crafting Threshold", 63 name = "Crafting Threshold",
64 desc = "Don't create items that will make less than this amount of profit", 64 desc = "Don't create items that will make less than this amount of profit",
65 values = craftingThresholdsDisplay, 65 values = craftingThresholdsDisplay,
66 get = function() return ItemAuditor.db.char.crafting_threshold end, 66 get = function() return ItemAuditor.db.char.crafting_threshold end,
67 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end, 67 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
68 order = 11, 68 order = 0,
69 }, 69 },
70 queue_destination = { 70 queue_destination = {
71 type = "select", 71 type = "select",
72 name = "Queue Destination", 72 name = "Queue Destination",
73 desc = "Select the addon who's queue you would like ItemAuditor to post to.", 73 desc = "Select the addon who's queue you would like ItemAuditor to post to.",
74 values = displayCraftingDestinations, 74 values = displayCraftingDestinations,
75 get = function() return select(2, Crafting.GetQueueDestination()) end, 75 get = function() return select(2, Crafting.GetQueueDestination()) end,
76 set = function(info, value) ItemAuditor.db.profile.queue_destination = value end, 76 set = function(info, value) ItemAuditor.db.profile.queue_destination = value end,
77 order = 11, 77 order = 1,
78 }, 78 },
79 deciders = {
80 type="header",
81 name="Crafting Deciders",
82 order = 10,
83 },
84
79 }, 85 },
80 } 86 }
81 87
82 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 88 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
83 if fShow == true then 89 if fShow == true then
259 self:CreateFrame('tab_crafting') 265 self:CreateFrame('tab_crafting')
260 end 266 end
261 267
262 local craftingDeciders = {} 268 local craftingDeciders = {}
263 269
264 function Crafting.RegisterCraftingDecider(name, decider) 270 function Crafting.RegisterCraftingDecider(name, decider, options)
265 craftingDeciders[name] = decider 271 craftingDeciders[name] = decider
272
273 ItemAuditor.Options.args.crafting_options.args['chk'..name] = {
274 type = "toggle",
275 name = "Enable "..name,
276 get = function() return not ItemAuditor.db.profile.disabled_deciders[name] end,
277 set = function(info, value) ItemAuditor.db.profile.disabled_deciders[name] = not value end,
278 order = 11,
279 }
280
281 if options then
282 ItemAuditor.Options.args.crafting_options.args['decider_'..name] = {
283 handler = {},
284 name = name,
285 type = 'group',
286 args = options,
287 }
288 end
266 end 289 end
267 290
268 local lastWinnder = "" 291 local lastWinnder = ""
269 local function Decide(data) 292 local function Decide(data)
270 local newDecision = 0 293 local newDecision = 0
271 for name, decider in pairs(craftingDeciders) do 294 for name, decider in pairs(craftingDeciders) do
272 if name ~= lastWinner then 295 if not ItemAuditor.db.profile.disabled_deciders[name] and name ~= lastWinner then
273 newDecision = decider(data) 296 newDecision = decider(data)
274 if newDecision > data.queue then 297 if newDecision > data.queue then
275 data.queue = newDecision 298 data.queue = newDecision
276 lastWinner = name 299 lastWinner = name
277 return Decide(data) 300 return Decide(data)
292 if data.profit > 0 and data.profit > ItemAuditor:GetCraftingThreshold() then 315 if data.profit > 0 and data.profit > ItemAuditor:GetCraftingThreshold() then
293 return 1 316 return 1
294 end 317 end
295 return -1 318 return -1
296 end 319 end
320
297 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable) 321 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable)
298 322
299 local function tableFilter(self, row, ...) 323 local function tableFilter(self, row, ...)
300 -- column 5 is how many should be crafted 324 -- column 5 is how many should be crafted
301 return row[5] > 0 325 return row[5] > 0