模块:物品收集度:修订间差异
外观
建立模块化物品展示及用户提供的测试数据(不迁移旧掉落) |
按旧Wiki恢复完整来源表、合成样式和缺省文案;物品来源不显示概率 |
||
| 第27行: | 第27行: | ||
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( | 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' } } | ||
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] = '<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>' | 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 | end | ||
end | end | ||
if #parts == 0 then | 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, '这啥?') .. table.concat(parts, '\n'), cats) | ||
end | end | ||
return p | return p | ||
2026年10月24日 (六) 12:18的版本
此模块的文档可以在模块:物品收集度/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, '这啥?') .. 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] = '<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
end
if #parts == 0 then return C.categories(c, cats) end
return C.finish(c, 'collection', C.heading(c, '这啥?') .. table.concat(parts, '\n'), cats)
end
return p