Skip to content

Commit

Permalink
Merge pull request #354 from Artur91425/milling_wotlk
Browse files Browse the repository at this point in the history
add support for milling profession
  • Loading branch information
shirsig authored Dec 21, 2023
2 parents 0a309ea + 69e04b6 commit af878d6
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aux-addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function event.AUX_LOADED()
disenchant_distribution = false,
prospecting_value = false,
prospecting_distribution = false,
milling_value = false,
milling_distribution = false,
money_icons = false
}
})
Expand Down
1 change: 1 addition & 0 deletions aux-addon.toc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ util\info.lua
core\history.lua
core\disenchant.lua
core\prospecting.lua
core\milling.lua
util\filter.lua
util\completion.lua
core\slash.lua
Expand Down
116 changes: 116 additions & 0 deletions core/milling.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
select(2, ...) 'aux.core.milling'

local aux = require 'aux'
local history = require 'aux.core.history'

function M.value(item_id)
local expectation
for _, event in pairs(distribution(item_id)) do
local value = history.value(event.item_id .. ':' .. 0)
expectation = (expectation or 0) + event.probability * (event.min_quantity + event.max_quantity) / 2 * (value or 0)
end
return expectation
end

function M.distribution(item_id)
if item_id == 2447 or item_id == 765 or item_id == 2449 then
return {
{ item_id = 39151, min_quantity = 2, max_quantity = 4, probability = 1 },
}
elseif item_id == 785 then
return {
{ item_id = 39334, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43103, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 2450 or item_id == 2452 then
return {
{ item_id = 39334, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43103, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 2453 or item_id == 3820 then
return {
{ item_id = 39334, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43103, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 3355 or item_id == 3369 then
return {
{ item_id = 39338, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43104, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 3356 or item_id == 3357 then
return {
{ item_id = 39338, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43104, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 3818 or item_id == 3821 then
return {
{ item_id = 39339, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43105, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 3358 or item_id == 3819 then
return {
{ item_id = 39339, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43105, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 4625 or item_id == 8831 or item_id == 8836 or item_id == 8838 then
return {
{ item_id = 39340, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43106, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 8839 or item_id == 8845 or item_id == 8846 then
return {
{ item_id = 39340, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43106, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 13463 or item_id == 13464 then
return {
{ item_id = 39341, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43107, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 13465 then
return {
{ item_id = 39341, min_quantity = 2, max_quantity = 4, probability = 1 },
}
elseif item_id == 13466 or item_id == 13467 then
return {
{ item_id = 39341, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43107, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 22785 then
return {
{ item_id = 39342, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43108, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 22786 or item_id == 22787 or item_id == 22789 then
return {
{ item_id = 39342, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43108, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 22790 or item_id == 22791 or item_id == 22792 or item_id == 22793 then
return {
{ item_id = 39342, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43108, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
elseif item_id == 36901 or item_id == 36907 or item_id == 37921 or item_id == 39970 then
return {
{ item_id = 39343, min_quantity = 2, max_quantity = 3, probability = 1 },
{ item_id = 43109, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 36903 then
return {
{ item_id = 39343, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43109, min_quantity = 1, max_quantity = 4, probability = 0.5 },
}
elseif item_id == 36904 then
return {
{ item_id = 39343, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43109, min_quantity = 1, max_quantity = 3, probability = 0.25 },
}
elseif item_id == 36905 or item_id == 36906 then
return {
{ item_id = 39343, min_quantity = 2, max_quantity = 4, probability = 1 },
{ item_id = 43109, min_quantity = 1, max_quantity = 3, probability = 0.5 },
}
end
return {}
end
8 changes: 8 additions & 0 deletions core/slash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function SlashCmdList.AUX(command)
elseif arguments[1] == 'tooltip' and arguments[2] == 'prospecting' and arguments[3] == 'distribution' then
tooltip_settings.prospecting_distribution = not tooltip_settings.prospecting_distribution
aux.print('tooltip prospecting distribution ' .. status(tooltip_settings.prospecting_distribution))
elseif arguments[1] == 'tooltip' and arguments[2] == 'milling' and arguments[3] == 'value' then
tooltip_settings.milling_value = not tooltip_settings.milling_value
aux.print('tooltip milling value ' .. status(tooltip_settings.milling_value))
elseif arguments[1] == 'tooltip' and arguments[2] == 'milling' and arguments[3] == 'distribution' then
tooltip_settings.milling_distribution = not tooltip_settings.milling_distribution
aux.print('tooltip milling distribution ' .. status(tooltip_settings.milling_distribution))
elseif arguments[1] == 'tooltip' and arguments[2] == 'money' and arguments[3] == 'icons' then
tooltip_settings.money_icons = not tooltip_settings.money_icons
aux.print('tooltip money icons ' .. status(tooltip_settings.money_icons))
Expand Down Expand Up @@ -89,6 +95,8 @@ function SlashCmdList.AUX(command)
aux.print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']')
aux.print('- tooltip prospecting value [' .. status(tooltip_settings.prospecting_value) .. ']')
aux.print('- tooltip prospecting distribution [' .. status(tooltip_settings.prospecting_distribution) .. ']')
aux.print('- tooltip milling value [' .. status(tooltip_settings.milling_value) .. ']')
aux.print('- tooltip milling distribution [' .. status(tooltip_settings.milling_distribution) .. ']')
aux.print('- tooltip money icons [' .. status(tooltip_settings.money_icons) .. ']')
aux.print('- clear item cache')
aux.print('- clear post')
Expand Down
19 changes: 19 additions & 0 deletions core/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local info = require 'aux.util.info'
local money = require 'aux.util.money'
local disenchant = require 'aux.core.disenchant'
local prospecting = require 'aux.core.prospecting'
local milling = require 'aux.core.milling'
local history = require 'aux.core.history'
local gui = require 'aux.gui'

Expand Down Expand Up @@ -105,6 +106,24 @@ function extend_tooltip(tooltip, link, quantity)
end
end
end
local distribution = milling.distribution(item_id)
if #distribution > 0 then
if settings.milling_distribution then
tooltip:AddLine('Milling into:', aux.color.tooltip.milling.distribution())
sort(distribution, function(a,b) return a.probability > b.probability end)
for _, event in ipairs(distribution) do
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), aux.color.tooltip.milling.distribution())
end
end
if settings.milling_value then
local milling_value = milling.value(item_id)
if settings.money_icons then
tooltip:AddLine('Milling: ' .. (milling_value and GetCoinTextureString(milling_value) or UNKNOWN), aux.color.tooltip.milling.value())
else
tooltip:AddLine('Milling: ' .. (milling_value and money.to_string2(milling_value) or UNKNOWN), aux.color.tooltip.milling.value())
end
end
end
if settings.merchant_buy then
local price, limited = info.merchant_buy_info(item_id)
if price then
Expand Down

0 comments on commit af878d6

Please sign in to comment.