- 点击右上角🔍,可以搜索 WIKI
全站通知:
模块:誓灵数据列表
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:誓灵数据列表/doc创建
local p = {}
--------------------------------------------------
-- 公开函数
--------------------------------------------------
p['查询分类誓灵'] = function()
local data = callAskQuery('[[概念:誓灵]]', {
'?编号',
'?稀有度',
'?属性',
'?5星生命',
'?5星速度',
'?5星物攻',
'?5星物防',
'?5星魔攻',
'?5星魔防',
'?出身',
'?天赋名称',
'?天赋介绍',
'?技能1名',
'?技能2名',
'?技能3名',
'?技能4名',
'?技能5名',
'?技能6名',
'?技能7名',
'?技能8名',
link = 'none',
sort = '编号',
headers = 'hide',
format = 'table',
limit = 1000
})
local result = {}
for _, item in ipairs(data) do
result[#result + 1] = parseToTableRow(item)
end
return table.concat(result, '')
end
--------------------------------------------------
-- 主要过程
--------------------------------------------------
--将每一行的数据解析为表格的行
local skill_keys = {'技能1名', '技能1', '技能2名', '技能2', '技能3名', '技能3', '技能4名', '技能4'}
function parseToTableRow(args)
--参考[[模板:舰娘数据列表15/行]]
--用于匹配替换的参数列表
local repl_args = {}
for k, v in pairs(args) do
repl_args[tostring(k)] = v --将数字转换为字符串
end
repl_args['页面链接'] = '[['..args[1]..'|NO.'..args[2]..'<b>'..args[1]..'</b>'..']]'
repl_args['小图标'] = '<div style="width:122px;display:inline-block;position:relative;"><div style="width:34px;height:34px;position:relative;display:inline-block;border-radius:5px;middle;border:2px solid {{#switch:'..args[3]..'|N=#88ddaa|R=#11ccff|SR=#ffaadd|UR=#ffdd44|#ddd}}">[[file:'..args[1]..'5星头像.png|30px|link='..args[1]..']] </div><div style="margin-left:2px;display:inline-block;line-height:34px;display:inline-block;height:34px;vertical-align: top;">[['..args[1]..']]</div></div>'
if not isNil(args[5]) then
repl_args['生命'] = tonumber(args[5]) * 10 +550
repl_args['速度'] = tonumber(args[6]) * 5 +12
repl_args['物攻'] = tonumber(args[7]) * 5 +12
repl_args['物防'] = tonumber(args[8]) * 5 +12
repl_args['魔攻'] = tonumber(args[9]) * 5 +12
repl_args['魔防'] = tonumber(args[10]) * 5 +12
else
repl_args['生命'] = "无数据"
repl_args['速度'] = "无数据"
repl_args['物攻'] = "无数据"
repl_args['物防'] = "无数据"
repl_args['魔攻'] = "无数据"
repl_args['魔防'] = "无数据"
end
if isNil(args[21]) then
repl_args['技能8'] = ""
else
repl_args['技能8'] = '[http://wiki.biligame.com/fzzl/技能:'..args[21]..' '..args[21]..']'
end
if isNil(args[20]) then
repl_args['技能7'] = ""
else
repl_args['技能7'] = '[http://wiki.biligame.com/fzzl/技能:'..args[20]..' '..args[20]..']'
end
repl_args.COMPARESEL = mw.getCurrentFrame():preprocess('<div class="compare-label"><span class="" onclick="card_sel(this);">对比</span></div>')
return ([[
|-class="divsort" data-param0="0" data-param1="{{{3}}}" data-param2="{{{4}}}" data-param3="{{{11}}}"
|{{{2}}}
| style="text-align:left;"|
<span data-cardurl="{{{1}}}">
<div class="itemhover" style="position:relative;">{{{小图标}}}
<div class="iteminfo" style="position:absolute;float:left;top:15px;left:80px;width:300px;;z-index:1000;background:#FFF;">
{| class="wikitable" style="width:100%;"
| colspan=2 style="text-align:left" | '''{{{12}}}'''<br />{{{13}}}
|-
| [http://wiki.biligame.com/fzzl/技能:{{{14}}} {{{14}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{15}}} {{{15}}}]
|-
| [http://wiki.biligame.com/fzzl/技能:{{{16}}} {{{16}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{17}}} {{{17}}}]
|-
| [http://wiki.biligame.com/fzzl/技能:{{{18}}} {{{18}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{19}}} {{{19}}}]
|-
| {{{技能7}}}
| {{{技能8}}}
|}</div></div></span>
<span data-id="info_{{{1}}}" style="display:none">{{{页面链接}}}<p>
</p>
{{{小图标}}}
<p>
{| class="wikitable" style="width:100%;"
! 稀有度
| {{{3}}}
|-
! 属性
| {{{4}}}
|-
! 生命
|{{{生命}}}
|-
! 速度
|{{{速度}}}
|-
! 物攻
|{{{物攻}}}
|-
! 物防
|{{{物防}}}
|-
! 魔攻
|{{{魔攻}}}
|-
! 魔防
|{{{魔防}}}
|-
| colspan=2 | <div style="text-align:left;height:70px;>'''{{{12}}}'''<br />{{{13}}}</div>
|-
| [http://wiki.biligame.com/fzzl/技能:{{{14}}} {{{14}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{15}}} {{{15}}}]
|-
| [http://wiki.biligame.com/fzzl/技能:{{{16}}} {{{16}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{17}}} {{{17}}}]
|-
| [http://wiki.biligame.com/fzzl/技能:{{{18}}} {{{18}}}]
| [http://wiki.biligame.com/fzzl/技能:{{{19}}} {{{19}}}]
|-
| {{{技能7}}}
| {{{技能8}}}
|}
</p>
</span>
|{{{3}}}
|{{{4}}}
|{{{11}}}
|{{{生命}}}
|{{{速度}}}
|{{{物攻}}}
|{{{物防}}}
|{{{魔攻}}}
|{{{魔防}}}
]]):gsub('%{%{%{(.-)%}%}%}', function(key)
return repl_args[key] or ''
end
)
end
--------------------------------------------------
-- 私有函数
--------------------------------------------------
--检查字符串是否为空
function isNil(s)
return not s or s == ''
end
--检查table中是否含有某项
function case(value, ...)
for _, v in ipairs({...}) do
if value == v then return true end
end
return false
end
--调用#ask语义查询,并将结果解析为table
function callAskQuery(title, args)
local frame = mw.getCurrentFrame()
args.format = 'table'
local html = frame:callParserFunction('#ask:'..title, args)
--返回解析结果的key
local keys = {}
keys[1] = '' --#ask的参数#1是title
for i, v in ipairs(args) do
keys[i+1] = mw.text.trim(v:sub(2))
end
local data = {}
for tr in html:gmatch('<tr .-</tr>') do
if tr:match('smwfooter') then break end
local item = {}
local i = 1 --#1单元格是页面名称
for td in tr:gmatch('<td.->(.-)</td>') do
td = mw.text.trim(td)
item[i] = td
if keys[i] then item[ keys[i] ] = td end
i = i + 1
end
table.insert(data, item)
end
return data
end
return p