2,875
edits
(Add formatting of user input) |
(Add table creation (still empty)) |
||
Line 5: | Line 5: | ||
local paramtest = require('Module:Shared/Paramtest') | local paramtest = require('Module:Shared/Paramtest') | ||
local itemdb = require('Module:Items') | local itemdb = require('Module:Items') | ||
local icons = require('Module:Icons') | |||
-- Constants | |||
local MaxDynamicArgs = 20 | local MaxDynamicArgs = 20 | ||
local AmountSuffix = 'amount' | local AmountSuffix = 'amount' | ||
local ValueSuffix = 'value' | local ValueSuffix = 'value' | ||
local SkillPrefix = 'skillExp' | local SkillPrefix = 'skillExp' | ||
local DLCParams = { | |||
aod = 'melvorAoD', | |||
toth = 'melvorTotH', | |||
ita = 'melvorItA' | |||
} | |||
function | --- Formats a wikicode string to be bold and red | ||
local | local function formatError(errorMessage) | ||
local eror = mw.html.create('span') | |||
:wikitext("'''") | |||
:css('color', 'red') | |||
:wikitext(errorMessage) | |||
:wikitext("'''") | |||
:done() | |||
return tostring(error) | |||
end | end | ||
Line 111: | Line 109: | ||
end | end | ||
--- Builds the section of the mmg table that shows the input and output items. | |||
-- @param items (table) A table containing items | |||
-- @return (string) The HTML representation of the item table section. | |||
local function buildItemTable(items) | |||
end | |||
--- Builds the section of the mmg table that shows the skill experience gained. | |||
-- @param items (table) A table containing skills and experience values. | |||
-- @return (string) The HTML representation of the item table section. | |||
local function buildExpTable(skills) | |||
end | |||
local function buildMMGTable(args) | |||
local pSkills = parseExp(args) | |||
local pInputs = parseItemInOut(args, 'input') | |||
local pOutputs = parseItemInOut(args, 'output') | |||
local dlcs = p.parseDLC(dlc) | |||
local html = mw.html.create() | |||
html:tag("table") | |||
:addClass("wikitable") | |||
:attr('style', 'width: 100%; text-align: center;') | |||
:tag("tr") | |||
:tag("td") | |||
:attr("colspan", 2) | |||
:wikitext("<ActivityName>") | |||
:tag("tr") | |||
:tag("th") | |||
:attr("colspan", 2) | |||
:wikitext("Requirements") | |||
:tag("tr") | |||
:tag("th") | |||
:wikitext("Skills") | |||
:tag("th") | |||
:wikitext("Recommended") | |||
:tag("tr") | |||
:tag("td") | |||
:wikitext("<SkillReqs>") | |||
:tag("td") | |||
:attr("rowspan", 3) | |||
:wikitext("<RecommendedReqs>") | |||
:tag("tr") | |||
:tag("th") | |||
:wikitext("Items") | |||
:tag("tr") | |||
:tag("td") | |||
:wikitext("<ItemReqs>") | |||
:tag("tr") | |||
:tag("th") | |||
:attr("colspan", 2) | |||
:wikitext("Results") | |||
:tag("tr") | |||
:tag("th") | |||
:wikitext("Profit") | |||
:tag("th") | |||
:wikitext("Experience gained") | |||
:tag("tr") | |||
:tag("td") | |||
:wikitext("<Total gp gained>") | |||
:done() | |||
:tag("td") | |||
:wikitext("<Exp values>") | |||
:tag("tr") | |||
:tag("th") | |||
:wikitext("Inputs") | |||
:done() | |||
:tag("th") | |||
:wikitext("Outputs") | |||
:tag("tr") | |||
:tag("td") | |||
:tag("td") | |||
--- | return tostring(html) | ||
end | |||
local | |||
--- Returns the parsed result of the dlcArgs. | |||
-- @param dlcArgs (string) A string separated by , listing the DLCs required for the MMG | |||
-- @return (table) A table listing which DLCs are required. | |||
function p.parseDLC(dlcArgs) | |||
if type(dlcArgs) ~= 'string' then return {} end | |||
return | local dlcs = {} | ||
for _, arg in pairs(shared.splitString(dlcArgs, ',')) do | |||
for dlc, ns in pairs(DLCParams) do | |||
if shared.compareString(dlc, arg, true) then | |||
table.insert(dlcs, ns) | |||
end | |||
end | |||
end | |||
return dlcs | |||
end | |||
function p.main(frame) | |||
local args = frame:getParent().args | |||
return p._main(args) | |||
end | |||
function p._main(args) | |||
return buildMMGTable(args) | |||
end | end | ||
edits