Module:Pokemon/Wild

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

local p = {}

local function createEncounterTable( encounters ) local frame = mw.getCurrentFrame local gameTable = mw.html.create( 'table' ) :addClass('wikitable') :addClass('pkmn-wild') local row = gameTable:tag( 'tr' ) row:tag( 'th' ):wikitext( 'Pokémon' ) row:tag( 'th' ):wikitext( 'Level' ) row:tag( 'th' ) :addClass( 'pkmn-wild-' .. string.lower( encounters.game ) ) :wikitext( frame:expandTemplate{ title = 'Pokemon/Short', args = { encounters.game } } ) for _, mon in ipairs(encounters) do		local rowData = gameTable:tag( 'tr' ) rowData:tag( 'td' ):wikitext( frame:expandTemplate{ title = 'PokePic', args = { mon.name } } .. frame:expandTemplate{ title = 'bp', args = { mon.name } } ) rowData:tag( 'td' ):wikitext( mon.level ) rowData:tag( 'td' ) :addClass( "pkmn-wild-" .. string.lower( encounters.game ) ) :wikitext( mon.rate .. "%" ) end return gameTable end

local function _wild local frame = mw.getCurrentFrame local data = mw.loadJsonData( 'Pokémon Ruby and Sapphire/Route 101.json' ) local root = mw.html.create ts = frame:extensionTag{ name = 'templatestyles', args = { src = "Template:Pokemon/Wild/styles.css" } }

for _, encounters in pairs(data["encounters"]) do		root:node( createEncounterTable(encounters) ) end return ts .. tostring(root) end

function p.wild( frame ) args = getArgs( frame, { wrappers = 'Template:Pokemon/Wild' } ) return _wild end

return p