Anonymous

Module:MoneyMakingGuide: Difference between revisions

From Melvor Idle
Add profit range row
(Add sorting for the item GP column)
(Add profit range row)
Line 6: Line 6:
local itemdb = require('Module:Items')
local itemdb = require('Module:Items')
local icons = require('Module:Icons')
local icons = require('Module:Icons')
local StringBuilder = require('Module:StringBuilder')


-- Constants
-- Constants
Line 75: Line 76:
return icon .. ' ' .. expValue
return icon .. ' ' .. expValue
end
local function parseProfitMargin(minProfit, maxProfit)
local min = tonumber(minProfit)
local max = tonumber(maxProfit)
if max == nil then
error("maxProfit is not a valid number.")
end
local sb = StringBuilder:new()
if min then
sb  :append(icons.GP(num.round2(min / 1000)))
:append('k/hr Minimum ~ ')
end
sb  :append(icons.GP(num.round2(max / 1000)))
:append('k/hr Maximum')
return sb:toString()
end
end


Line 258: Line 280:
local pOutputs = parseItemInOut(args, 'output')
local pOutputs = parseItemInOut(args, 'output')
local dlcIcons = p.getDLCIcons(args['dlc'], ' ')
local dlcIcons = p.getDLCIcons(args['dlc'], ' ')
local minProfit = args['minimumProfit']
local maxProfit = pOutputs.TotalValue - pInputs.TotalValue


local tbl = mw.html.create()
local tbl = mw.html.create()
Line 270: Line 294:
             :wikitext(table.concat(dlcIcons) .. ' ')
             :wikitext(table.concat(dlcIcons) .. ' ')
             :wikitext(args['guideName'] or '{{{guideName}}}')
             :wikitext(args['guideName'] or '{{{guideName}}}')
    :tag("tr")
        :tag("td")
            :attr("colspan", 2)
            :css('font-weight', 'bold')
            :wikitext(parseProfitMargin(minProfit, maxProfit))
     :tag("tr")
     :tag("tr")
         :tag("th")
         :tag("th")
Line 309: Line 338:
         html:wikitext(icons.GP(num.round2(args['profit'])))
         html:wikitext(icons.GP(num.round2(args['profit'])))
         else
         else
         html:wikitext(icons.GP(num.round2(pOutputs.TotalValue - pInputs.TotalValue)))
         html:wikitext(icons.GP(num.round2(maxProfit)))
         end
         end
         html = html
         html = html
Line 387: Line 416:
error("Call a specific function rather than main.")
error("Call a specific function rather than main.")
end
end


-- function p.test()
-- function p.test()
2,875

edits