Module:PncUtil
跳转到导航
跳转到搜索
-- 主要为[[Template:云图计划心智人形]]使用
local p = {}
function p.dollRole(frame)
return table.concat(mw.text.split(frame.args.s, '%s*[,,、]%s*'), '</span><span>')
end
function p.replSkValueClass(frame)
local s = mw.ustring.gsub(frame.args.s, 'pnc%-sk%-', frame.args.r)
return s
end
-- 供[[Template:云图计划颜色]]使用,使用方法见对应文档
function p.dyeText(frame)
do
local parent = frame:getParent()
if parent and parent:getTitle() == 'Template:云图计划颜色' then
frame = parent
end
end
local args = frame.args
local colors = {
['增益'] = '44b163', ['+'] = '44b163',
['减益'] = 'ed372e', ['-'] = 'ed372e',
['治疗'] = '44b164', ['护盾'] = '44b164',
['物理伤害'] = 'ed362e', ['物伤'] = 'ed362e',
['算量伤害'] = '2ba8c4', ['算伤'] = '2ba8c4',
['真实伤害'] = 'b99534', ['真伤'] = 'b99534',
['1星'] = '2c99ff',
['2星'] = 'b268f3',
['3星'] = 'ff8a07',
['潜能'] = 'f08d18',
['潜能灰'] = '3c3d42',
}
local color
-- v模式,返回颜色值
if args.v then
color = colors[args.v]
assert(color, '未识别对应颜色')
return '#'..color
end
-- 返回添加了颜色的文本
color = colors[args[1]]
local text = mw.text.trim(args[2] or args[1])
if not color then
-- 匹配“……的物理伤害/算量伤害/真实伤害/护盾“
for i, v in ipairs({'物理伤害', '算量伤害', '护盾', '真实伤害'}) do
if mw.ustring.match(text, v) then
color = colors[v]
break
end
end
end
if not color then
-- 匹配增益/减益效果
local effects = require('Module:云图计划效果').effects
for k, v in pairs(effects) do
if text == k and v[2] then
color = colors[v[2]]
break
end
end
end
assert(color, '未识别对应颜色')
return '<span style="color:#'..color..'">'..text..'</span>'
end
return p