模块:测试调用数据:修订间差异
小无编辑摘要 标签:已被回退 |
无编辑摘要 |
||
(未显示同一用户的40个中间版本) | |||
第15行: | 第15行: | ||
local function skillBox(skill) | local function skillBox(skill) | ||
-- 状态图标 | |||
local tag2Html | |||
if skill.skill_tag2 then | if skill.skill_tag2 then | ||
local skillTags2 = split(skill.skill_tag2, ",") | local skillTags2 = split(skill.skill_tag2, ",") | ||
tag2Html = mw.html.create() | tag2Html = mw.html.create() | ||
for _, tagicon2 in ipairs(skillTags2) do | for _, tagicon2 in ipairs(skillTags2) do | ||
tag2Html:wikitext(string.format('[[File:icon-%s.png| | tag2Html:wikitext(string.format('[[File:icon-%s.png|class=skillbox-tag2|link=]]', tagicon2)) | ||
end | end | ||
end | end | ||
-- 特性图标 | -- 特性图标 | ||
local tagHtml | |||
if skill.skill_tag then | if skill.skill_tag then | ||
local skillTags = split(skill.skill_tag, ",") | local skillTags = split(skill.skill_tag, ",") | ||
tagHtml = mw.html.create() | tagHtml = mw.html.create() | ||
for _, tagicon in ipairs(skillTags) do | for _, tagicon in ipairs(skillTags) do | ||
tagHtml:wikitext(string.format('[[File:icon-%s.png| | tagHtml:wikitext(string.format('[[File:icon-%s.png|class=skillbox-tag|link=]]', tagicon)) | ||
end | end | ||
end | end | ||
-- SP | -- SP | ||
local spHtml | |||
if skill.skill_sp then | if skill.skill_sp then | ||
spHtml = mw.html.create() | spHtml = mw.html.create() | ||
if skill.skill_type == "EX" then | |||
spHtml:tag('div') | |||
:addClass('skillbox-sp') | |||
:wikitext('可用次数 <span style="font-size:1.2rem;">' .. skill.skill_sp .. '</span>') | |||
:done() | |||
else | |||
spHtml:tag('div') | |||
:addClass('skillbox-sp') | |||
:wikitext('消耗精力 <span style="font-size:1.2rem;">' .. skill.skill_sp .. '</span>') | |||
:done() | |||
end | |||
end | end | ||
-- 技能BOOST | -- 技能BOOST | ||
local boostHtml | |||
if skill.skill_boost then | if skill.skill_boost then | ||
boostHtml = mw.html.create() | boostHtml = mw.html.create() | ||
boostHtml:tag('tr') | boostHtml:tag('tr') | ||
:tag('td | :tag('td') | ||
:wikitext('【BP加成效果】') | :wikitext('【BP加成效果】') | ||
:done() | :done() | ||
第57行: | 第67行: | ||
-- 技能强化效果 | -- 技能强化效果 | ||
local upcontentHtml | |||
if skill.skill_up_content then | if skill.skill_up_content then | ||
upcontentHtml = mw.html.create() | upcontentHtml = mw.html.create() | ||
upcontentHtml:tag('tr') | upcontentHtml:tag('tr') | ||
:tag('td | :tag('td') | ||
:wikitext('【能力强化效果】') | :wikitext('【能力强化效果】') | ||
:done() | :done() | ||
第74行: | 第85行: | ||
-- 技能强化等级 | -- 技能强化等级 | ||
local upHtml | |||
if skill.skill_up then | if skill.skill_up then | ||
upHtml = mw.html.create() | upHtml = mw.html.create() | ||
upHtml:tag('tr') | upHtml:tag('tr') | ||
:tag('td | :tag('td') | ||
:wikitext('【强化学习条件】') | :wikitext('【强化学习条件】') | ||
:done() | :done() | ||
第92行: | 第104行: | ||
-- 展示内容 | -- 展示内容 | ||
local skillBoxDiv = mw.html.create() | local skillBoxDiv = mw.html.create() | ||
skillBoxDiv:tag('div'):addClass('skillbox') | |||
:tag('div'):addClass('skillbox-left') | |||
skillBoxDiv:tag('div'):addClass(' | |||
:tag('div'):addClass(' | |||
:node(tagHtml) -- 特性图标 | :node(tagHtml) -- 特性图标 | ||
:done() | :done() | ||
:tag('div'):addClass(' | :tag('div'):addClass('skillbox-right') | ||
:tag('div'):addClass(' | :tag('div'):addClass('skillbox-topbox') | ||
:tag('div'):addClass('skillbox-namebox') | |||
:tag('div'):addClass('skillbox-name') | |||
:wikitext(skill.skill_name) | |||
:done() | |||
:tag('div'):addClass('skillbox-tag2') | |||
:node(tag2Html) -- 状态图标 | |||
:done() | |||
:done() | |||
:node(spHtml) -- SP | |||
:done() | |||
:tag('table'):addClass('skillbox-content w-100 text-left') | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '2') | |||
:wikitext(skill.skill_content) | |||
:done() | |||
:done() | |||
:node(boostHtml) -- BP | |||
:node(upcontentHtml) -- 强化条件 | |||
:node(upHtml) -- 强化等级 | |||
:done() | |||
:done() | :done() | ||
:done() | :done() | ||
第137行: | 第146行: | ||
-- 提取数据 | -- 提取数据 | ||
local dataList = (query_lang == "cn" or query_lang == "国服" or query_lang == "中文") and dataList_cn or dataList_jp | |||
local parentSkill = {} | |||
local childSkill = {} | |||
for _, ownerList in ipairs(dataList) do | for _, ownerList in ipairs(dataList) do | ||
if query_num == ownerList.owner_order then | if query_num == ownerList.owner_order then | ||
for _, skill in ipairs(ownerList.owner_skill) do | for _, skill in ipairs(ownerList.owner_skill) do | ||
if skill.skill_type == query_type | if skill.skill_type == query_type then | ||
if skill.skill_parent == nil then | |||
table.insert(parentSkill, skill) | |||
else | |||
table.insert(childSkill, skill) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
-- 展示内容 | |||
for _, parent in ipairs(parentSkill) do | |||
html:node(skillBox(parent)) | |||
for _, child in ipairs(childSkill) do | |||
if child.skill_parent == parent.skill_order then | |||
html:tag('div'):addClass('parent-description-container'):node(skillBox(child)):done() | |||
end | |||
end | |||
end | |||
return tostring(html) | return tostring(html) |
2024年7月12日 (五) 22:27的最新版本
可在模块:测试调用数据/doc创建此模块的帮助文档
local p = {}
-- 加载数据
local db_cn = mw.loadData('模块:角色技能数据中文')
local dataList_cn = db_cn.char_skill_data
local db_jp = mw.loadData('模块:角色技能数据日文')
local dataList_jp = db_jp.char_skill_data
-- 手搓split
local function split(input, delimiter)
local result = {}
for match in (input .. delimiter):gmatch("(.-)" .. delimiter) do
table.insert(result, match)
end
return result
end
local function skillBox(skill)
-- 状态图标
local tag2Html
if skill.skill_tag2 then
local skillTags2 = split(skill.skill_tag2, ",")
tag2Html = mw.html.create()
for _, tagicon2 in ipairs(skillTags2) do
tag2Html:wikitext(string.format('[[File:icon-%s.png|class=skillbox-tag2|link=]]', tagicon2))
end
end
-- 特性图标
local tagHtml
if skill.skill_tag then
local skillTags = split(skill.skill_tag, ",")
tagHtml = mw.html.create()
for _, tagicon in ipairs(skillTags) do
tagHtml:wikitext(string.format('[[File:icon-%s.png|class=skillbox-tag|link=]]', tagicon))
end
end
-- SP
local spHtml
if skill.skill_sp then
spHtml = mw.html.create()
if skill.skill_type == "EX" then
spHtml:tag('div')
:addClass('skillbox-sp')
:wikitext('可用次数 <span style="font-size:1.2rem;">' .. skill.skill_sp .. '</span>')
:done()
else
spHtml:tag('div')
:addClass('skillbox-sp')
:wikitext('消耗精力 <span style="font-size:1.2rem;">' .. skill.skill_sp .. '</span>')
:done()
end
end
-- 技能BOOST
local boostHtml
if skill.skill_boost then
boostHtml = mw.html.create()
boostHtml:tag('tr')
:tag('td')
:wikitext('【BP加成效果】')
:done()
:tag('td')
:wikitext(skill.skill_boost)
:done()
:done()
end
-- 技能强化效果
local upcontentHtml
if skill.skill_up_content then
upcontentHtml = mw.html.create()
upcontentHtml:tag('tr')
:tag('td')
:wikitext('【能力强化效果】')
:done()
:tag('td')
:tag('li'):wikitext(skill.skill_up_content):done()
-- 下面的upcontentHtml不能删
if skill.skill_up_content2 then
upcontentHtml:tag('li'):wikitext(skill.skill_up_content2):done()
end
upcontentHtml:done()
upcontentHtml:done()
end
-- 技能强化等级
local upHtml
if skill.skill_up then
upHtml = mw.html.create()
upHtml:tag('tr')
:tag('td')
:wikitext('【强化学习条件】')
:done()
:tag('td')
:tag('li'):wikitext('角色等级达到'.. skill.skill_up .. '以上,并习得技能' .. skill.skill_name):done()
-- 下面的upHtml不能删
if skill.skill_up2 then
upHtml:tag('li'):wikitext('角色等级达到'.. skill.skill_up2 .. '以上,并习得技能' .. skill.skill_name):done()
end
upHtml:done()
upHtml:done()
end
-- 展示内容
local skillBoxDiv = mw.html.create()
skillBoxDiv:tag('div'):addClass('skillbox')
:tag('div'):addClass('skillbox-left')
:node(tagHtml) -- 特性图标
:done()
:tag('div'):addClass('skillbox-right')
:tag('div'):addClass('skillbox-topbox')
:tag('div'):addClass('skillbox-namebox')
:tag('div'):addClass('skillbox-name')
:wikitext(skill.skill_name)
:done()
:tag('div'):addClass('skillbox-tag2')
:node(tag2Html) -- 状态图标
:done()
:done()
:node(spHtml) -- SP
:done()
:tag('table'):addClass('skillbox-content w-100 text-left')
:tag('tr')
:tag('td')
:attr('colspan', '2')
:wikitext(skill.skill_content)
:done()
:done()
:node(boostHtml) -- BP
:node(upcontentHtml) -- 强化条件
:node(upHtml) -- 强化等级
:done()
:done()
:done()
return skillBoxDiv
end
p["测试调用"] = function(frame)
local query_num = frame.args['角色序号']
local query_type = frame.args['查询类型']
local query_lang = frame.args['查询语言'] or ""
local html = mw.html.create()
-- 提取数据
local dataList = (query_lang == "cn" or query_lang == "国服" or query_lang == "中文") and dataList_cn or dataList_jp
local parentSkill = {}
local childSkill = {}
for _, ownerList in ipairs(dataList) do
if query_num == ownerList.owner_order then
for _, skill in ipairs(ownerList.owner_skill) do
if skill.skill_type == query_type then
if skill.skill_parent == nil then
table.insert(parentSkill, skill)
else
table.insert(childSkill, skill)
end
end
end
end
end
-- 展示内容
for _, parent in ipairs(parentSkill) do
html:node(skillBox(parent))
for _, child in ipairs(childSkill) do
if child.skill_parent == parent.skill_order then
html:tag('div'):addClass('parent-description-container'):node(skillBox(child)):done()
end
end
end
return tostring(html)
end
return p