Jump to navigation
Jump to search
(Fixed second capture loops) Tags: Mobile edit Mobile web edit |
(Removed loops column for sequel games and added sprite checks for sequels if they existed in previous games) Tags: Mobile edit Mobile web edit |
||
Line 17: | Line 17: | ||
row:tag( 'th' ):wikitext( "Field Move" ) | row:tag( 'th' ):wikitext( "Field Move" ) | ||
row:tag( 'th' ):wikitext( "Poké Assist" ) | row:tag( 'th' ):wikitext( "Poké Assist" ) | ||
if guide == "Pokémon Ranger" then | |||
row:tag( 'th' ):wikitext( "Loops" ) | |||
end | |||
for i, v in ipairs( args ) do | for i, v in ipairs( args ) do | ||
local monData = data[ "browser" ][ v ] | local monData = data[ "browser" ][ v ] | ||
local row = root:tag( 'tr' ) | local row = root:tag( 'tr' ) | ||
if monData.filename then | |||
row:tag( 'td' ):wikitext( "[[File:" .. monData.filename .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' ) | |||
else | |||
row:tag( 'td' ):wikitext( "[[File:" .. shortname[guide] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' ) | |||
end | |||
if monData.move == "None" then | if monData.move == "None" then | ||
move = "None" | move = "None" | ||
Line 42: | Line 48: | ||
else | else | ||
loops = monData.loops | loops = monData.loops | ||
end | end | ||
row:tag( 'td' ):wikitext ( loops ) | if guide == "Pokémon Ranger" then | ||
row:tag( 'td' ):wikitext ( loops ) | |||
end | |||
end | end | ||
Line 101: | Line 109: | ||
local row = root:tag( 'tr' ) | local row = root:tag( 'tr' ) | ||
row:tag( 'td' ):wikitext( k ):css( 'line-height', '40px' ) | row:tag( 'td' ):wikitext( k ):css( 'line-height', '40px' ) | ||
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. v.name .. ".png|" .. v.name .. "]]" ) | if v.filename then | ||
row:tag( 'td' ):wikitext( "[[File:" .. v.filename .. ' ' .. v.name .. ".png|" .. v.name .. "]]" ) | |||
else | |||
row:tag( 'td' ):wikitext( "[[File:" .. shortname[guide] .. ' ' .. v.name .. ".png|" .. v.name .. "]]" ) | |||
end | |||
row:tag( 'td' ) | row:tag( 'td' ) | ||
:wikitext( frame:expandTemplate{ title = 'a', args = { v.name, frame:expandTemplate{ title = 'bp', args = { v.name } } } } ) | :wikitext( frame:expandTemplate{ title = 'a', args = { v.name, frame:expandTemplate{ title = 'bp', args = { v.name } } } } ) |
Revision as of 21:25, 8 May 2024
Documentation for this module may be created at Module:Pokemon/Ranger/Documentation
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 )
local guide = mw.title.getCurrentTitle().rootText
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' )
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" )
if guide == "Pokémon Ranger" then
row:tag( 'th' ):wikitext( "Loops" )
end
for i, v in ipairs( args ) do
local monData = data[ "browser" ][ v ]
local row = root:tag( 'tr' )
if monData.filename then
row:tag( 'td' ):wikitext( "[[File:" .. monData.filename .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
else
row:tag( 'td' ):wikitext( "[[File:" .. shortname[guide] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
end
if monData.move == "None" then
move = "None"
else
move = ""
for j = 1, monData.rating do
move = move .. "[[File:" .. shortname[ guide ] .. ' ' .. monData.move .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]] "
end
end
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( monData.assist )
if monData.loops2 then
page = mw.title.getCurrentTitle().text
if monData.loops2page == page then
loops = monData.loops2
else
loops = monData.loops
end
else
loops = monData.loops
end
if guide == "Pokémon Ranger" then
row:tag( 'td' ):wikitext ( loops )
end
end
return tostring( root )
end
local function _challenge( args )
local guide = mw.title.getCurrentTitle().rootText
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' )
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( "Requirements" )
row:tag( 'th' ):wikitext( "Points" )
row:tag( 'th' ):wikitext( "Loops" )
for i, v in ipairs( args ) do
local monData = data[ "browser" ][ v ]
local challengeData = data[ "challenges" ][ v ]
local row = root:tag( 'tr' )
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
row:tag( 'td' ):wikitext( challengeData.requirement )
row:tag( 'td' ):wikitext( challengeData.points )
row:tag( 'td' ):wikitext( monData.loops )
end
return tostring( root )
end
function p.browser( frame )
local guide = mw.title.getCurrentTitle().rootText
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' )
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( data[ "browser" ] ) do
table.insert( nums, k )
end
table.sort( nums )
for i = 1, #nums do
local k, v = nums[ i ], data[ "browser" ][ nums[ i ] ]
local row = root:tag( 'tr' )
row:tag( 'td' ):wikitext( k ):css( 'line-height', '40px' )
if v.filename then
row:tag( 'td' ):wikitext( "[[File:" .. v.filename .. ' ' .. v.name .. ".png|" .. v.name .. "]]" )
else
row:tag( 'td' ):wikitext( "[[File:" .. shortname[guide] .. ' ' .. v.name .. ".png|" .. v.name .. "]]" )
end
row:tag( 'td' )
:wikitext( frame:expandTemplate{ title = 'a', args = { v.name, frame:expandTemplate{ title = 'bp', args = { v.name } } } } )
:css( 'text-align', 'left' )
row:tag( 'td' ):wikitext( v.group )
if v.move == "None" then
move = "None"
elseif v.rating == "1" then
move = v.move
else
move = v.move .. " " .. v.rating
end
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( v.assist )
row:tag( 'td' ):wikitext( v.loops )
end
return tostring( root )
end
function p.capture( frame )
local getArgs = require( 'Module:Arguments' ).getArgs
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Capture' } )
return _capture( args )
end
function p.challenge( frame )
local getArgs = require( 'Module:Arguments' ).getArgs
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Challenge' } )
return _challenge( args )
end
return p