From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
(rename json files)
(Adding in mid table headers for capture arena as the Pokémon are divided into different ranks)
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local getArgs = require( 'Module:Arguments' ).getArgs
local p = {}
local p = {}
local shortname = {
local shortname = {
Line 5: Line 7:
["Pokémon Ranger: Guardian Signs"] = "Pokemon Ranger GS",
["Pokémon Ranger: Guardian Signs"] = "Pokemon Ranger GS",
}
}
local function _move( guide, move, rating )
out = ""
if guide == "Pokémon Ranger" then
if move == "None" then
return "None"
else
for j = 1, rating do
out = out .. "[[File:" .. shortname[ guide ] .. ' ' .. move .. ' ' .. "Icon.png|" .. move .. "]] "
end
end
else
if rating == "-" then
out = "[[File:Pokemon Ranger SoA " .. move .. " Icon.png|" .. move .. "]]"
else
out = "[[File:Pokemon Ranger SoA " .. move .. ' ' .. rating .. " Icon.png|" .. move .. ' ' .. rating .. "]]"
end
end
return out
end


local function _capture( args )
local function _capture( args )
Line 17: Line 40:
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Loops" )
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[ guide ][ v ]
local monData = {}
if data["browser"][v] then
monData = data["browser"][v]
else
monData = data["browser-past"][v]
end
local row = root:tag( 'tr' )
local 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.filename then
if monData.move == "None" then
prefix = monData.filename
move = "None"
else
else
move = ""
prefix = shortname[guide]
for j = 1, monData.rating do
move = move .. "[[File:" .. shortname[ guide ] .. ' ' .. monData.move .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
end
end
end
row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
move = _move( guide, monData.move, monData.rating )
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( monData.assist )
row:tag( 'td' ):wikitext( monData.assist )
if guide == "Pokémon Ranger" then
if monData.loops2page == mw.title.getCurrentTitle().text then
loops = monData.loops2
else
loops = monData.loops
end
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' )
if monData == nil then
    root:tag( 'tr' )
:tag( 'td' )
:attr( 'colspan', 4 )
:css( 'text-align', 'center' )
:css( { ['background-color'] = '#317103', color = 'white' } )
:wikitext( v )
end
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 )
row:tag( 'td' ):wikitext( monData.loops )
end
end
Line 39: Line 109:
end
end


function p.browser( frame )
local function _browser( guide, section )
local guide = mw.title.getCurrentTitle().rootText
local frame = mw.getCurrentFrame()
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' )
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' )
mons = data[ guide ]
local root = mw.html.create( 'table' )
local root = mw.html.create( 'table' )
:addClass( 'wikitable mid-table sortable' )
:addClass( 'wikitable mid-table sortable' )
Line 54: Line 123:
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Field Move" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Poké Assist" )
row:tag( 'th' ):wikitext( "Loops" )
if guide == "Pokémon Ranger" then
row:tag( 'th' ):wikitext( "Loops" )
end


local nums = {}
local nums = {}


for k in pairs( mons ) do
for k in pairs( data[ section ] ) do
table.insert( nums, k )
table.insert( nums, k )
end
end
Line 64: Line 135:


for i = 1, #nums do
for i = 1, #nums do
local k, v = nums[ i ], mons[ nums[ i ] ]
local k, v = nums[ i ], data[ section ][ nums[ i ] ]
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', '20px' )
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. v.name .. ".png|" .. v.name .. "]]" )
if v.filename then
prefix = v.filename
else
prefix = shortname[guide]
end
row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. v.name .. ".png|" .. v.name .. "]]" )
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 } } } } )
:css( 'text-align', 'left' )
:css( 'text-align', 'left' )
row:tag( 'td' ):wikitext( v.group )
row:tag( 'td' ):wikitext( v.group )
if v.move == "None" then
move = _move( guide, v.move, v.rating )
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( move )
row:tag( 'td' ):wikitext( v.assist )
row:tag( 'td' ):wikitext( v.assist )
row:tag( 'td' ):wikitext( v.loops )
if guide == "Pokémon Ranger" then
row:tag( 'td' ):wikitext( v.loops )
end
end
end


