◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
![]() |
“模块:Sangvis info”的版本间的差异
小 |
(技能图标名格式和用户:莹lolo统一) |
||
(未显示同一用户的39个中间版本) | |||
第4行: | 第4行: | ||
local unitdata | local unitdata | ||
local data = mw.loadData('Module:Sangvis info/data') | local data = mw.loadData('Module:Sangvis info/data') | ||
− | local | + | local bdata = {} |
+ | local mdata = mw.loadData('Module:Mission skill config/data') | ||
local infobox = require('Module:Infobox').infobox | local infobox = require('Module:Infobox').infobox | ||
local forces = {'铁血工造', '正规军', '帕拉蒂斯', '其他势力'} | local forces = {'铁血工造', '正规军', '帕拉蒂斯', '其他势力'} | ||
第11行: | 第12行: | ||
'穿甲', '暴击', '暴击伤害', '移速', '射程'} | '穿甲', '暴击', '暴击伤害', '移速', '射程'} | ||
local effectname = {'伤害', '攻速', '命中', '回避', '暴击率', [8] = '护甲'} | local effectname = {'伤害', '攻速', '命中', '回避', '暴击率', [8] = '护甲'} | ||
+ | local orgs = {'', '专用训练场', '隔离考场', '专用工厂'} | ||
local function serveSkillInfo(order) | local function serveSkillInfo(order) | ||
local id = unitdata['skill' .. order] | local id = unitdata['skill' .. order] | ||
− | local skilldata = | + | local group = math.floor(id/1e5) |
− | local skill = root:tag('table'):attr{ | + | local skilldata = mdata[id] |
− | ['data-cd'] = skilldata.cd_time } | + | if not skilldata then |
+ | if not bdata[group] then | ||
+ | bdata[group] = mw.loadData('Module:Battle skill config/sangvis data ' .. tostring(group)) | ||
+ | end | ||
+ | skilldata = bdata[group][id] | ||
+ | end | ||
+ | local skill = root:tag('table'):attr{ id = 'skill' .. order, | ||
+ | class = 'skill-table', | ||
+ | ['data-cd'] = skilldata.cd_time, | ||
+ | ['data-cd-start'] = skilldata.start_cd_time } | ||
if skilldata.vals then skill:attr('data-val', skilldata.vals) end | if skilldata.vals then skill:attr('data-val', skilldata.vals) end | ||
− | local signature = skill:tag('tr') | + | local signature = skill:tag('tr'):attr('class', 'skill-signature') |
local icon = signature:tag('td') | local icon = signature:tag('td') | ||
− | if order == '2' then icon:attr('class', | + | if order == '2' and unitdata.skill2_type ~= 1 then |
− | icon:attr('rowspan', | + | icon:attr('class', 'active-skill') end |
− | :wikitext('[[ | + | icon:attr('rowspan', 2) |
+ | :wikitext('[[File:IconSkill ' .. skilldata.code .. '.png|48px|link=]]') | ||
local skillname = signature:tag('td') | local skillname = signature:tag('td') | ||
skillname:wikitext(skilldata.name) | skillname:wikitext(skilldata.name) | ||
if order == '_adv' then skillname:tag('span'):wikitext('4星解锁') end | if order == '_adv' then skillname:tag('span'):wikitext('4星解锁') end | ||
− | local lvcd = skill:tag('tr'):tag('td') | + | local lvcd = skill:tag('tr'):tag('td'):attr('class', 'skill-lvcd') |
lvcd:tag('span'):wikitext('等级10') | lvcd:tag('span'):wikitext('等级10') | ||
− | if order ~= '2' or | + | if order ~= '2' or unitdata.skill2_type ~= 2 then |
− | lvcd:wikitext('前置冷却<span> | + | lvcd:wikitext('前置冷却<span></span>秒/') |
end | end | ||
lvcd:wikitext('冷却时间') | lvcd:wikitext('冷却时间') | ||
lvcd:tag('span') | lvcd:tag('span') | ||
− | if order == '2' | + | if order == '2' and unitdata.skill2_type == 2 then lvcd:wikitext('回合') |
else lvcd:wikitext('秒') end | else lvcd:wikitext('秒') end | ||
− | skill:tag('tr'):tag('td'):attr{class = 'lv-control', colspan = | + | skill:tag('tr'):tag('td'):attr{class = 'lv-control', colspan = 2} |
− | local desc = skill:tag('tr'):tag('td'):attr('colspan', | + | local desc = skill:tag('tr'):tag('td'):attr('colspan', 2) |
if skilldata.desc then | if skilldata.desc then | ||
− | local descstr = string.gsub(skilldata.desc, '{}', '<skill></ | + | local descstr = string.gsub(skilldata.desc, '{}', '<span class="skill"></span>') |
descstr = string.gsub(descstr, '\n', '<br>') | descstr = string.gsub(descstr, '\n', '<br>') | ||
desc:wikitext(descstr) | desc:wikitext(descstr) | ||
else for i, v in ipairs(skilldata.full_desc) do | else for i, v in ipairs(skilldata.full_desc) do | ||
− | desc:tag('p'):wikitext(string.gsub(v, '\n', '<br>')) end | + | desc:tag('p'):wikitext((string.gsub(v, '\n', '<br>'))) end |
end | end | ||
if order == '1' then | if order == '1' then | ||
− | local | + | local rescrow = skill:tag('tr'):attr('class', 'desc-hidden') |
− | local resdata = | + | local resc = rescrow:tag('td'):attr('colspan', 2) |
− | local descstr = string.gsub(resdata.desc, '{}', '<skill></ | + | local resdata = bdata[group][unitdata.skill_res] |
+ | local descstr = string.gsub(resdata.desc, '{}', '<span class="skill"></span>') | ||
descstr = string.gsub(descstr, '\n', '<br>') | descstr = string.gsub(descstr, '\n', '<br>') | ||
resc:wikitext(descstr) | resc:wikitext(descstr) | ||
skill:attr{ | skill:attr{ | ||
['data-cd-res'] = resdata.cd_time, | ['data-cd-res'] = resdata.cd_time, | ||
− | ['data- | + | ['data-res-start'] = resdata.start_cd_time, |
['data-res'] = resdata.vals } | ['data-res'] = resdata.vals } | ||
end | end | ||
第62行: | 第75行: | ||
if griddata[i] then | if griddata[i] then | ||
content:wikitext('<br>') | content:wikitext('<br>') | ||
− | content:wikitext('对[[:分类:' .. chartype[i] .. '单位|' .. chartype[i] .. ']]有效,') | + | content:wikitext('对', |
+ | '[[:分类:' .. chartype[i] .. '单位|' .. chartype[i] .. ']]', | ||
+ | '有效,<br>') | ||
local pair = griddata[i] | local pair = griddata[i] | ||
for j = 1, 8 do | for j = 1, 8 do | ||
if pair[j] then | if pair[j] then | ||
− | content:wikitext( | + | content:wikitext(effectname[j], |
− | + | '上升<span>' .. tostring(pair[j]) .. '%</span>') | |
end | end | ||
end | end | ||
第77行: | 第92行: | ||
local function putSkills() | local function putSkills() | ||
root:wikitext('=== 技能 ===') | root:wikitext('=== 技能 ===') | ||
+ | root:newline() | ||
if unitdata.type == 1 then | if unitdata.type == 1 then | ||
serveSkillInfo('1') | serveSkillInfo('1') | ||
serveSkillInfo('2') | serveSkillInfo('2') | ||
end | end | ||
− | if unitdata.type | + | if unitdata.type < 3 then |
serveSkillInfo('3') | serveSkillInfo('3') | ||
end | end | ||
serveSkillInfo('_adv') | serveSkillInfo('_adv') | ||
+ | root:newline() | ||
end | end | ||
local function putGrid() | local function putGrid() | ||
root:wikitext('=== 阵型加成 ===') | root:wikitext('=== 阵型加成 ===') | ||
+ | root:newline() | ||
local grid = root:tag('div'):attr('id', 'effect-grid') | local grid = root:tag('div'):attr('id', 'effect-grid') | ||
local baseeffect = grid:tag('div') | local baseeffect = grid:tag('div') | ||
− | baseeffect:wikitext("''初始效果''") | + | baseeffect:wikitext("'''初始效果'''") |
baseeffect:wikitext(makeGrid(unitdata.effect)) | baseeffect:wikitext(makeGrid(unitdata.effect)) | ||
local reseffect = grid:tag('div') | local reseffect = grid:tag('div') | ||
− | + | reseffect:wikitext("'''解析等级1效果'''") | |
reseffect:wikitext(makeGrid(unitdata.resolved_effect)) | reseffect:wikitext(makeGrid(unitdata.resolved_effect)) | ||
root:newline() | root:newline() | ||
第101行: | 第119行: | ||
local function putAttrs() | local function putAttrs() | ||
root:wikitext('=== 属性 ===') | root:wikitext('=== 属性 ===') | ||
+ | root:newline() | ||
local div = root:tag('div') | local div = root:tag('div') | ||
local attrs = {} | local attrs = {} | ||
for i = 1, 6 do attrs[i] = tostring(unitdata.attrs[i]) end | for i = 1, 6 do attrs[i] = tostring(unitdata.attrs[i]) end | ||
div:attr{ id = 'attrs', | div:attr{ id = 'attrs', | ||
− | ['data-id'] = | + | ['data-id'] = unitdata.id, |
− | ['data-type'] = | + | ['data-type'] = unitdata.type-1, |
['data-attrs'] = table.concat(attrs, ','), | ['data-attrs'] = table.concat(attrs, ','), | ||
− | ['data-grow'] = | + | ['data-grow'] = unitdata.grow, |
['data-resolution'] = unitdata.resolution } | ['data-resolution'] = unitdata.resolution } | ||
local control = div:tag('div'):attr('id', 'control') | local control = div:tag('div'):attr('id', 'control') | ||
第139行: | 第158行: | ||
tbody2:tag('td'):wikitext(val) | tbody2:tag('td'):wikitext(val) | ||
end | end | ||
+ | root:newline() | ||
+ | end | ||
+ | |||
+ | local function addIntro() | ||
+ | local intro = unitdata.intro | ||
+ | if unitdata.id < 1013 then | ||
+ | intro = "'''" .. unitdata.name .. "'''是[[铁血工造]]的头目单位。" .. intro | ||
+ | elseif unitdata.id == 1015 then | ||
+ | intro = "'''建筑师-临海战斗特化型''',简称'''NVW型'''" .. mw.ustring.sub(intro, 19) | ||
+ | elseif unitdata.id ~= 1021 and unitdata.id > 1014 and unitdata.id < 2001 then | ||
+ | local namepos = mw.ustring.find(intro, ',') | ||
+ | intro = "'''" .. mw.ustring.sub(intro, 1, namepos-1) .. "'''" .. mw.ustring.sub(intro, namepos) | ||
+ | elseif unitdata.id ~= 2017 then intro = "'''" .. unitdata.name .. "'''是" .. intro end | ||
+ | root:wikitext(intro) | ||
root:newline() | root:newline() | ||
end | end | ||
local function addInfobox() | local function addInfobox() | ||
− | + | local cat = {} | |
− | above = unitdata.name, | + | for i = 1,3 do |
+ | local ctype = chartype[unitdata.char[i]] | ||
+ | cat[i] = '[[:分类:' .. ctype .. '单位|' .. ctype .. ']]' | ||
+ | cat[i] = cat[i] .. '[[分类:' .. ctype .. '单位|' .. ctype .. ']]' | ||
+ | end | ||
+ | local params = { above = unitdata.name, | ||
label1 = '初始星级', | label1 = '初始星级', | ||
data1 = tostring(4 - unitdata.type), | data1 = tostring(4 - unitdata.type), | ||
第150行: | 第188行: | ||
data2 = forces[unitdata.force], | data2 = forces[unitdata.force], | ||
label3 = '战斗特性', | label3 = '战斗特性', | ||
− | data3 = | + | data3 = table.concat(cat, ' '), |
− | |||
label4 = '费用', | label4 = '费用', | ||
− | data4 = tostring(unitdata.cost) | + | data4 = tostring(unitdata.cost), |
− | + | image1 = '[[file:pic ' .. unitdata.code .. ' LL.png|320px]]' } | |
+ | if unitdata.type == 1 then | ||
+ | params.caption1 = '初始形象' | ||
+ | params.image2 = '[[file:pic ' .. unitdata.code .. ' LL 1.png|320px]]' | ||
+ | params.caption2 = '五星形象' | ||
+ | params.label5 = '所属部门' | ||
+ | org = orgs[unitdata.org-10600] | ||
+ | params.data5 = '[[内部一览/协议同归部#' .. org .. '|' .. org .. ']]' | ||
+ | end | ||
+ | root:wikitext(infobox(params)) | ||
+ | root:newline() | ||
end | end | ||
第166行: | 第213行: | ||
addInfobox() | addInfobox() | ||
− | + | addIntro() | |
root:wikitext('== 作战能力 ==') | root:wikitext('== 作战能力 ==') | ||
root:newline() | root:newline() | ||
第172行: | 第219行: | ||
if unitdata.type == 1 then putGrid() end | if unitdata.type == 1 then putGrid() end | ||
putSkills() | putSkills() | ||
+ | root:wikitext('== 战斗形象 ==') | ||
+ | root:newline() | ||
local templatestyles = mw.getCurrentFrame():extensionTag{ | local templatestyles = mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = '模板:融合势力信息/styles.css' } | name = 'templatestyles', args = { src = '模板:融合势力信息/styles.css' } | ||
} | } | ||
− | return templatestyles .. tostring(root) | + | local chibi = mw.getCurrentFrame():expandTemplate{ |
+ | title = 'Q版调用', | ||
+ | args = { | ||
+ | ['人形名'] = args.spine or unitdata.code, | ||
+ | W = '360px', H = '360px', | ||
+ | ['大单位'] = args.large or '' | ||
+ | } | ||
+ | } | ||
+ | return templatestyles .. tostring(root) .. chibi | ||
end | end | ||
2023年5月31日 (三) 02:39的最新版本
此模块的文档可以在模块:Sangvis info/doc创建
local p = {} local args = {} local root local unitdata local data = mw.loadData('Module:Sangvis info/data') local bdata = {} local mdata = mw.loadData('Module:Mission skill config/data') local infobox = require('Module:Infobox').infobox local forces = {'铁血工造', '正规军', '帕拉蒂斯', '其他势力'} local chartype = {'有甲', '无甲', '机械', '人形', '近战', '远程', [0] = '全体'} local attrname = {'生命', '伤害', '攻速', '命中', '回避', '护甲', '穿甲', '暴击', '暴击伤害', '移速', '射程'} local effectname = {'伤害', '攻速', '命中', '回避', '暴击率', [8] = '护甲'} local orgs = {'', '专用训练场', '隔离考场', '专用工厂'} local function serveSkillInfo(order) local id = unitdata['skill' .. order] local group = math.floor(id/1e5) local skilldata = mdata[id] if not skilldata then if not bdata[group] then bdata[group] = mw.loadData('Module:Battle skill config/sangvis data ' .. tostring(group)) end skilldata = bdata[group][id] end local skill = root:tag('table'):attr{ id = 'skill' .. order, class = 'skill-table', ['data-cd'] = skilldata.cd_time, ['data-cd-start'] = skilldata.start_cd_time } if skilldata.vals then skill:attr('data-val', skilldata.vals) end local signature = skill:tag('tr'):attr('class', 'skill-signature') local icon = signature:tag('td') if order == '2' and unitdata.skill2_type ~= 1 then icon:attr('class', 'active-skill') end icon:attr('rowspan', 2) :wikitext('[[File:IconSkill ' .. skilldata.code .. '.png|48px|link=]]') local skillname = signature:tag('td') skillname:wikitext(skilldata.name) if order == '_adv' then skillname:tag('span'):wikitext('4星解锁') end local lvcd = skill:tag('tr'):tag('td'):attr('class', 'skill-lvcd') lvcd:tag('span'):wikitext('等级10') if order ~= '2' or unitdata.skill2_type ~= 2 then lvcd:wikitext('前置冷却<span></span>秒/') end lvcd:wikitext('冷却时间') lvcd:tag('span') if order == '2' and unitdata.skill2_type == 2 then lvcd:wikitext('回合') else lvcd:wikitext('秒') end skill:tag('tr'):tag('td'):attr{class = 'lv-control', colspan = 2} local desc = skill:tag('tr'):tag('td'):attr('colspan', 2) if skilldata.desc then local descstr = string.gsub(skilldata.desc, '{}', '<span class="skill"></span>') descstr = string.gsub(descstr, '\n', '<br>') desc:wikitext(descstr) else for i, v in ipairs(skilldata.full_desc) do desc:tag('p'):wikitext((string.gsub(v, '\n', '<br>'))) end end if order == '1' then local rescrow = skill:tag('tr'):attr('class', 'desc-hidden') local resc = rescrow:tag('td'):attr('colspan', 2) local resdata = bdata[group][unitdata.skill_res] local descstr = string.gsub(resdata.desc, '{}', '<span class="skill"></span>') descstr = string.gsub(descstr, '\n', '<br>') resc:wikitext(descstr) skill:attr{ ['data-cd-res'] = resdata.cd_time, ['data-res-start'] = resdata.start_cd_time, ['data-res'] = resdata.vals } end end local function makeGrid(griddata) local content = mw.html.create() for i = 0, 6 do if griddata[i] then content:wikitext('<br>') content:wikitext('对', '[[:分类:' .. chartype[i] .. '单位|' .. chartype[i] .. ']]', '有效,<br>') local pair = griddata[i] for j = 1, 8 do if pair[j] then content:wikitext(effectname[j], '上升<span>' .. tostring(pair[j]) .. '%</span>') end end end end return tostring(content) end local function putSkills() root:wikitext('=== 技能 ===') root:newline() if unitdata.type == 1 then serveSkillInfo('1') serveSkillInfo('2') end if unitdata.type < 3 then serveSkillInfo('3') end serveSkillInfo('_adv') root:newline() end local function putGrid() root:wikitext('=== 阵型加成 ===') root:newline() local grid = root:tag('div'):attr('id', 'effect-grid') local baseeffect = grid:tag('div') baseeffect:wikitext("'''初始效果'''") baseeffect:wikitext(makeGrid(unitdata.effect)) local reseffect = grid:tag('div') reseffect:wikitext("'''解析等级1效果'''") reseffect:wikitext(makeGrid(unitdata.resolved_effect)) root:newline() end local function putAttrs() root:wikitext('=== 属性 ===') root:newline() 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'] = unitdata.id, ['data-type'] = unitdata.type-1, ['data-attrs'] = table.concat(attrs, ','), ['data-grow'] = 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 root:newline() end local function addIntro() local intro = unitdata.intro if unitdata.id < 1013 then intro = "'''" .. unitdata.name .. "'''是[[铁血工造]]的头目单位。" .. intro elseif unitdata.id == 1015 then intro = "'''建筑师-临海战斗特化型''',简称'''NVW型'''" .. mw.ustring.sub(intro, 19) elseif unitdata.id ~= 1021 and unitdata.id > 1014 and unitdata.id < 2001 then local namepos = mw.ustring.find(intro, ',') intro = "'''" .. mw.ustring.sub(intro, 1, namepos-1) .. "'''" .. mw.ustring.sub(intro, namepos) elseif unitdata.id ~= 2017 then intro = "'''" .. unitdata.name .. "'''是" .. intro end root:wikitext(intro) root:newline() end local function addInfobox() local cat = {} for i = 1,3 do local ctype = chartype[unitdata.char[i]] cat[i] = '[[:分类:' .. ctype .. '单位|' .. ctype .. ']]' cat[i] = cat[i] .. '[[分类:' .. ctype .. '单位|' .. ctype .. ']]' end local params = { above = unitdata.name, label1 = '初始星级', data1 = tostring(4 - unitdata.type), label2 = '所属势力', data2 = forces[unitdata.force], label3 = '战斗特性', data3 = table.concat(cat, ' '), label4 = '费用', data4 = tostring(unitdata.cost), image1 = '[[file:pic ' .. unitdata.code .. ' LL.png|320px]]' } if unitdata.type == 1 then params.caption1 = '初始形象' params.image2 = '[[file:pic ' .. unitdata.code .. ' LL 1.png|320px]]' params.caption2 = '五星形象' params.label5 = '所属部门' org = orgs[unitdata.org-10600] params.data5 = '[[内部一览/协议同归部#' .. org .. '|' .. org .. ']]' end root:wikitext(infobox(params)) root:newline() 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() addIntro() root:wikitext('== 作战能力 ==') root:newline() putAttrs() if unitdata.type == 1 then putGrid() end putSkills() root:wikitext('== 战斗形象 ==') root:newline() local templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = '模板:融合势力信息/styles.css' } } local chibi = mw.getCurrentFrame():expandTemplate{ title = 'Q版调用', args = { ['人形名'] = args.spine or unitdata.code, W = '360px', H = '360px', ['大单位'] = args.large or '' } } return templatestyles .. tostring(root) .. chibi end function p.sangvisInfo(frame) if frame == mw.getCurrentFrame() then args = frame:getParent().args else args = frame end return _sangvisInfo() end return p