模块:LevelInfo:修订间差异
外观
Jathon15201(留言 | 贡献) 无编辑摘要 |
Jathon15201(留言 | 贡献) 无编辑摘要 |
||
| 第68行: | 第68行: | ||
-- ["1-1"] = "1.0", | -- ["1-1"] = "1.0", | ||
} | } | ||
-- 图片数据 | |||
local imgs = { | |||
["1-1"] = "1-1", | |||
["1-1A"] = "1-1", | |||
} | |||
local imgd2s = { | |||
-- ["1-1"] = "1-1d2", | |||
} | |||
local imgd3s = { | |||
-- ["1-1"] = "1-1d3", | |||
} | |||
local imgd4s = { | |||
-- ["1-1"] = "1-1d4", | |||
} | |||
local imgd5s = { | |||
-- ["1-1"] = "1-1d5", | |||
} | |||
local imgd6s = { | |||
-- ["1-1"] = "1-1d6", | |||
} | |||
-- =================================== | |||
local function getValue(tbl, key, default) | local function getValue(tbl, key, default) | ||
| 第109行: | 第136行: | ||
hpmultiplier = getValue(hpmultipliers, pageKey, nil), | hpmultiplier = getValue(hpmultipliers, pageKey, nil), | ||
} | } | ||
-- 图片处理 | |||
local mainImg = getValue(imgs, pageKey, nil) | |||
local d2 = getValue(imgd2s, pageKey, nil) | |||
local d3 = getValue(imgd3s, pageKey, nil) | |||
local d4 = getValue(imgd4s, pageKey, nil) | |||
local d5 = getValue(imgd5s, pageKey, nil) | |||
local d6 = getValue(imgd6s, pageKey, nil) | |||
local imageWikitext = "" | |||
if mainImg then | |||
local hasExtra = d2 or d3 or d4 or d5 or d6 | |||
if not hasExtra then | |||
-- 直接插入第一张图 | |||
imageWikitext = "[[File:" .. mainImg .. ".png]]" | |||
else | |||
-- 有多张图,构建表格 | |||
local tbl = {} | |||
table.insert(tbl, '{| class="wikitable mw-collapsible" style="text-align:center;"') | |||
-- Day 1 | |||
table.insert(tbl, "|-\n| Day 1") | |||
table.insert(tbl, "|-\n| [[File:" .. mainImg .. ".png]]") | |||
local extras = { | |||
{2, d2}, | |||
{3, d3}, | |||
{4, d4}, | |||
{5, d5}, | |||
{6, d6}, | |||
} | |||
for _, item in ipairs(extras) do | |||
local dayNum = item[1] | |||
local img = item[2] | |||
if img then | |||
table.insert(tbl, "|-\n| Day " .. dayNum) | |||
table.insert(tbl, "|-\n| [[File:" .. img .. ".png]]") | |||
end | |||
end | |||
table.insert(tbl, "|}") | |||
imageWikitext = table.concat(tbl, "\n") | |||
end | |||
end | |||
-- =================================== | |||
-- wikitext | -- wikitext | ||
local lines = {} | local lines = {} | ||
-- table.insert(lines, "== " .. pageKey .. " " .. data.name .. " ==") | |||
if imageWikitext ~= "" then | |||
table.insert(lines, imageWikitext) | |||
end | |||
table.insert(lines, "游戏模式: " .. data.gamemode) | table.insert(lines, "游戏模式: " .. data.gamemode) | ||
2026年6月29日 (一) 08:51的版本
local p = {}
-- 数据定义
local names = {
["1-1"] = "日光之塔",
["1-1A"] = "(日光之塔)",
}
local challenges = {
["1-1"] = "0",
["1-1A"] = "1",
}
local belongstos = {
["1-1A"] = "1-1",
}
local rewards = {
["1-1"] = "金矿",
}
local gamemodes = {
["1-1"] = "经典模式",
["1-1A"] = "固定选卡模式",
}
local gametimes = {
["1-1"] = "1",
["1-1A"] = "1",
}
local startgolds = {
["1-1"] = "260",
["1-1A"] = "300",
}
local startcrystals = {
["1-1"] = "0",
["1-1A"] = "15",
}
local sizexs = {
["1-1"] = "29",
["1-1A"] = "29",
}
local sizeys = {
["1-1"] = "13",
["1-1A"] = "13",
}
local goldores = {
["1-1"] = "0",
["1-1A"] = "0",
}
local crystalores = {
["1-1"] = "0",
["1-1A"] = "0",
}
-- 可选属性
local hpmultipliers = {
-- ["1-1"] = "1.0",
}
-- 图片数据
local imgs = {
["1-1"] = "1-1",
["1-1A"] = "1-1",
}
local imgd2s = {
-- ["1-1"] = "1-1d2",
}
local imgd3s = {
-- ["1-1"] = "1-1d3",
}
local imgd4s = {
-- ["1-1"] = "1-1d4",
}
local imgd5s = {
-- ["1-1"] = "1-1d5",
}
local imgd6s = {
-- ["1-1"] = "1-1d6",
}
-- ===================================
local function getValue(tbl, key, default)
local v = tbl[key]
if v == nil then
return default
end
return v
end
-- wikitext
function p.render(frame)
-- 获取当前页面标题
local title = mw.title.getCurrentTitle()
if not title then
return "错误:无法获取当前页面标题。"
end
local pageKey = title.prefixedText
-- 检查是否存在
if names[pageKey] == nil then
return "该关卡暂无信息(" .. pageKey .. " 未配置)。"
end
-- 组装属性
local data = {
name = getValue(names, pageKey, "未知"),
challenge = getValue(challenges, pageKey, "未知"),
belongsto = getValue(belongstos, pageKey, nil),
reward = getValue(rewards, pageKey, nil),
gamemode = getValue(gamemodes, pageKey, "未知"),
gametime = getValue(gametimes, pageKey, "未知"),
startgold = getValue(startgolds, pageKey, "未知"),
startcrystal = getValue(startcrystals, pageKey, "未知"),
sizex = getValue(sizexs, pageKey, "未知"),
sizey = getValue(sizeys, pageKey, "未知"),
goldore = getValue(goldores, pageKey, "未知"),
crystalore = getValue(crystalores, pageKey, "未知"),
hpmultiplier = getValue(hpmultipliers, pageKey, nil),
}
-- 图片处理
local mainImg = getValue(imgs, pageKey, nil)
local d2 = getValue(imgd2s, pageKey, nil)
local d3 = getValue(imgd3s, pageKey, nil)
local d4 = getValue(imgd4s, pageKey, nil)
local d5 = getValue(imgd5s, pageKey, nil)
local d6 = getValue(imgd6s, pageKey, nil)
local imageWikitext = ""
if mainImg then
local hasExtra = d2 or d3 or d4 or d5 or d6
if not hasExtra then
-- 直接插入第一张图
imageWikitext = "[[File:" .. mainImg .. ".png]]"
else
-- 有多张图,构建表格
local tbl = {}
table.insert(tbl, '{| class="wikitable mw-collapsible" style="text-align:center;"')
-- Day 1
table.insert(tbl, "|-\n| Day 1")
table.insert(tbl, "|-\n| [[File:" .. mainImg .. ".png]]")
local extras = {
{2, d2},
{3, d3},
{4, d4},
{5, d5},
{6, d6},
}
for _, item in ipairs(extras) do
local dayNum = item[1]
local img = item[2]
if img then
table.insert(tbl, "|-\n| Day " .. dayNum)
table.insert(tbl, "|-\n| [[File:" .. img .. ".png]]")
end
end
table.insert(tbl, "|}")
imageWikitext = table.concat(tbl, "\n")
end
end
-- ===================================
-- wikitext
local lines = {}
-- table.insert(lines, "== " .. pageKey .. " " .. data.name .. " ==")
if imageWikitext ~= "" then
table.insert(lines, imageWikitext)
end
table.insert(lines, "游戏模式: " .. data.gamemode)
table.insert(lines, "关卡时长: 共 " .. data.gametime .. "天")
table.insert(lines, "初始资源: {{gc|" .. data.startgold .. "|" .. data.startcrystal .. "}}")
table.insert(lines, "金矿矿地: {{c|g|" .. data.goldore .. "}}")
table.insert(lines, "水晶矿矿地: {{c|c|" .. data.crystalore .. "}}")
table.insert(lines, "关卡大小: " .. data.sizex .. " * " .. data.sizey)
if data.hpmultiplier then
table.insert(lines, "关内倍率: " .. data.hpmultiplier)
end
-- 用换行符连接
return frame:preprocess(table.concat(lines, "\n\n"))
end
return p