return tostring( root )
return tostring( root )
end
function p.browser( frame )
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Browser' } )
local guide = mw.title.getCurrentTitle().rootText
local section = args[1] or "browser"
return _browser( guide, section )
end
end


function p.capture( frame )
function p.capture( frame )
local getArgs = require( 'Module:Arguments' ).getArgs
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Capture' } )
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Capture' } )


return _capture( args )
return _capture( args )
end
function p.challenge( frame )
local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Challenge' } )
return _challenge( args )
end
end


return p
return p

Revision as of 00:35, 14 May 2024

Documentation for this module may be created at Module:Pokemon/Ranger/Documentation

local getArgs = require( 'Module:Arguments' ).getArgs

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 _move( guide, move, rating )
	out = ""
	if guide == "Pokémon Ranger" then
		if move == "None" then
			return "None"
		else
			for j = 1, rating do
				out = out .. "[[File:" .. shortname[ guide ] .. ' ' .. move .. ' ' .. "Icon.png|" .. move .. "]] "
			end
		end
	else
		if rating == "-" then
			out = "[[File:Pokemon Ranger SoA " .. move .. " Icon.png|" .. move .. "]]"
		else
			out = "[[File:Pokemon Ranger SoA " .. move .. ' ' .. rating .. " Icon.png|" .. move .. ' ' .. rating .. "]]"
		end
	end
	
	return out
end

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 = {}
		if data["browser"][v] then
			monData = data["browser"][v]
		else
			monData = data["browser-past"][v]
		end
		local row = root:tag( 'tr' )
		if monData.filename then
			prefix = monData.filename
		else
			prefix = shortname[guide]
		end
		row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
		move = _move( guide, monData.move, monData.rating )
		row:tag( 'td' ):wikitext( move )
		row:tag( 'td' ):wikitext( monData.assist )
		if guide == "Pokémon Ranger" then
			if monData.loops2page == mw.title.getCurrentTitle().text then
				loops = monData.loops2
			else
				loops = monData.loops
			end
			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' )
		
		if monData == nil then
    		root:tag( 'tr' )
				:tag( 'td' )
					:attr( 'colspan', 4 )
					:css( 'text-align', 'center' )
					:css( { ['background-color'] = '#317103', color = 'white' } )
					:wikitext( v )
		end
		
		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

local function _browser( guide, section )
	local frame = mw.getCurrentFrame()
	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" )
	if guide == "Pokémon Ranger" then
		row:tag( 'th' ):wikitext( "Loops" )
	end

	local nums = {}

	for k in pairs( data[ section ] ) do
		table.insert( nums, k )
	end
	table.sort( nums )

	for i = 1, #nums do
		local k, v = nums[ i ], data[ section ][ nums[ i ] ]
		local row = root:tag( 'tr' )
		row:tag( 'td' ):wikitext( k ):css( 'line-height', '20px' )
		if v.filename then
			prefix = v.filename
		else
			prefix = shortname[guide]
		end
		row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. v.name .. ".png|" .. v.name .. "]]" )
		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 )
		move = _move( guide, v.move, v.rating )
		row:tag( 'td' ):wikitext( move )
		row:tag( 'td' ):wikitext( v.assist )
		if guide == "Pokémon Ranger" then
			row:tag( 'td' ):wikitext( v.loops )
		end
	end

	return tostring( root )
end

function p.browser( frame )
	local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Browser' } )
	local guide = mw.title.getCurrentTitle().rootText
	local section = args[1] or "browser"

	return _browser( guide, section )
end

function p.capture( frame )
	local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Capture' } )

	return _capture( args )
end

function p.challenge( frame )
	local args = getArgs( frame, { wrappers = 'Template:Pokemon Ranger/Challenge' } )

	return _challenge( args )
end

return p