| 此模块基于Lua语言实现,使用以下模块: |
本模板用于添加各宝可梦的图鉴介绍,不需要任何参数。所有图鉴文本均在Module:Pokedex/Data的子页面维护。
模块中已经预设了第六世代以来的所有游戏,其中《Let's Go! 皮卡丘/Let's Go! 伊布》共用图鉴文本。由于前五世代无官方中文图鉴文本,故未在模板中预留。
模块自带配色,如有修改需求请直接在模块修改。
本模板用于添加各宝可梦的图鉴介绍,不需要任何参数。所有图鉴文本均在[[Module:Pokedex]]的子页面维护。
| 参数 | 描述 | 类型 | 状态 | |||
|---|---|---|---|---|---|---|
| 未指定参数 | ||||||
local p = {}
local getArgs = require('Module:Arguments').getArgs
local pokedexData = {}
local game_versions = {
'XY',
'ORAS',
'SM',
'USUM',
'LPLE',
'SWSH',
'BDSP',
'LA',
'SV',
'ZA',
}
for _, v in ipairs(game_versions) do
local temp = require('Module:Pokedex/Data/' .. v)
for k, v in pairs(temp) do
pokedexData[k] = v
end
end
local colors = {
X = '025da6',
Y = 'ea1a3e',
OR = 'ab2813',
AS = '26649c',
Su = 'ee993c',
Mo = '7dc3e3',
US = 'fa8e00',
UM = '008cd9',
LP = 'f5da26',
LE = 'd4924b',
Sw = '00a1e9',
Sh = 'e5015a',
BD = '009fe5',
SP = 'ff75ac',
LA = '63b671',
Sc = 'f95c4d',
Vi = '5942ba',
ZA = '34b574',
}
local games = {
{ 'X' },
{ 'Y' },
{ 'XY', children = { 'X', 'Y' } },
{ 'OR', alias = { '欧米伽红宝石', '歐米加紅寶石' } },
{ 'AS', alias = { '阿尔法蓝宝石', '阿爾法藍寶石' } },
{ 'ORAS', children = { 'OR', 'AS' } },
{ 'Su', alias = { '太阳', '太陽' } },
{ 'Mo', alias = { '月亮' } },
{ 'SM', children = { 'Su', 'Mo' } },
{ 'US', alias = { '究极之日', '究極之日' } },
{ 'UM', alias = { '究极之月', '究極之月' } },
{ 'USUM', children = { 'US', 'UM' } },
{ 'LPLE', alias = { "Let's Go!" }, children = { 'LP', 'LE' } },
{ 'Sw', alias = { '剑', '劍' } },
{ 'Sh', alias = { '盾' } },
{ 'SWSH', children = { 'Sw', 'Sh' } },
{ 'BD', alias = { '晶灿钻石', '晶燦鑽石' } },
{ 'SP', alias = { '明亮珍珠' } },
{ 'BDSP', children = { 'BD', 'SP' } },
{ 'LA', alias = { '传说 阿尔宙斯', '傳說 阿爾宙斯' } },
{ 'Sc', alias = { '朱' } },
{ 'Vi', alias = { '紫' } },
{ 'SV', children = { 'Sc', 'Vi' } },
{ 'ZA' },
}
local get_text_from_game = function(game, args, name)
local key = game[1]
if pokedexData[key] and pokedexData[key][name] then
local output = {}
local result = pokedexData[key][name]
for _, v in ipairs(result) do
table.insert(output, v[1] .. (#result > 1 and v[2] and '{{ps|' .. v[2] .. '}}' or ''))
end
return table.concat(output, '<hr />')
end
if args[key] and args[key] ~= '' then
return args[key]
end
if game.alias then
for _, alias in ipairs(game.alias) do
if args[alias] and args[alias] ~= '' then
return args[alias]
end
end
end
return ''
end
function p._main(frame, args)
local name = args.name or mw.title.getCurrentTitle().text
local output = {
'{| class="pm-pokedex wikitable" style="text-align: center; min-width: 50%;"',
'|+ ' .. name .. '的图鉴介绍',
}
for _, v in ipairs(games) do
local text = get_text_from_game(v, args, name)
if text ~= '' then
if v.children then
local left = v.children[1]
local right = v.children[2]
table.insert(output,
'|-\n! colspan="6" style="text-align: right; width: 50%; color: #fff; -webkit-text-fill-color: #fff; background-color: #' ..
colors[left] ..
'; " | 《{{Pokemon Game|' .. left ..
'}}\n! colspan="6" style="text-align: left; width: 50%; color: #fff; -webkit-text-fill-color: #fff; background-color: #' ..
colors[right] .. '; " | {{Pokemon Game|' .. right .. '}}》')
else
table.insert(output,
'|-\n! colspan="12" style="color: #fff; -webkit-text-fill-color: #fff; background-color: #' ..
colors[v[1]] ..
'; " | 《{{Pokemon Game|' .. v[1] .. '}}》')
end
table.insert(output, '|-\n| style="text-align: justify; padding: 0.2em;" colspan="12" | ' .. text)
end
end
table.insert(output, '|}')
return frame:preprocess(table.concat(output, '\n'))
end
function p.main(frame)
return p._main(frame, getArgs(frame))
end
return p