模块:物品来源
外观
此模块的文档可以在模块:物品来源/doc创建
local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
local categories = { travel = '能通过旅行获取的物品', planting = '能通过种菜获取的物品', shop = '能通过超市获取的物品', other = '有其他获取方式的物品' }
local labels = { travel = '旅行', planting = '种植', shop = '超市', other = '其他' }
function p.main(frame)
local c = C.context(frame)
if not c.enabled then return '' end
local result, rows, cats = D.getSources(c.name), {}, {}
local other = c.text('其他方式')
for _, entry in ipairs(result.entries or {}) do
if not (entry.kind == 'other' and other) then
local text = entry.target and C.link(entry.target, entry.label) or C.literal(entry.label)
if entry.probabilityStatus then text = text .. '(掉落概率:' .. C.probability(entry) .. ')' end
if entry.note then text = text .. '(' .. C.literal(entry.note) .. ')' end
rows[#rows + 1] = '|-\n| ' .. (labels[entry.kind] or '其他') .. ' || ' .. text
if categories[entry.kind] then cats[#cats + 1] = categories[entry.kind] end
end
end
if other then rows[#rows + 1] = '|-\n| 其他 ||\n' .. other; cats[#cats + 1] = categories.other end
local body = C.heading(c, '在哪掉的?')
if result.status == 'error' then body = body .. C.diagnostic(result) .. '\n'; cats[#cats + 1] = '物品数据异常的页面' end
if result.status == 'pending' then body = body .. '获取途径数据待接入。\n' end
if result.status == 'none' and #rows == 0 then body = body .. '已确认没有所列获取途径。\n' end
if #rows > 0 then body = body .. '{| class="wikitable wum-item-table"\n! 获取途径 !! 说明\n' .. table.concat(rows, '\n') .. '\n|}' end
return C.finish(c, 'sources', body, cats)
end
return p