Jump to navigation
Jump to search
Documentation for this module may be created at Module:Pokemon/Ranger/Documentation
local getArgs = require('Module:Arguments').getArgs
local data = mw.loadJsonData( 'Module:Pokemon Ranger/Browser.json' )
local p = {}
local shortname = {
["Pokémon Ranger"] = "Pokemon Ranger",
["Pokémon Ranger: Shadows of Almia"] = "Pokemon Ranger SoA",
["Pokémon Ranger: Guardian Signs"] = "Pokemon Ranger GS",
}
local function _capture( args, frame )
local guide = "Pokémon Ranger"
local root = mw.html.create( 'table' )
:addClass( 'wikitable mid-table' )
:css( 'text-align', 'center' )
local row = root:tag( 'tr' )
row:tag( 'th' ):wikitext( "Pokémon" )
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Loops" )
local monData = {}
local row = {}
for i,v in ipairs(args) do
monData = data[guide][v]
row = root:tag( 'tr' )
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[Pokémon Ranger/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
if monData.move == "None" then
move = "None"
elseif monData.rating == "1" then
move = monData.move
else
move = monData.move .. " " .. monData.rating
end
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. move .. ' ' .. "Icon" .. ".png|" .. move .. "]]")
row:tag( 'td' ):wikitext( monData.assist )
row:tag( 'td' ):wikitext( monData.loops )
end
return tostring( root )
end
function p.browser( frame )
local guide = mw.title.getCurrentTitle().rootText
mons = data[ guide ]
local root = mw.html.create( 'table' )
:addClass( 'wikitable mid-table sortable' )
:css( 'text-align', 'center' )
local row = root:tag( 'tr' )
row:tag( 'th' ):wikitext( "#" )
row:tag( 'th' ):wikitext( "Image" )
row:tag( 'th' ):wikitext( "Name" )
row:tag( 'th' ):wikitext( "Group" )
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Loops" )
local nums = {}
for k in pairs(mons) do
table.insert(nums, k)
end
table.sort(nums)
for i = 1, #nums do
local k, t = nums[i], mons[ nums[i] ]
local row = root:tag( 'tr' )
row:tag( 'td' ):wikitext( k ):css( 'line-height', '40px' )
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. t.name .. ".png|" .. t.name .. "]]" )
row:tag( 'td' ):wikitext( frame:expandTemplate{ title = 'a', args = { t.name, frame:expandTemplate{ title = 'bp', args = { t.name } } } } ):css( 'text-align', 'left' )
row:tag( 'td' ):wikitext( t.group )
if t.move == "None" then
move = "None"
elseif t.rating == "1" then
move = t.move
else
move = t.move .. " " .. t.rating
end
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( t.assist )
row:tag( 'td' ):wikitext( t.loops )
end
return tostring( root )
end
function p.capture( frame )
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Capture' } )
return _capture( args, frame )
end
return p