模块:角色属性
可在模块:角色属性/doc创建此模块的帮助文档
local p = {}
local db = require('模块:角色数据属性')
local dataList = db.char_self_data
local elements = {"HP", "SP", "ATK", "DEF", "MAG", "MDEF", "CRT", "SPD"}
local charBaseData = {}
local query_num = frame.args['角色编号']
-- 查询并缓存数据
local function filterCharData(query_num)
if charBaseData[query_num] then
return charBaseData[query_num]
end
local filteredData = {}
for _, v in ipairs(dataList) do
if v.owner_order == query_num then
table.insert(filteredData, v)
end
end
charBaseData[query_num] = filteredData
return filteredData
end
-- 角色白值函数
p["角色白值"] = function(frame)
local charData = filterCharData(query_num)
local html = mw.html.create('table')
for _, w in ipairs(charData) do
local row = html:tag('tr')
for _, emt in ipairs(elements) do
local emtname = "Base" .. emt
if w[emtname] then
row:tag('td'):wikitext(w[emtname]):done()
else
row:tag('td'):wikitext("N/A"):done()
end
end
end
return tostring(html)
end
return p