模块:StageNavExpand
可在模块:StageNavExpand/doc创建此模块的帮助文档
local p = {}
local getArgs
local termTable = {
["cond"] = {
{"type", {"活动"}}
},
["result"] = {[0] = "main", "act"},
["next"] = {
[0] = {
["cond"] = {
{"type", {"主线", "支线", "特殊剧情"}},
{"category", {"日常", "模拟", "剿灭", "保全派驻"}},
{"category", {"集成战略"}},
{"category", {"生息演算"}},
},
["result"] = {":main", ":daily", ":is", ":ra"},
},
{
["cond"] = {
{"id", {"a001", "a003", "act5d0", "act9d0", "act11d0", "act12d0", "act13d5", "act15d0", "act16d5", "act17d0", "act18d0"}},
{"id", {"act18d3", "act1[0123456]side"}},
{"id", {"act1[789]side", "act2[01234]side"}},
{"id", {"act2[56789]side", "act3[01234]side"}},
{"id", {"act4d0", "act6d5", "act7d5", "act10d5", "act13d0", "act15d5", "act.-mini"}},
{"category", {"危机合约"}},
{"id", {"act38rune"}},
},
["result"] = {[0] = ":other", ":ss1", ":ss2", ":ss3", ":ss4", ":mini", ":cc", ":cc"},
},
},
}
function stage_match(keyword, condTable)
for k,v in ipairs(condTable) do
if mw.ustring.match(keyword, v) then
return true
end
end
return false
end
function judge(pagename, termTable, resource, cur)
for k, v in ipairs(termTable["cond"]) do
if stage_match(resource[v[1]], v[2]) then
cur = cur .. termTable["result"][k]
if termTable["next"] and termTable["next"][k] then
return judge(pagename, termTable["next"][k], resource, cur)
else
return cur
end
end
end
cur = cur .. (termTable["result"][0] or "")
if termTable["next"] and termTable["next"][0] then
return judge(pagename, termTable["next"][0], resource, cur)
else
return cur
end
end
function p.expand(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local pagename = getArgs(frame)[1]
local resource = {
["type"] = mw.getCurrentFrame():callParserFunction("#show", pagename .. "#普通关卡信息", "?关卡类型"),
["category"] = mw.getCurrentFrame():callParserFunction("#show", pagename, "?分类"),
["id"] = mw.getCurrentFrame():callParserFunction("#show", pagename, "?关卡id"),
}
return judge(pagename, termTable, resource, "")
end
return p