Module:Pokemon/Ranger: Difference between revisions

From StrategyWiki, the video game walkthrough and strategy guide wiki
added Challenge function
(Made Browser link for all Ranger games)
Tags: Mobile edit Mobile web edit
(added Challenge function)
Tags: Mobile edit Mobile web edit
Line 38: Line 38:
return tostring( root )
return tostring( root )
end
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[ 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( monData.requirement )
row:tag( 'td' ):wikitext( monData.points )
row:tag( 'td' ):wikitext( monData.loops )
end
return tostring( root )
end


function p.browser( frame )
function p.browser( frame )
Line 91: Line 116:


return _capture( args )
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
end


return p
return p
4,339

edits