Documentation for this module may be created at Module:C/doc
local p = {}
function p.c(frame)
local args = frame.args
local rawAbilities = args['a'] or ''
local abilities = {}
for ability in mw.text.gsplit(rawAbilities, ";;", true) do
ability = mw.text.trim(ability)
if ability ~= "" then
local name = ability
local limited = ""
local improved = ""
local gifted = false
local adept = false
-- Look for gifted marker
if mw.ustring.find(ability, "%-g%-") then
gifted = true
end
-- Look for adept marker
if mw.ustring.find(ability, "%-a%-") then
adept = true
end
-- Limited (-l-) note
local limitedMatch = mw.ustring.match(ability, "%-l%-(.-)(%-[liag]%-|$)")
or mw.ustring.match(ability, "%-l%-(.+)$")
if limitedMatch then
limited = mw.text.trim(limitedMatch)
end
-- Improved (-i-) note
local improvedMatch = mw.ustring.match(ability, "%-i%-(.-)(%-[liag]%-|$)")
or mw.ustring.match(ability, "%-i%-(.+)$")
if improvedMatch then
improved = mw.text.trim(improvedMatch)
end
-- Remove all markers and their text for name cleanup
name = mw.ustring.gsub(name, "%-l%-.+", "")
name = mw.ustring.gsub(name, "%-i%-.+", "")
name = mw.ustring.gsub(name, "%-g%-", "")
name = mw.ustring.gsub(name, "%-a%-", "")
name = mw.text.trim(name)
table.insert(abilities, {
name = name,
limited = limited,
improved = improved,
gifted = gifted,
adept = adept
})
end
end
-- Sort alphabetically by name
table.sort(abilities, function(a, b) return a.name < b.name end)
-- Intermediate table output
return mw.dumpObject(abilities)
end
return p