模块:物品查询:修订间差异
外观
建立模块化物品展示及用户提供的测试数据(不迁移旧掉落) |
上线 drop.json 正式物品、种子与旅行数据;条件转备注,零材料标注需持有 |
||
| (未显示同一用户的1个中间版本) | |||
| 第2行: | 第2行: | ||
local D = require('模块:物品数据') | local D = require('模块:物品数据') | ||
local p = {} | local p = {} | ||
function p.shop(frame) | |||
local c = C.context(frame) | |||
local result = D.getShop(c.option('name', c.option(1, c.name))) | |||
if result.status == 'error' then return C.diagnostic(result) end | |||
return result.status == 'known' and C.literal(result.availability) or '' | |||
end | |||
function p.info(frame) | function p.info(frame) | ||
local c = C.context(frame) | local c = C.context(frame) | ||
| 第26行: | 第32行: | ||
if kind ~= '配方' then return '' end | if kind ~= '配方' then return '' end | ||
local body = C.literal(recipe.name) .. (recipe.quantity == 1 and '' or ('x' .. recipe.quantity)) .. '=' | local body = C.literal(recipe.name) .. (recipe.quantity == 1 and '' or ('x' .. recipe.quantity)) .. '=' | ||
for _, material in ipairs(recipe.materials) do body = body .. '<br>' .. C.link(material.name) .. 'x' .. material.quantity end | for _, material in ipairs(recipe.materials) do | ||
body = body .. '<br>' .. C.link(material.name) .. 'x' .. material.quantity .. | |||
(material.quantity == 0 and '(需持有)' or '') | |||
end | |||
return body | return body | ||
end | end | ||
2026年10月24日 (六) 13:09的最新版本
此模块的文档可以在模块:物品查询/doc创建
local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
function p.shop(frame)
local c = C.context(frame)
local result = D.getShop(c.option('name', c.option(1, c.name)))
if result.status == 'error' then return C.diagnostic(result) end
return result.status == 'known' and C.literal(result.availability) or ''
end
function p.info(frame)
local c = C.context(frame)
local name = c.option('name', c.option(1, c.name))
local level = c.option('num', c.option(2, ''))
if not tonumber(level) then return '' end
local result = D.getCollection(name, level)
if result.status == 'error' then return C.diagnostic(result) end
for _, entry in ipairs(result.entries or {}) do
if entry.status == 'none' then return '无' end
if entry.status == 'known' then return C.literal(entry.text) end
end
return ''
end
function p.recipe(frame)
local c = C.context(frame)
local result = D.getRecipes(c.option('name', c.option(1, c.name)))
if result.status == 'error' then return C.diagnostic(result) end
if result.status ~= 'known' then return '' end
local recipe = result.recipes[1]
local kind = c.option('type', c.option(2, '配方'))
if kind == '等级' then return recipe.level ~= nil and tostring(recipe.level) or '' end
if kind == '信息' then return C.literal(recipe.info or '') end
if kind ~= '配方' then return '' end
local body = C.literal(recipe.name) .. (recipe.quantity == 1 and '' or ('x' .. recipe.quantity)) .. '='
for _, material in ipairs(recipe.materials) do
body = body .. '<br>' .. C.link(material.name) .. 'x' .. material.quantity ..
(material.quantity == 0 and '(需持有)' or '')
end
return body
end
function p.upper(frame)
local c = C.context(frame)
local result = D.getUses(c.option('name', c.option(1, c.name)))
if result.status == 'error' then return C.diagnostic(result) end
if result.status ~= 'known' then return '' end
local links = {}
for _, name in ipairs(result.products) do links[#links + 1] = C.link(name) end
return table.concat(links, '、')
end
return p