模块:测试调用数据:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第6行: | 第6行: | ||
local dataList_jp = db_jp.char_skill_data | local dataList_jp = db_jp.char_skill_data | ||
-- 手搓split | |||
local function split(input, delimiter) | local function split(input, delimiter) | ||
local result = {} | local result = {} | ||
第64行: | 第65行: | ||
:tag('td') | :tag('td') | ||
:tag('li'):wikitext(skill.skill_up_content):done() | :tag('li'):wikitext(skill.skill_up_content):done() | ||
-- 下面的upcontentHtml不能删 | |||
if skill.skill_up_content2 then | if skill.skill_up_content2 then | ||
upcontentHtml:tag('li'):wikitext(skill.skill_up_content2):done() | upcontentHtml:tag('li'):wikitext(skill.skill_up_content2):done() | ||
第80行: | 第82行: | ||
:tag('td') | :tag('td') | ||
:tag('li'):wikitext('角色等级达到'.. skill.skill_up .. '以上,并习得技能' .. skill.skill_name):done() | :tag('li'):wikitext('角色等级达到'.. skill.skill_up .. '以上,并习得技能' .. skill.skill_name):done() | ||
-- 下面的upHtml不能删 | |||
if skill.skill_up2 then | if skill.skill_up2 then | ||
upHtml:tag('li'):wikitext('角色等级达到'.. skill.skill_up2 .. '以上,并习得技能' .. skill.skill_name):done() | upHtml:tag('li'):wikitext('角色等级达到'.. skill.skill_up2 .. '以上,并习得技能' .. skill.skill_name):done() | ||
第87行: | 第90行: | ||
end | end | ||
-- | -- 展示内容 | ||
local skillBoxDiv = mw.html.create() | local skillBoxDiv = mw.html.create() | ||
skillBoxDiv:tag('div'):addClass('description-container'):attr('style', 'margin: 15px 0 15px 0; padding: 20px 10px; background-color: #fbf9f1;') | skillBoxDiv:tag('div'):addClass('description-container'):attr('style', 'margin: 15px 0 15px 0; padding: 20px 10px; background-color: #fbf9f1;') | ||
:tag('div'):addClass('description-display width-5 hidden-xs'):attr('style', 'vertical-align: top; padding: 10px 5px 0 0;') | :tag('div'):addClass('description-display width-5 hidden-xs'):attr('style', 'vertical-align: top; padding: 10px 5px 0 0;') | ||
:node(tagHtml)-- 特性图标 | :node(tagHtml) -- 特性图标 | ||
:done() | :done() | ||
第101行: | 第104行: | ||
:wikitext(skill.skill_name) | :wikitext(skill.skill_name) | ||
:done() | :done() | ||
:node(tag2Html)-- 状态图标 | :node(tag2Html) -- 状态图标 | ||
:done() | :done() | ||
:done() | :done() | ||
:node(spHtml)-- SP | :node(spHtml) -- SP | ||
:done() | :done() | ||
第116行: | 第119行: | ||
:done() | :done() | ||
:done() | :done() | ||
:node(boostHtml) | :node(boostHtml) -- BP | ||
:node(upcontentHtml) | :node(upcontentHtml) -- 强化条件 | ||
:node(upHtml) | :node(upHtml) -- 强化等级 | ||
:done() | :done() | ||
:done() | :done() | ||
第125行: | 第128行: | ||
return skillBoxDiv | return skillBoxDiv | ||
end | end | ||
p["测试调用"] = function(frame) | p["测试调用"] = function(frame) | ||
第139行: | 第141行: | ||
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 and skill.skill_parent == nil then | if skill.skill_type == query_type and skill.skill_parent == nil then |
2024年6月29日 (六) 09:13的版本
可在模块:测试调用数据/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)
-- 状态图标
if skill.skill_tag2 then
local skillTags2 = split(skill.skill_tag2, ",")
tag2Html = mw.html.create()
for _, tag in ipairs(skillTags2) do
tag2Html:wikitext(string.format('[[File:icon-%s.png|20px]]', tag))
end
end
-- 特性图标
if skill.skill_tag then
local skillTags = split(skill.skill_tag, ",")
tagHtml = mw.html.create()
for _, tag in ipairs(skillTags) do
tagHtml:wikitext(string.format('[[File:icon-%s.png|32px]]', tag))
end
end
-- SP
if skill.skill_sp then
spHtml = mw.html.create()
spHtml:tag('div')
:addClass('flex-center text-cen sk-sp'):attr('style', 'border: 1px solid #d0bca7; background-color: #d0bca7; border-radius: 0.5em; padding: 0 15px;')
:wikitext('消耗精力 <span style="font-size:1.2rem;">' .. skill.skill_sp .. '</span>')
:done()
end
-- 技能BOOST
if skill.skill_boost then
boostHtml = mw.html.create()
boostHtml:tag('tr')
:tag('td'):attr('style', 'width: 130px; font-weight: bold;')
:wikitext('【BP加成效果】')
:done()
:tag('td')
:wikitext(skill.skill_boost)
:done()
:done()
end
-- 技能强化效果
if skill.skill_up_content then
upcontentHtml = mw.html.create()
upcontentHtml:tag('tr')
:tag('td'):attr('style', 'font-weight: bold;')
: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
-- 技能强化等级
if skill.skill_up then
upHtml = mw.html.create()
upHtml:tag('tr')
:tag('td'):attr('style', 'font-weight: bold;')
: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('description-container'):attr('style', 'margin: 15px 0 15px 0; padding: 20px 10px; background-color: #fbf9f1;')
:tag('div'):addClass('description-display width-5 hidden-xs'):attr('style', 'vertical-align: top; padding: 10px 5px 0 0;')
:node(tagHtml) -- 特性图标
:done()
:tag('div'):addClass('description-display')
:tag('div'):addClass('flex-row-btw')
:tag('div'):addClass('flex-center text-left'):attr('style', 'padding: 5px;')
:tag('span'):attr('style', 'font-size: 1.3rem; font-weight: bold; padding-left: 2em;')
:wikitext(skill.skill_name)
:done()
:node(tag2Html) -- 状态图标
:done()
:done()
:node(spHtml) -- SP
:done()
:tag('div'):addClass('text-left')
:tag('table'):addClass('w-100')
:tag('tr')
:tag('td')
:attr('colspan', '2')
:attr('style', 'padding: 5px 0px 15px 5px;')
: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 == "国服") and dataList_cn or dataList_jp
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 and skill.skill_parent == nil then
html:node(skillBox(skill))
end
end
end
end
return tostring(html)
end
return p