跳转到内容

模块:物品合成:修订间差异

来自Wymbot 共创站
NotBot​(留言 | 贡献)
建立模块化物品展示及用户提供的测试数据(不迁移旧掉落)
 
NotBot​(留言 | 贡献)
等级1不显示合成等级提示;等级可空,合成增加收集度空值默认30;省略JSON默认值并同步文档
 
(未显示同一用户的2个中间版本)
第8行: 第8行:
     local body = C.heading(c, '怎么合成?')
     local body = C.heading(c, '怎么合成?')
     if result.status == 'error' then body = body .. C.diagnostic(result); cats = { '物品数据异常的页面' }
     if result.status == 'error' then body = body .. C.diagnostic(result); cats = { '物品数据异常的页面' }
     elseif result.status == 'pending' then body = body .. '合成数据待补充。'
     elseif result.status ~= 'known' then body = body .. '这东西能合成???'
    elseif result.status == 'none' then body = body .. '已确认此物品不能通过合成获得。'
     else
     else
         cats = { '能够合成的物品' }
         cats = { '能够合成的物品' }
         local parts = {}
         local parts = {}
         for _, recipe in ipairs(result.recipes) do
         for _, recipe in ipairs(result.recipes) do
             local ingredients = {}
             local text = C.literal(c.name) .. (recipe.quantity == 1 and '' or ('x' .. recipe.quantity)) .. '='
             for _, material in ipairs(recipe.materials) do ingredients[#ingredients + 1] = C.link(material.name) .. ' × ' .. material.quantity end
             for _, material in ipairs(recipe.materials) do
            local text = C.literal(c.name) .. ' × ' .. recipe.quantity .. ' ← ' .. table.concat(ingredients, ' + ')
                text = text .. '<br>' .. C.link(material.name) .. 'x' .. material.quantity ..
             if recipe.level ~= nil then text = text .. '\n\n合成等级要求:' .. recipe.level .. '。' end
                    (material.quantity == 0 and '(需持有)' or '')
             if recipe.info and recipe.info ~= '' and recipe.info ~= '无' then text = text .. '\n\n' .. C.literal(recipe.info) end
            end
            if recipe.info == '无' then text = text .. '<br>此物品的合成信息待补充。'
             elseif recipe.info and recipe.info ~= '' then text = text .. "<br>'''" .. C.literal(recipe.info) .. "'''" end
             if c.kind == '装备' and recipe.level ~= nil and recipe.level > 1 then
                text = text .. '<br>合成此装备需要达到' .. recipe.level .. '级。'
            end
             parts[#parts + 1] = text
             parts[#parts + 1] = text
         end
         end

2026年10月25日 (日) 12:12的最新版本

此模块的文档可以在模块:物品合成/doc创建

local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
function p.main(frame)
    local c = C.context(frame)
    if not c.enabled then return '' end
    local result, cats = D.getRecipes(c.name), {}
    local body = C.heading(c, '怎么合成?')
    if result.status == 'error' then body = body .. C.diagnostic(result); cats = { '物品数据异常的页面' }
    elseif result.status ~= 'known' then body = body .. '这东西能合成???'
    else
        cats = { '能够合成的物品' }
        local parts = {}
        for _, recipe in ipairs(result.recipes) do
            local text = C.literal(c.name) .. (recipe.quantity == 1 and '' or ('x' .. recipe.quantity)) .. '&#61;'
            for _, material in ipairs(recipe.materials) do
                text = text .. '<br>' .. C.link(material.name) .. 'x' .. material.quantity ..
                    (material.quantity == 0 and '(需持有)' or '')
            end
            if recipe.info == '无' then text = text .. '<br>此物品的合成信息待补充。'
            elseif recipe.info and recipe.info ~= '' then text = text .. "<br>'''" .. C.literal(recipe.info) .. "'''" end
            if c.kind == '装备' and recipe.level ~= nil and recipe.level > 1 then
                text = text .. '<br>合成此装备需要达到' .. recipe.level .. '级。'
            end
            parts[#parts + 1] = text
        end
        body = body .. table.concat(parts, '\n\n')
    end
    return C.finish(c, 'recipes', body, cats)
end
return p