◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
![]() |
模块:Sangvis info
此模块的文档可以在模块:Sangvis info/doc创建
local p = {} local args = {} local root local unitdata local data = mw.loadData('Module:Sangvis info/data') local infobox = require('Module:Infobox').infobox local forces = {'铁血工造', '正规军', '帕拉蒂斯', '其他势力'} local chartype = {'有甲', '无甲', '机械', '人形', '近战', '远程', [0] = '全体'} local attrname = {'生命', '伤害', '攻速', '命中', '回避', '护甲', '穿甲', '暴击', '暴击伤害', '移速', '射程'} local effectname = {'伤害', '攻速', '命中', '回避', '暴击率', [8] = '护甲'} local function putAttrs() local div = root:tag('div') local attrs = {} for i = 1, 6 do attrs[i] = tostring(unitdata.attrs[i]) end div:attr{ id = 'attrs', ['data-id'] = tostring(unitdata.id), ['data-type'] = tostring(unitdata.type-1), ['data-attrs'] = table.concat(attrs, ','), ['data-grow'] = tostring(unitdata.grow), ['data-resolution'] = unitdata.resolution } local control = div:tag('div'):attr('id', 'control') local affix = control:tag('div') if unitdata.type > 1 then affix:tag('div'):attr('id', 'size-control') end affix:tag('div'):attr('id', 'formation-control') local common = control:tag('div') common:tag('div'):attr('id', 'resolve-signal') common:tag('div'):attr('id', 'lv-control') local rank = common:tag('div'):attr('id', 'rank-control') for i = 1, 5 do rank:tag('img'):attr{ id = 'star' .. tostring(i), ['data-id'] = i - 1 } end div:tag('div'):attr('id', 'resolve-control') local growing = div:tag('table') local thead1 = growing:tag('tr') local tbody1 = growing:tag('tr') for i = 1, 6 do thead1:tag('th'):attr('id', 'attr-th-' .. tostring(i)):wikitext(attrname[i]) tbody1:tag('td'):attr('id', 'attr-td-' .. tostring(i)) end local fixed = div:tag('table') local thead2 = fixed:tag('tr') local tbody2 = fixed:tag('tr') for i = 7, 11 do thead2:tag('th'):attr('id', 'attr-th-' .. tostring(i)):wikitext(attrname[i]) local val = tostring(unitdata.attrs[i]) if i == 8 or i == 9 then val = val .. '%' end tbody2:tag('td'):wikitext(val) end end local function addInfobox() root:wikitext(infobox{ above = unitdata.name, label1 = '初始星级', data1 = tostring(4 - unitdata.type), label2 = '所属势力', data2 = forces[unitdata.force], label3 = '战斗特性', data3 = chartype[unitdata.char[1]] .. ' ' .. chartype[unitdata.char[2]] .. ' ' .. chartype[unitdata.char[3]], label4 = '费用', data4 = tostring(unitdata.cost) }) end local function _sangvisInfo() unitdata = data[tonumber(args[1])] if unitdata == nil then return '<p style="color:red">未找到编号对应的融合势力单位信息,请检查编号是否正确及' .. '<a href="/w/Module:Sangvis_info/data">模块:Sangvis info/data</a>的数据是否为最新。</p>' end root = mw.html.create() addInfobox() putAttrs() local templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = '模板:融合势力信息/styles.css' } } return templatestyles .. tostring(root) end function p.sangvisInfo(frame) if frame == mw.getCurrentFrame() then args = frame:getParent().args else args = frame end return _sangvisInfo() end return p