2,875
edits
mNo edit summary |
(Add experience rewards first version) |
||
Line 41: | Line 41: | ||
return name | return name | ||
end | |||
local function getSkillExpIcon(skillName, expValue) | |||
if expValue == nil then error("expValue is nil") end | |||
expValue = num.formatnum(expValue) | |||
return icons.Icon({ | |||
skillName, | |||
expValue, | |||
type='skill', | |||
nolink=true}) | |||
end | end | ||
Line 78: | Line 89: | ||
local totAmt = pAmount or 0 | local totAmt = pAmount or 0 | ||
totalValue = totalValue + (totVal * totAmt) | totalValue = totalValue + (totVal * totAmt) | ||
table.insert(items, { | table.insert(items, { | ||
prmNumber = i, | prmNumber = i, | ||
Line 130: | Line 141: | ||
-- @param items (table) A table containing skills and experience values. | -- @param items (table) A table containing skills and experience values. | ||
-- @return (string) The HTML representation of the item table section. | -- @return (string) The HTML representation of the item table section. | ||
local function | local function buildExpLayout(skills) | ||
local layoutLines = {} | |||
for _, skillLine in pairs(skills) do | |||
local hasInvalidExp = false | |||
local hasInvalidName = false | |||
local span = mw.html.create('div') | |||
if skillLine.exp == nil or skillLine.exp == 0 then | |||
hasInvalidExp = true | |||
end | |||
local skillIcon = getSkillExpIcon(skillLine.name, skillLine.exp or 0) | |||
if skillIcon == nil then | |||
hasInvalidName = true | |||
end | |||
if hasInvalidExp or hasInvalidName then | |||
else | |||
span:wikitext(skillIcon) | |||
end | |||
mw.log(skillIcon) | |||
mw.log(skillLine.name) | |||
table.insert(layoutLines, span) | |||
end | |||
end | end | ||
Line 190: | Line 227: | ||
:done() | :done() | ||
:tag("td") | :tag("td") | ||
if pSkills ~= nil then | |||
for _, v in ipairs(buildExpLayout(pSkills)) do | |||
html:node(v) | |||
end | |||
else | |||
html:wikitext("None") | |||
end | |||
html = html | |||
:tag("tr") | :tag("tr") | ||
:tag("th") | :tag("th") |
edits