模块:测试调用数据:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第16行: | 第16行: | ||
local function skillBox(skill) | local function skillBox(skill) | ||
local skillBoxDiv = mw.html.create() | local skillBoxDiv = mw.html.create() | ||
local tagHtml = mw.html.create() | |||
local tag2Html = mw.html.create() | |||
local spHtml = mw.html.create() | |||
if skill.skill_tag2 then | |||
local skillTags2 = split(skill.skill_tag2, ",") | |||
for _, tag in ipairs(skillTags2) do | |||
tag2Html:wikitext(string.format('[[File:icon-%s.png|20px]]', tag)) | |||
end | |||
end | |||
if skill.skill_sp then | |||
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 | |||
skillBoxDiv: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;') | |||
:text(skill.skill_name) | |||
:done() | |||
:node(tag2Html)-- 状态图标 | |||
:done() | |||
:done() | |||
:node(spHtml)-- SP | |||
:done() | |||
return skillBoxDiv | return skillBoxDiv | ||
end | end |
2024年6月29日 (六) 07:49的版本
可在模块:测试调用数据/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 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 skillBoxDiv = mw.html.create()
local tagHtml = mw.html.create()
local tag2Html = mw.html.create()
local spHtml = mw.html.create()
if skill.skill_tag2 then
local skillTags2 = split(skill.skill_tag2, ",")
for _, tag in ipairs(skillTags2) do
tag2Html:wikitext(string.format('[[File:icon-%s.png|20px]]', tag))
end
end
if skill.skill_sp then
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
skillBoxDiv: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;')
:text(skill.skill_name)
:done()
:node(tag2Html)-- 状态图标
:done()
:done()
:node(spHtml)-- SP
: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