Module:Exedra Skill Scaling
Jump to navigation
Jump to search
See Template:Exedra Skill Scaling.
The colors specified at the top are for highlighting the parameters in Magia Exedra Skills in Template:Magia Exedra Stats. The colors do not correspond to anything specific in Magia Exedra, they are only for the wiki.
If adding new colors, keep in mind that the text should be visible and readable on both light and dark backgrounds.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local colors = {'#2394ca', '#bd23ca', '#f03d86', '#e37517', '#e3d317', '#43e317', '#696969'}
local function letter2index(letter)
return string.byte(letter) - string.byte('a') + 1
end
local function colorize(clr, s)
return ("'''<span style='color:%s'>%s</span>'''"):format(colors[clr] or colors[#colors], s)
end
local function convertPlaceholder(letter)
if letter:match('[1-9]') then return '%' .. letter .. 's' end
return '%' .. tostring(letter2index(letter)) .. 's'
end
function p.main(...)
local args = getArgs(...)
local template = args.text:gsub([[%%]], '%%%%'):gsub('%[([a-z1-9])%]', convertPlaceholder)
local fmt_args = {}
for letter in ('abcdefghijklmnopqrstuvwxyz'):gmatch('.') do
local min_arg = letter .. '1'
local max_arg = letter .. '10'
local idx = letter2index(letter)
if args[min_arg] and args[max_arg] then
fmt_args[idx] = string.format('%s-%s', args[min_arg], args[max_arg])
elseif args[min_arg] or args[max_arg] then
fmt_args[idx] = args[min_arg] or args[max_arg]
end
if fmt_args[idx] then
fmt_args[idx] = colorize(idx, fmt_args[idx])
end
end
return template:format(unpack(fmt_args))
end
return p