模块:角色属性

可在模块:角色属性/doc创建此模块的帮助文档

local p = {}
local db = require('模块:角色数据属性')
local dataList = db.char_self_data
local query_num = frame.args['角色编号']
local elements = {"HP", "SP", "ATK", "DEF", "MAG", "MDEF", "CRT", "SPD"}
local charBaseData = {}

-- 查询并缓存数据
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 = filterCharSkill(query_num)
    
    local html = mw.html.create()

    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()  -- 如果字段不存在,则输出 "N/A"
            end
        
        end
    
        return tostring(html)
    end
end

return p