From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
(Template renaming)
Tags: Mobile edit Mobile web edit
(Added multiple Icon images if rating is greater than 1)
Tags: Mobile edit Mobile web edit
Line 10: Line 10:


local function _capture( args, frame )
local function _capture( args, frame )
     local guide = "Pokémon Ranger"
     local guide = mw.title.getCurrentTitle().rootText
local root = mw.html.create( 'table' )
local root = mw.html.create( 'table' )
:addClass( 'wikitable mid-table' )
:addClass( 'wikitable mid-table' )
Line 30: Line 30:
move = "None"
move = "None"
elseif monData.rating == "1" then
elseif monData.rating == "1" then
move = monData.move
move = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
else
elseif monData.rating == "2" then
move = monData.move .. " " .. monData.rating
move = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " " .. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
        else
          move = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " " .. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " ".. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
end
end
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. move .. ' ' .. "Icon" .. ".png|" .. move .. "]]")
row:tag( 'td' ):wikitext( move )
row:tag( 'td' ):wikitext( monData.assist )
row:tag( 'td' ):wikitext( monData.assist )
row:tag( 'td' ):wikitext( monData.loops )
row:tag( 'td' ):wikitext( monData.loops )

Revision as of 21:56, 25 April 2024

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 = mw.title.getCurrentTitle().rootText
	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 = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
		elseif monData.rating == "2" then
			move = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " " .. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
        else
           move = "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " " .. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]" .. " ".. "[[File:" .. shortname[ guide ] .. ' ' .. monDatamove .. ' ' .. "Icon" .. ".png|" .. monData.move .. "]]"
		end
		row:tag( 'td' ):wikitext( 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