Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:GameSkills: Difference between revisions

From SpiritVale Wiki
No edit summary
No edit summary
Line 892: Line 892:


local req = rec.Requirements or {}
local req = rec.Requirements or {}
local reqSkills = (type(req["Required Skills"]) == "table") and req["Required Skills"] or {}
local reqSkillsRaw = (type(req["Required Skills"]) == "table") and req["Required Skills"] or {}
local reqWeapons = (type(req["Required Weapons"]) == "table") and req["Required Weapons"] or {}
local reqWeaponsRaw = (type(req["Required Weapons"]) == "table") and req["Required Weapons"] or {}
local reqStances = (type(req["Required Stances"]) == "table") and req["Required Stances"] or {}
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 titleBox = textBox:tag("div")
local notesBtn
titleBox:addClass("spiritvale-infobox-title")
if hasNotes then
 
notesBtn = mw.html.create("span")
if hasNotes and icon and icon ~= "" then
local notesBtn = mw.html.create("span")
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")
iconBox:node(notesBtn)
end
end


if hasNotes and (not icon or icon == "") then
if notesBtn and icon and icon ~= "" then
local notesBtn = mw.html.create("span")
iconBox:node(notesBtn)
notesBtn:addClass("sv-tip-btn sv-tip-btn--notes")
elseif notesBtn then
notesBtn:attr("role", "button")
textBox:node(notesBtn)
notesBtn:attr("tabindex", "0")
notesBtn:attr("data-sv-tip", "notes")
notesBtn:attr("aria-label", "Notes")
notesBtn:attr("aria-expanded", "false")
notesBtn:tag("span"):addClass("sv-ico sv-ico--info"):attr("aria-hidden", "true"):wikitext("i")
titleBox: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")
reqContent:tag("div"):addClass("sv-tip-title"):wikitext("Requirements")


if #reqSkills > 0 then
if #reqSkills > 0 then
local skillLines = {}
local section = reqContent:tag("div")
for _, rs in ipairs(reqSkills) do
section:addClass("sv-tip-section")
if type(rs) == "table" then
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Skills")
local nameReq = rs["Skill External Name"] or rs["Skill Internal Name"] or "Unknown"
section:tag("div"):wikitext(table.concat(reqSkills, "<br />"))
local lvlReq  = rs["Required Level"]
if lvlReq then
table.insert(skillLines, string.format("%s (Lv.%s)", mw.text.nowiki(nameReq), mw.text.nowiki(tostring(lvlReq))))
else
table.insert(skillLines, mw.text.nowiki(nameReq))
end
end
end
if #skillLines > 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(skillLines, "<br />"))
end
end
end


if #reqWeapons > 0 then
if #reqWeapons > 0 then
local weapons = {}
local section = reqContent:tag("div")
for _, w in ipairs(reqWeapons) do
section:addClass("sv-tip-section")
local wn = trim(w)
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Weapons")
if wn then table.insert(weapons, mw.text.nowiki(wn)) end
section:tag("div"):wikitext(table.concat(reqWeapons, ", "))
end
if #weapons > 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(weapons, ", "))
end
end
end


if #reqStances > 0 then
if #reqStances > 0 then
local stances = {}
local section = reqContent:tag("div")
for _, s in ipairs(reqStances) do
section:addClass("sv-tip-section")
local sn = trim(s)
section:tag("span"):addClass("sv-tip-label"):wikitext("Required Stances")
if sn then table.insert(stances, mw.text.nowiki(sn)) end
section:tag("div"):wikitext(table.concat(reqStances, ", "))
end
if #stances > 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(stances, ", "))
end
end
end
end
end