2023年政策修订增补工作正在进行中,欢迎参与!
Module:Pokemon Game
跳转到导航
跳转到搜索
local p = {}
local getArgs = require('Module:Arguments').getArgs
local data = require('Module:Pokemon Game/Data')
function p._link(frame, args)
local showpokemon = false
local output = {}
local error = {}
for _, v in ipairs(args) do
v = string.upper(v)
if data.keywords[v] then
if data.keywords[v] == "Pokemon" then
showpokemon = true
end
elseif data.games[v] then
if type(data.games[v][1]) == "table" then
for k2, v2 in ipairs(data.games[v][1]) do
if #output > 0 and output[#output][1] == v2 then
output[#output][2] = output[#output][2] + data.separator + (data.games[v][2] or data.games[v][1])[k2]
else
table.insert(output, {v2, (data.games[v][2] or data.games[v][1])[k2], prefix = (data.games[v].prefix or ""), series = (data.games[v].series or "")})
end
end
else
if #output > 0 and output[#output][1] == data.games[v][1] then
output[#output][2] = output[#output][2] .. data.separator .. (data.games[v][2] or data.games[v][1])
else
table.insert(output, {data.games[v][1], data.games[v][2] or data.games[v][1], prefix = (data.games[v].prefix or ""), series = (data.games[v].series or "")})
end
end
else
table.insert(error, v)
end
end
local outputstring = ""
for k, v in ipairs(output) do
outputstring = outputstring .. "[[" .. (v.series ~= "" and v.series or (v.prefix .. data.series)) .. v[1] .. "|" .. (showpokemon and (v.series ~= "" and v.series or (v.prefix .. data.series)) or "") .. v[2] .. "]]"
showpokemon = false
if k ~= #output then
outputstring = outputstring .. data.separator
end
end
return outputstring
end
function p.link(frame)
return p._link(frame, getArgs(frame, {wrappers = "Template:Pokemon Game"}))
end
return p