跳转到内容

模块:LevelInfo

来自Minimalist Tower Defense Wiki
Jathon15201​(留言 | 贡献)2026年6月25日 (四) 14:03的版本 (创建页面,内容为“ local p = {} -- 数据定义 local levelData = { ["1-1"] = { name = "日光之塔", challenge = "0", gamemode = "经典模式", gametime = "1", startgold = "260", startcrystal = "0", sizex = "29", sizey = "13", goldore = "0", crystalore = "0" }, ["1-1A"] = { name = "(日光之塔)", challenge = "1", gamemode = "固定选卡模式", game…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

见Template:LevelInfo。



local p = {}

-- 数据定义

local levelData = {
    ["1-1"] = {
        name = "日光之塔",
        challenge = "0",
        gamemode = "经典模式",
        gametime = "1",
        startgold = "260",
        startcrystal = "0",
        sizex = "29",
        sizey = "13",
        goldore = "0",
        crystalore = "0"
    },
    ["1-1A"] = {
        name = "(日光之塔)",
        challenge = "1",
        gamemode = "固定选卡模式",
        gametime = "1",
        startgold = "300",
        startcrystal = "15",
        sizex = "29",
        sizey = "13",
        goldore = "0",
        crystalore = "0"
    },
}

-- wikitext

function p.render(frame)
    -- 获取当前页面标题
    local title = mw.title.getCurrentTitle()
    if not title then
        return "错误:无法获取当前页面标题。"
    end

    local pageKey = title.prefixedText
    local data = levelData[pageKey]

    if not data then
        return "该关卡暂无信息(" .. pageKey .. " 未配置)。"
    end

    -- 构建wikitext
    local lines = {}
    -- table.insert(lines, "== " .. pageKey .. " " .. data.name .. " ==")
    table.insert(lines, "游戏模式: " .. (data.gamemode or "未知"))
    table.insert(lines, "关卡时长: 共 " .. (data.gametime or "未知") .. "天")
    table.insert(lines, "初始资源: {{gc|" .. (data.startgold or "未知") .. "|" .. (data.startcrystal or "未知") .. "}}")
    table.insert(lines, "金矿矿地: {{c|g|" .. (data.goldore or "未知") .. "}}")
    table.insert(lines, "水晶矿矿地: {{c|c|" .. (data.crystalore or "未知") .. "}}")
    table.insert(lines, "关卡大小: " .. (data.sizex or "未知") .. " * " .. (data.sizey or "未知"))
    
    -- 可选字段
    if data.hpmultiplier then
        table.insert(lines, "关内倍率: " .. data.hpmultiplier)
    end

    -- 用换行符连接
    return frame:preprocess(table.concat(lines, "\n\n"))
end

return p