918
edits
(Limit height of itemrow to 32px) |
(Fix styling issues with lists) |
||
(12 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 181: | Line 204: | ||
local imgCell = mw.html.create('td') | local imgCell = mw.html.create('td') | ||
:wikitext(getItemIcon(i.name)) | :wikitext(getItemIcon(i.name)) | ||
:css('height', ' | :css('height', '28px') | ||
:done() | :done() | ||
Line 193: | Line 216: | ||
qtyCell:node(getErrorDiv("Unable to parse quantity for item: " .. i.name)) | qtyCell:node(getErrorDiv("Unable to parse quantity for item: " .. i.name)) | ||
else | else | ||
local qty = i.amount | local qty = num.autoround(i.amount) | ||
qtyCell:wikitext(num.formatnum(qty)) | qtyCell:wikitext(num.formatnum(qty)) | ||
end | end | ||
Line 203: | Line 226: | ||
else | else | ||
local tot = i.value * (i.amount or 0) | local tot = i.value * (i.amount or 0) | ||
valCell:wikitext(icons.GP(num.round2(tot))) | valCell | ||
:css('text-align','right') | |||
:wikitext(icons.GP(num.round2(tot))) | |||
:attr("data-sort-value", tot) | |||
end | end | ||
valCell:done() | valCell:done() | ||
Line 255: | 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 264: | Line 292: | ||
:tag("td") | :tag("td") | ||
:attr("colspan", 2) | :attr("colspan", 2) | ||
:css('font-weight', 'bold') | |||
: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 278: | 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 288: | 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 305: | 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 384: | 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