模块:物品来源:修订间差异
外观
将超市可购买信息独立存储于模板空间,保留物品来源查询;机制页不修改 |
无编辑摘要 |
||
| (未显示1个用户的2个中间版本) | |||
| 第23行: | 第23行: | ||
local planting = #groups.planting > 0 and table.concat(groups.planting, '、') or | local planting = #groups.planting > 0 and table.concat(groups.planting, '、') or | ||
(#groups.travel > 0 and '他妈,种菜不掉这个!' or '他妈,种菜也不掉这个!') | (#groups.travel > 0 and '他妈,种菜不掉这个!' or '他妈,种菜也不掉这个!') | ||
local otherText = #groups.other > 0 and table.concat(groups.other, '、') or '你觉得还有其他方式?' | |||
local otherPrefix = C.trim(otherText) | |||
local separator = (otherPrefix:sub(1, 2) == '{|' or otherPrefix:match('^[*#;:=]')) and '\n' or ' ' | |||
rows = { | rows = { | ||
'|-\n| 旅行 || ' .. travel, | '|-\n| 旅行 || ' .. travel, | ||
'|-\n| 种菜 || ' .. planting, | '|-\n| 种菜 || ' .. planting, | ||
'|-\n| [[SB洪超市]] || ' .. (#groups.shop > 0 and table.concat(groups.shop, '、') or '他妈,超市还卖这个?'), | '|-\n| [[SB洪超市]] || ' .. (#groups.shop > 0 and table.concat(groups.shop, '、') or '他妈,超市还卖这个?'), | ||
'|-\n| 其他 || | '|-\n| 其他 || class="wum-item-other" |' .. separator .. otherText | ||
} | } | ||
local fishing = D.getFishingSources(c.name) | |||
if fishing.enabled then | |||
local links = {} | |||
for _, entry in ipairs(fishing.entries or {}) do | |||
local link = C.link(entry.target, entry.label, entry.fragment) | |||
if entry.note then link = link .. '(' .. C.literal(entry.note) .. ')' end | |||
links[#links + 1] = link | |||
end | |||
local text = fishing.status == 'error' and C.diagnostic(fishing) or (#links > 0 and table.concat(links, '、') or '他妈,钓鱼还是不掉这个!') | |||
table.insert(rows, 3, '|-\n| 钓鱼 || ' .. text) | |||
end | |||
local body = C.heading(c, '在哪掉的?') | local body = C.heading(c, '在哪掉的?') | ||
if result.status == 'error' then body = body .. C.diagnostic(result) .. '\n'; cats[#cats + 1] = '物品数据异常的页面' end | if result.status == 'error' then body = body .. C.diagnostic(result) .. '\n'; cats[#cats + 1] = '物品数据异常的页面' end | ||
2026年11月17日 (二) 12:53的最新版本
此模块的文档可以在模块:物品来源/doc创建
local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
local categories = { 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 groups = { travel = {}, planting = {}, shop = {}, other = {} }
local other = c.text('其他方式')
for _, entry in ipairs(result.entries or {}) do
if groups[entry.kind] and not (entry.kind == 'other' and other) then
local text = entry.target and C.link(entry.target, entry.label) or C.literal(entry.label)
-- Item acquisition lists never display probabilities, including unknown ones.
if entry.kind == 'shop' and entry.label == 'SB洪超市' then text = C.literal(entry.availability or '能') end
if entry.note then text = text .. '(' .. C.literal(entry.note) .. ')' end
groups[entry.kind][#groups[entry.kind] + 1] = text
if categories[entry.kind] then cats[#cats + 1] = categories[entry.kind] end
end
end
if other then groups.other = { other }; cats[#cats + 1] = categories.other end
local travel = #groups.travel > 0 and table.concat(groups.travel, '、') or '他妈,旅行不掉这个!'
local planting = #groups.planting > 0 and table.concat(groups.planting, '、') or
(#groups.travel > 0 and '他妈,种菜不掉这个!' or '他妈,种菜也不掉这个!')
local otherText = #groups.other > 0 and table.concat(groups.other, '、') or '你觉得还有其他方式?'
local otherPrefix = C.trim(otherText)
local separator = (otherPrefix:sub(1, 2) == '{|' or otherPrefix:match('^[*#;:=]')) and '\n' or ' '
rows = {
'|-\n| 旅行 || ' .. travel,
'|-\n| 种菜 || ' .. planting,
'|-\n| [[SB洪超市]] || ' .. (#groups.shop > 0 and table.concat(groups.shop, '、') or '他妈,超市还卖这个?'),
'|-\n| 其他 || class="wum-item-other" |' .. separator .. otherText
}
local fishing = D.getFishingSources(c.name)
if fishing.enabled then
local links = {}
for _, entry in ipairs(fishing.entries or {}) do
local link = C.link(entry.target, entry.label, entry.fragment)
if entry.note then link = link .. '(' .. C.literal(entry.note) .. ')' end
links[#links + 1] = link
end
local text = fishing.status == 'error' and C.diagnostic(fishing) or (#links > 0 and table.concat(links, '、') or '他妈,钓鱼还是不掉这个!')
table.insert(rows, 3, '|-\n| 钓鱼 || ' .. text)
end
local body = C.heading(c, '在哪掉的?')
if result.status == 'error' then body = body .. C.diagnostic(result) .. '\n'; cats[#cats + 1] = '物品数据异常的页面' end
body = body .. '{| class="wikitable wum-item-table"\n! 获取途径 !! 能否通过该途径获得\n' .. table.concat(rows, '\n') .. '\n|}'
return C.finish(c, 'sources', body, cats)
end
return p