跳转到内容

模块:地点介绍:修订间差异

来自Wymbot 共创站
NotBot​(留言 | 贡献)
地点hours/distance/experience改为可选,空值不显示对应概况;cost仍必填,同步使用文档
NotBot​(留言 | 贡献)
VisualJSON:地点解锁迁移为 and/or 条件树,支持 use;校正太阳持有条件
 
(未显示同一用户的1个中间版本)
第7行: 第7行:
     local c = P.context(frame)
     local c = P.context(frame)
     if not c.enabled then return '' end
     if not c.enabled then return '' end
     return P.finish(c, 'intro', c.text('介绍', C.literal(c.name) .. '是wymboTrip的一个地点。'))
     local intro = c.text('介绍', C.literal(c.name) .. '是wymboTrip的一个地点。')
end
     local result = D.get(c.name)
 
     local body
function p.overview(frame)
     if result.status == 'error' then body = C.diagnostic(result)
     local c = P.context(frame)
     elseif result.status == 'known' then
    if not c.enabled then return '' end
    local custom = c.text('这啥地方', c.text('地点类型'))
    local result
    if not custom then result = D.get(c.name) end
     local body = custom
     if not body and result.status == 'error' then body = C.diagnostic(result)
     elseif not body and result.status == 'known' then
         local r = result.record
         local r = result.record
         local parts = { '在这里的每次旅行需要消耗' .. C.literal(r.cost) .. '啥币' }
         local parts = { '在这里的每次旅行需要消耗' .. C.literal(r.cost) .. '啥币' }
第25行: 第18行:
         if type(r.experience) == 'number' then parts[#parts + 1] = '经验基数为' .. C.literal(r.experience) end
         if type(r.experience) == 'number' then parts[#parts + 1] = '经验基数为' .. C.literal(r.experience) end
         body = table.concat(parts, ',') .. '。'
         body = table.concat(parts, ',') .. '。'
     elseif not body then body = '他妈,这什么申必地方' end
     else body = '他妈,这什么申必地方' end
     return P.finish(c, 'overview', P.heading(c, '这啥地方?') .. body)
     return P.finish(c, 'intro', intro .. '\n\n' .. body)
end
end


local function sortedKeys(value)
function p.overview(frame)
     local names = {}
     local c = P.context(frame)
    for name in pairs(value or {}) do names[#names + 1] = name end
     if not c.enabled then return '' end
    table.sort(names)
     local body = c.text('地点类型')
    return names
     if not body then return '' end
end
     return P.finish(c, 'overview', P.heading(c, '这啥地方?') .. body)
 
local function requirements(value)
    local pieces = {}
     if value.item then
        local item = C.link(value.item)
        if value.collection then item = item .. '的收集度达到' .. C.literal(value.collection) .. '%'
        else item = item .. 'x' .. C.literal(value.count or 1) end
        pieces[#pieces + 1] = item
    end
     for _, name in ipairs(sortedKeys(value.items)) do
        local r = value.items[name]
        pieces[#pieces + 1] = C.link(name) .. (r.collection and ('的收集度达到' .. C.literal(r.collection) .. '%') or ('x' .. C.literal(r.count or 1)))
     end
    for _, item in ipairs(value.equipment or {}) do pieces[#pieces + 1] = '装备' .. C.link(item) end
     if value.currency == 'sha_coin' and value.amount then pieces[#pieces + 1] = C.literal(value.amount) .. '啥币' end
    return table.concat(pieces, '且')
end
end


local function defaultRoute(record)
local function defaultRoute(result)
     local unlock = record.unlock or {}
     local unlock = result.unlock or { status = 'none', text = '无需解锁' }
    if C.trim(unlock.text) ~= '' then return C.literal(unlock.text) end
     if unlock.status == 'none' then return '无需解锁。' end
    if record.entryDisabled then return '此地点当前不可进入。' end
     return '解锁条件:' .. unlock.text .. '。'
    local alternatives = {}
     for _, option in ipairs(unlock.any_of or {}) do
        local text = requirements(option)
        if text ~= '' then alternatives[#alternatives + 1] = text end
    end
    local direct = requirements(unlock)
    local text = #alternatives > 0 and table.concat(alternatives, ';或') or direct
     text = text ~= '' and ('解锁条件:' .. text .. '。') or '你妈,这地方不用解锁,王畅都能去!'
    local equipment = (record.entryEquipment or {}).any_of or {}
    if #equipment > 0 then
        local links = {}
        for _, name in ipairs(equipment) do links[#links + 1] = C.link(name) end
        text = text .. '<br>进入时需装备' .. table.concat(links, '或') .. '。'
    end
    return text
end
end


第82行: 第44行:
     local body = custom
     local body = custom
     if not body and result.status == 'error' then body = C.diagnostic(result)
     if not body and result.status == 'error' then body = C.diagnostic(result)
     elseif not body then body = defaultRoute(result.record or {}) end
     elseif not body then body = defaultRoute(result) end
     return P.finish(c, 'route', P.heading(c, '怎么去?') .. body)
     return P.finish(c, 'route', P.heading(c, '怎么去?') .. body)
end
end

2026年11月12日 (四) 09:59的最新版本

此模块的文档可以在模块:地点介绍/doc创建

local C = require('模块:物品通用')
local P = require('模块:地点通用')
local D = require('模块:地点数据')
local p = {}

function p.main(frame)
    local c = P.context(frame)
    if not c.enabled then return '' end
    local intro = c.text('介绍', C.literal(c.name) .. '是wymboTrip的一个地点。')
    local result = D.get(c.name)
    local body
    if result.status == 'error' then body = C.diagnostic(result)
    elseif result.status == 'known' then
        local r = result.record
        local parts = { '在这里的每次旅行需要消耗' .. C.literal(r.cost) .. '啥币' }
        if type(r.hours) == 'number' then parts[#parts + 1] = '保底时长为' .. C.literal(r.hours) .. '小时' end
        if type(r.distance) == 'number' then parts[#parts + 1] = '发言基数为' .. C.literal(r.distance) end
        if type(r.experience) == 'number' then parts[#parts + 1] = '经验基数为' .. C.literal(r.experience) end
        body = table.concat(parts, ',') .. '。'
    else body = '他妈,这什么申必地方' end
    return P.finish(c, 'intro', intro .. '\n\n' .. body)
end

function p.overview(frame)
    local c = P.context(frame)
    if not c.enabled then return '' end
    local body = c.text('地点类型')
    if not body then return '' end
    return P.finish(c, 'overview', P.heading(c, '这啥地方?') .. body)
end

local function defaultRoute(result)
    local unlock = result.unlock or { status = 'none', text = '无需解锁' }
    if unlock.status == 'none' then return '无需解锁。' end
    return '解锁条件:' .. unlock.text .. '。'
end

function p.route(frame)
    local c = P.context(frame)
    if not c.enabled then return '' end
    local custom = c.text('怎么去', c.text('解锁方法'))
    local result
    if not custom then result = D.get(c.name) end
    local body = custom
    if not body and result.status == 'error' then body = C.diagnostic(result)
    elseif not body then body = defaultRoute(result) end
    return P.finish(c, 'route', P.heading(c, '怎么去?') .. body)
end

function p.drops(frame)
    local c = P.context(frame)
    if not c.enabled then return '' end
    local body = frame:expandTemplate({ title = '物品产出', args = {
        ['物品名'] = c.name .. '旅行', ['分类'] = '否', ['显示标题'] = '否'
    } })
    if C.trim(body) == '' then return '' end
    return P.finish(c, 'drops', P.heading(c, '这里有啥?') .. body)
end

return p