918
edits
m (Use autoround instead for rounding) |
(Fix styling issues with lists) |
||
(6 intermediate revisions by the same user not shown) | |||
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 140: | Line 162: | ||
local pSkill = formatSkillName(args[skillPrefix]) | local pSkill = formatSkillName(args[skillPrefix]) | ||
local pExp = args[skillPrefix .. AmountSuffix] | local pExp = tonumber(args[skillPrefix .. AmountSuffix]) | ||
table.insert(skills, { | table.insert(skills, { | ||
prmNumber = i, | prmNumber = i, | ||
Line 152: | Line 170: | ||
end | end | ||
-- Return nil if there is no experience earned. | |||
-- Lets the parent table know to enter 'None' instead | |||
if #skills == 0 then | |||
return nil | |||
end | |||
return skills | return skills | ||
end | end | ||
Line 206: | Line 229: | ||
:css('text-align','right') | :css('text-align','right') | ||
:wikitext(icons.GP(num.round2(tot))) | :wikitext(icons.GP(num.round2(tot))) | ||
:attr("data-sort-value", tot) | |||
end | end | ||
valCell:done() | valCell:done() | ||
Line 257: | Line 281: | ||
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 269: | Line 295: | ||
: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) | |||
:wikitext(parseProfitMargin(minProfit, maxProfit)) | |||
:tag("tr") | :tag("tr") | ||
:tag("th") | :tag("th") | ||
Line 281: | Line 311: | ||
:tag("tr") | :tag("tr") | ||
:tag("td") | :tag("td") | ||
:addClass('mmg-no-list') | |||
:newline() | |||
:wikitext(paramtest.default_to(args['skills'], 'None')) | |||
:tag("td") | :tag("td") | ||
:addClass('mmg-no-list') | |||
:newline() | |||
:wikitext(paramtest.default_to(args['other'], 'None')) | |||
:tag('tr') | :tag('tr') | ||
:tag('th') | :tag('th') | ||
Line 291: | Line 325: | ||
:tag('tr') | :tag('tr') | ||
:tag('td') | :tag('td') | ||
:addClass('mmg-no-list') | |||
:newline() | |||
:wikitext(paramtest.default_to(args['items'], 'None')) | :wikitext(paramtest.default_to(args['items'], 'None')) | ||
:tag('td') | :tag('td') | ||
:addClass('mmg-no-list') | |||
:newline() | |||
:wikitext(paramtest.default_to(args['recommended'], 'None')) | :wikitext(paramtest.default_to(args['recommended'], 'None')) | ||
:tag("tr") | :tag("tr") | ||
Line 308: | Line 346: | ||
html:wikitext(icons.GP(num.round2(args['profit']))) | html:wikitext(icons.GP(num.round2(args['profit']))) | ||
else | else | ||
html:wikitext(icons.GP(num.round2( | html:wikitext(icons.GP(num.round2(maxProfit))) | ||
end | end | ||
html = html | html = html | ||
Line 387: | Line 425: | ||
end | end | ||
function p.test() | |||
local args = { | |||
guideName ='Mining Pure Crystal', | |||
category ='Non-combat', | |||
dlc ='aod, toth', | |||
skills =[[ | |||
*{{SkillReq|Mining|85}} | |||
*{{SkillReq|Herblore|53}}]], | |||
items =[=[ | |||
*{{ItemIcon|Mining Gloves}} | |||
*{{ItemIcon|Perfect Swing Potion IV}}]=], | |||
other =[=[ | |||
*{{ItemIcon|Pure Crystal|notext=true}}{{Icon|Mastery|notext=true}} Level 99 | |||
*{{UpgradeIcon|Dragon Pickaxe}} | |||
*[[Mining#Mastery Pool Checkpoints|95% Mining Mastery Pool Checkpoint]]]=], | |||
recommended =[=[ | |||
[[Money_Making/Mining_Pure_Crystal#Improves_GP_Rate|Bonusses that improve profit]]]=], | |||
} | |||
local t = p._buildMMGTable(args) | |||
mw.log(t) | |||
end | |||
-- function p.test() | -- function p.test() |
edits