跳转到内容

模块:物品收集度:修订间差异

来自Wymbot 共创站
NotBot​(留言 | 贡献)
建立模块化物品展示及用户提供的测试数据(不迁移旧掉落)
 
NotBot​(留言 | 贡献)
恢复旧站紧凑灰底收集度折叠表格,修复来源表其他单元格的异常段落间距
 
(未显示同一用户的1个中间版本)
第23行: 第23行:
     local parts = {}
     local parts = {}
     if result.status == 'error' or overall.status == 'error' then
     if result.status == 'error' or overall.status == 'error' then
         return C.finish(c, 'collection', C.heading(c, '这啥?') .. C.diagnostic(result.status == 'error' and result or overall), { '物品数据异常的页面' })
         return C.finish(c, 'collection', C.heading(c, '这啥?', 3) .. C.diagnostic(result.status == 'error' and result or overall), { '物品数据异常的页面' })
     end
     end
     local cats = classify(overall)
     local cats = classify(overall)
     if result.status == 'none' then return C.categories(c, cats) end
     if result.status == 'none' then return C.categories(c, cats) end
     for _, entry in ipairs(result.entries or {}) do
    local entries = result.entries or {}
         if entry.status ~= 'none' then
    if #entries == 0 then
             local text = entry.status == 'known' and C.literal(entry.text) or '具体信息待补充。'
        entries = { { level = 100, status = 'pending' }, { level = 300, status = 'pending' }, { level = 500, status = 'pending' } }
             parts[#parts + 1] = '<div class="mw-collapsible mw-collapsed wum-item-collection-entry">\n<div class="wum-item-collection-heading">收集度达到 ' .. entry.level .. '%</div>\n<div class="mw-collapsible-content wum-item-literal">' .. text .. '</div>\n</div>'
    end
     for _, entry in ipairs(entries) do
         if entry.status == 'known' or (entry.status ~= 'none' and (entry.level == 100 or entry.level == 300)) then
             local text = entry.status == 'known' and C.literal(entry.text) or '具体信息还不是很清楚,多收集几个试试?<sup>[待完善]</sup>'
             parts[#parts + 1] = '<table class="wikitable mw-collapsible mw-collapsed wum-item-collection-entry">\n<tr><th class="wum-item-collection-heading">收集度达到' .. entry.level .. '%</th></tr>\n<tr><td class="wum-item-literal">' .. text .. '</td></tr>\n</table>'
         end
         end
     end
     end
     if #parts == 0 then parts[1] = '收集度信息待补充。' end
     if #parts == 0 then return C.categories(c, cats) end
     return C.finish(c, 'collection', C.heading(c, '这啥?') .. table.concat(parts, '\n'), cats)
     return C.finish(c, 'collection', C.heading(c, '这啥?', 3) .. table.concat(parts, '\n'), cats)
end
end
return p
return p

2026年10月24日 (六) 12:37的最新版本

此模块的文档可以在模块:物品收集度/doc创建

local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
local function classify(result)
    local cats, pending = {}, result.status == 'pending'
    if result.status == 'none' then cats[#cats + 1] = '没有收集度信息的物品' end
    for _, entry in ipairs(result.entries or {}) do
        if entry.status == 'pending' then pending = true end
        if entry.level == 500 or entry.level == 10000 then
            if entry.status == 'known' then cats[#cats + 1] = '有' .. entry.level .. '%收集度信息的物品'
            elseif entry.level == 500 and entry.status == 'none' then cats[#cats + 1] = '没有500%收集度信息的物品' end
        end
    end
    if pending then cats[#cats + 1] = '物品收集度信息待完善的页面' end
    return cats
end
function p.main(frame)
    local c = C.context(frame)
    if not c.enabled then return '' end
    local selected = c.option('收集度档位', '')
    local result = D.getCollection(c.name, selected)
    local overall = selected ~= '' and D.getCollection(c.name, '') or result
    local parts = {}
    if result.status == 'error' or overall.status == 'error' then
        return C.finish(c, 'collection', C.heading(c, '这啥?', 3) .. C.diagnostic(result.status == 'error' and result or overall), { '物品数据异常的页面' })
    end
    local cats = classify(overall)
    if result.status == 'none' then return C.categories(c, cats) end
    local entries = result.entries or {}
    if #entries == 0 then
        entries = { { level = 100, status = 'pending' }, { level = 300, status = 'pending' }, { level = 500, status = 'pending' } }
    end
    for _, entry in ipairs(entries) do
        if entry.status == 'known' or (entry.status ~= 'none' and (entry.level == 100 or entry.level == 300)) then
            local text = entry.status == 'known' and C.literal(entry.text) or '具体信息还不是很清楚,多收集几个试试?<sup>[待完善]</sup>'
            parts[#parts + 1] = '<table class="wikitable mw-collapsible mw-collapsed wum-item-collection-entry">\n<tr><th class="wum-item-collection-heading">收集度达到' .. entry.level .. '%</th></tr>\n<tr><td class="wum-item-literal">' .. text .. '</td></tr>\n</table>'
        end
    end
    if #parts == 0 then return C.categories(c, cats) end
    return C.finish(c, 'collection', C.heading(c, '这啥?', 3) .. table.concat(parts, '\n'), cats)
end
return p