模块:测试调用数据:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第5行: | 第5行: | ||
local db_jp = mw.loadData('模块:角色技能数据日文') | local db_jp = mw.loadData('模块:角色技能数据日文') | ||
local dataList_jp = db_jp.char_skill_data | local dataList_jp = db_jp.char_skill_data | ||
local function skillBox(skill) | |||
local html = mw.html.create() | |||
-- 创建技能框的容器 div | |||
local skillBoxDiv = html:tag('div') | |||
skillBoxDiv:addClass('description-container') | |||
skillBoxDiv:css({ | |||
margin = '15px 0 15px 0', | |||
padding = '20px 10px', | |||
['background-color'] = '#fbf9f1' | |||
}) | |||
-- 第一个部分:特性图标和技能名称 | |||
skillBoxDiv:tag('div') | |||
:addClass('description-display width-5 hidden-xs') | |||
:css({ | |||
['vertical-align'] = 'top', | |||
padding = '10px 5px 0 0' | |||
}) | |||
:tag('center') | |||
:wikitext('{{#arraymap:' .. skill.skill_tag .. '|,|@|{{特性图标|@|size=32px}}|}}') | |||
:done() | |||
:done() | |||
:tag('div') | |||
:addClass('flex-row-btw') | |||
:css({ | |||
padding = '5px', | |||
['font-size'] = 'bold' | |||
}) | |||
:tag('span') | |||
:attr('style', 'font-size: 1.3rem') | |||
:text(skill.skill_name) | |||
:wikitext('{{#arraymap:' .. skill.skill_tag2 .. '|,|@|{{特性图标|@}}|}}') | |||
:done() | |||
-- 如果有消耗SP,则显示消耗精力 | |||
if skill.skill_sp then | |||
skillBoxDiv:tag('div') | |||
:addClass('flex-center text-cen sk-sp') | |||
:css({ | |||
border = '1px solid #d0bca7', | |||
['background-color'] = '#d0bca7', | |||
['border-radius'] = '0.5em', | |||
padding = '0 15px' | |||
}) | |||
:wikitext('消耗精力') | |||
:tag('span') | |||
:css({['font-size'] = '1.2rem'}) | |||
:text(skill.skill_sp) | |||
:done() | |||
:done() | |||
end | |||
-- 第二部分:技能描述和其他属性表格 | |||
skillBoxDiv:tag('div') | |||
:addClass('text-left') | |||
:tag('table') | |||
:addClass('w-100') | |||
:tag('tr') | |||
:tag('td') | |||
:css({padding = '5px 0px 15px 5px', colspan = '2'}) | |||
:text(skill.skill_content) | |||
:done() | |||
-- 辅助函数:用于创建属性表格行 | |||
local function tabletr(label, value) | |||
if value then | |||
skillBoxDiv:tag('tr') | |||
:tag('td') | |||
:css({padding = '5px 0px 15px 5px', colspan = '2'}) | |||
:wikitext(label .. ': ' .. value) | |||
:done() | |||
end | |||
end | |||
-- 添加其余属性 | |||
tabletr('【BP加成效果】', skill.skill_boost) | |||
tabletr('【强化效果】', skill.skill_up) | |||
tabletr('【强化学习条件】', skill.skill_up_content) | |||
tabletr('【强化学习条件】', skill.skill_up_content2) | |||
return skillBoxDiv | |||
end | |||
p["测试调用"] = function(frame) | p["测试调用"] = function(frame) | ||
第21行: | 第106行: | ||
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 | ||
html: | html:node(skillBox(skill)) | ||
end | end | ||
end | end |
2024年6月28日 (五) 17:05的版本
可在模块:测试调用数据/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
local function skillBox(skill)
local html = mw.html.create()
-- 创建技能框的容器 div
local skillBoxDiv = html:tag('div')
skillBoxDiv:addClass('description-container')
skillBoxDiv:css({
margin = '15px 0 15px 0',
padding = '20px 10px',
['background-color'] = '#fbf9f1'
})
-- 第一个部分:特性图标和技能名称
skillBoxDiv:tag('div')
:addClass('description-display width-5 hidden-xs')
:css({
['vertical-align'] = 'top',
padding = '10px 5px 0 0'
})
:tag('center')
:wikitext('{{#arraymap:' .. skill.skill_tag .. '|,|@|{{特性图标|@|size=32px}}|}}')
:done()
:done()
:tag('div')
:addClass('flex-row-btw')
:css({
padding = '5px',
['font-size'] = 'bold'
})
:tag('span')
:attr('style', 'font-size: 1.3rem')
:text(skill.skill_name)
:wikitext('{{#arraymap:' .. skill.skill_tag2 .. '|,|@|{{特性图标|@}}|}}')
:done()
-- 如果有消耗SP,则显示消耗精力
if skill.skill_sp then
skillBoxDiv:tag('div')
:addClass('flex-center text-cen sk-sp')
:css({
border = '1px solid #d0bca7',
['background-color'] = '#d0bca7',
['border-radius'] = '0.5em',
padding = '0 15px'
})
:wikitext('消耗精力')
:tag('span')
:css({['font-size'] = '1.2rem'})
:text(skill.skill_sp)
:done()
:done()
end
-- 第二部分:技能描述和其他属性表格
skillBoxDiv:tag('div')
:addClass('text-left')
:tag('table')
:addClass('w-100')
:tag('tr')
:tag('td')
:css({padding = '5px 0px 15px 5px', colspan = '2'})
:text(skill.skill_content)
:done()
-- 辅助函数:用于创建属性表格行
local function tabletr(label, value)
if value then
skillBoxDiv:tag('tr')
:tag('td')
:css({padding = '5px 0px 15px 5px', colspan = '2'})
:wikitext(label .. ': ' .. value)
:done()
end
end
-- 添加其余属性
tabletr('【BP加成效果】', skill.skill_boost)
tabletr('【强化效果】', skill.skill_up)
tabletr('【强化学习条件】', skill.skill_up_content)
tabletr('【强化学习条件】', skill.skill_up_content2)
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