Jump to navigation
Jump to search
(Added arena table) Tags: Mobile edit Mobile web edit |
(drop loops from Pokémon Ranger/Browser) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 25: | Line 25: | ||
end | end | ||
end | end | ||
return out | return out | ||
end | end | ||
Line 32: | Line 32: | ||
local guide = mw.title.getCurrentTitle().rootText | local guide = mw.title.getCurrentTitle().rootText | ||
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' ) | local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' ) | ||
local form = Nil | |||
local formText = "" | |||
local root = mw.html.create( 'table' ) | local root = mw.html.create( 'table' ) | ||
:addClass( 'wikitable mid-table' ) | :addClass( 'wikitable mid-table' ) | ||
Line 44: | Line 46: | ||
end | end | ||
for i, v in ipairs( args ) do | for i, v in ipairs( args ) do | ||
if #v > 5 then | |||
form = v:sub(-1, -1) | |||
v = v:sub(1, -2) | |||
end | |||
local monData = {} | local monData = {} | ||
if data["browser"][v] then | if data["browser"][v] then | ||
Line 56: | Line 63: | ||
prefix = shortname[guide] | prefix = shortname[guide] | ||
end | end | ||
row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' ) | if form then | ||
formText = " (" .. monData.forms[form] .. ")" | |||
end | |||
row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' .. formText ) | |||
move = _move( guide, monData.move, monData.rating ) | move = _move( guide, monData.move, monData.rating ) | ||
row:tag( 'td' ):wikitext( move ) | row:tag( 'td' ):wikitext( move ) | ||
Line 64: | Line 74: | ||
loops = monData.loops2 | loops = monData.loops2 | ||
else | else | ||
loops = monData.loops | if form then | ||
loops = monData.loops[form] | |||
else | |||
loops = monData.loops | |||
end | |||
end | end | ||
row:tag( 'td' ):wikitext ( loops ) | row:tag( 'td' ):wikitext ( loops ) | ||
Line 113: | Line 127: | ||
row:tag( 'th' ):wikitext( "Field Move" ) | row:tag( 'th' ):wikitext( "Field Move" ) | ||
row:tag( 'th' ):wikitext( "Poké Assist" ) | row:tag( 'th' ):wikitext( "Poké Assist" ) | ||
local nums = {} | local nums = {} | ||
Line 141: | Line 152: | ||
row:tag( 'td' ):wikitext( move ) | row:tag( 'td' ):wikitext( move ) | ||
row:tag( 'td' ):wikitext( v.assist ) | row:tag( 'td' ):wikitext( v.assist ) | ||
end | end | ||
Line 149: | Line 157: | ||
end | end | ||
function p.arena() | |||
local guide = mw.title.getCurrentTitle().rootText | local guide = mw.title.getCurrentTitle().rootText | ||
local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' ) | local data = mw.loadJsonData( 'Module:Pokemon/' .. string.sub( shortname[ guide ], 9 ) .. '.json' ) | ||
Line 155: | Line 163: | ||
:addClass( 'wikitable mid-table' ) | :addClass( 'wikitable mid-table' ) | ||
:css( 'text-align', 'center' ) | :css( 'text-align', 'center' ) | ||
local row = root:tag( 'tr' ) | local row = root:tag( 'tr' ) | ||
row:tag( 'th' ):wikitext( "Pokémon" ) | row:tag( 'th' ):wikitext( "Pokémon" ) | ||
Line 161: | Line 169: | ||
row:tag( 'th' ):wikitext( "Points" ) | row:tag( 'th' ):wikitext( "Points" ) | ||
row:tag( 'th' ):wikitext( "Loops" ) | row:tag( 'th' ):wikitext( "Loops" ) | ||
for level, k in ipairs(data[ "arena" ]) do | |||
root:tag( 'tr' ):tag( 'td' ) | |||
for | |||
:attr( 'colspan', 4 ) | :attr( 'colspan', 4 ) | ||
:css( 'text-align', 'center' ) | :css( 'text-align', 'center' ) | ||
:css( { ['background-color'] = '#317103', color = 'white' } ) | :css( { ['background-color'] = '#317103', color = 'white' } ) | ||
:wikitext( | :wikitext( "Level " .. level ) | ||
for j,v in | for j, v in ipairs( data[ "arena" ][ level ] ) do | ||
local monData = data[ "browser" ][ | local monData = data[ "browser" ][ v[ "#" ] ] | ||
local row = root:tag( 'tr' ) | 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( "[[File:" .. shortname[ guide ] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' ) | ||
if v.requirement then | if v.requirement then | ||
row:tag( 'td' ):wikitext( v.requirement ) | row:tag( 'td' ):wikitext( v.requirement ) | ||
Line 195: | Line 191: | ||
end | end | ||
end | end | ||
return tostring( root ) | return tostring( root ) | ||
end | end | ||
function p.browser( frame ) | function p.browser( frame ) |
Latest revision as of 21:40, 22 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 form = Nil
local formText = ""
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
if #v > 5 then
form = v:sub(-1, -1)
v = v:sub(1, -2)
end
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
if form then
formText = " (" .. monData.forms[form] .. ")"
end
row:tag( 'td' ):wikitext( "[[File:" .. prefix .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' .. formText )
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
if form then
loops = monData.loops[form]
else
loops = monData.loops
end
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' )
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" )
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 )
end
return tostring( root )
end
function p.arena()
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 level, k in ipairs(data[ "arena" ]) do
root:tag( 'tr' ):tag( 'td' )
:attr( 'colspan', 4 )
:css( 'text-align', 'center' )
:css( { ['background-color'] = '#317103', color = 'white' } )
:wikitext( "Level " .. level )
for j, v in ipairs( data[ "arena" ][ level ] ) do
local monData = data[ "browser" ][ v[ "#" ] ]
local row = root:tag( 'tr' )
row:tag( 'td' ):wikitext( "[[File:" .. shortname[ guide ] .. ' ' .. monData.name .. ".png|" .. monData.name .. "]]" .. " " .. '[[' .. guide .. '/Browser#'.. monData.name .. '|' .. monData.name .. ']]' )
if v.requirement then
row:tag( 'td' ):wikitext( v.requirement )
else
row:tag( 'td' ):wikitext( "None" )
end
row:tag( 'td' ):wikitext( v.points )
row:tag( 'td' ):wikitext( monData.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