Module:GameSkills: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary |
No edit summary |
||
| Line 892: | Line 892: | ||
local req = rec.Requirements or {} | local req = rec.Requirements or {} | ||
local | local reqSkillsRaw = (type(req["Required Skills"]) == "table") and req["Required Skills"] or {} | ||
local | local reqWeaponsRaw = (type(req["Required Weapons"]) == "table") and req["Required Weapons"] or {} | ||
local | local reqStancesRaw = (type(req["Required Stances"]) == "table") and req["Required Stances"] or {} | ||
local reqSkills = {} | |||
for _, rs in ipairs(reqSkillsRaw) do | |||
if type(rs) == "table" then | |||
local nameReq = rs["Skill External Name"] or rs["Skill Internal Name"] or "Unknown" | |||
local lvlReq = rs["Required Level"] | |||
if lvlReq then | |||
table.insert(reqSkills, string.format("%s (Lv.%s)", mw.text.nowiki(nameReq), mw.text.nowiki(tostring(lvlReq)))) | |||
else | |||
table.insert(reqSkills, mw.text.nowiki(nameReq)) | |||
end | |||
end | |||
end | |||
local reqWeapons = {} | |||
for _, w in ipairs(reqWeaponsRaw) do | |||
local wn = trim(w) | |||
if wn then table.insert(reqWeapons, mw.text.nowiki(wn)) end | |||
end | |||
local reqStances = {} | |||
for _, s in ipairs(reqStancesRaw) do | |||
local sn = trim(s) | |||
if sn then table.insert(reqStances, mw.text.nowiki(sn)) end | |||
end | |||
local hasNotes = (#notesList > 0) | local hasNotes = (#notesList > 0) | ||
| Line 913: | Line 938: | ||
textBox:addClass("sv-herobar-text") | textBox:addClass("sv-herobar-text") | ||
local | local notesBtn | ||
if hasNotes then | |||
notesBtn = mw.html.create("span") | |||
if hasNotes | |||
notesBtn:addClass("sv-tip-btn sv-tip-btn--notes") | notesBtn:addClass("sv-tip-btn sv-tip-btn--notes") | ||
notesBtn:attr("role", "button") | notesBtn:attr("role", "button") | ||
| Line 925: | Line 948: | ||
notesBtn:attr("aria-expanded", "false") | notesBtn:attr("aria-expanded", "false") | ||
notesBtn:tag("span"):addClass("sv-ico sv-ico--info"):attr("aria-hidden", "true"):wikitext("i") | notesBtn:tag("span"):addClass("sv-ico sv-ico--info"):attr("aria-hidden", "true"):wikitext("i") | ||
end | end | ||
if | if notesBtn and icon and icon ~= "" then | ||
iconBox:node(notesBtn) | |||
elseif notesBtn then | |||
textBox:node(notesBtn) | |||
end | end | ||
local titleBox = textBox:tag("div") | |||
titleBox:addClass("spiritvale-infobox-title") | |||
titleBox:wikitext(title) | titleBox:wikitext(title) | ||
| Line 968: | Line 986: | ||
reqContent:addClass("sv-tip-content") | reqContent:addClass("sv-tip-content") | ||
reqContent:attr("data-sv-tip-content", "req") | reqContent:attr("data-sv-tip-content", "req") | ||
if #reqSkills > 0 then | if #reqSkills > 0 then | ||
local section = reqContent:tag("div") | |||
section:addClass("sv-tip-section") | |||
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Skills") | |||
section:tag("div"):wikitext(table.concat(reqSkills, "<br />")) | |||
end | end | ||
if #reqWeapons > 0 then | if #reqWeapons > 0 then | ||
local section = reqContent:tag("div") | |||
section:addClass("sv-tip-section") | |||
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Weapons") | |||
section:tag("div"):wikitext(table.concat(reqWeapons, ", ")) | |||
end | end | ||
if #reqStances > 0 then | if #reqStances > 0 then | ||
local section = reqContent:tag("div") | |||
section:addClass("sv-tip-section") | |||
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Stances") | |||
section:tag("div"):wikitext(table.concat(reqStances, ", ")) | |||
end | end | ||
end | end | ||