Module:Pokemon/Wild

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

local p = {} local rateCount = { Base = 1, Time = 3, DN = 2, Weather = 9, Season = 4 }

function p.row( frame ) local args = getArgs( frame, { wrappers = 'Template:Pokemon/Wild row' } ) local pokedex = mw.loadJsonData( 'Module:Pokemon/Pokedex.json' ) local game = args[1] or 'red' local mode = args[2] or 'Base' local monNum = args[3] or '001' local level = args[4] or '-' local forms = args['form'] local rates = {}

for i = 1, rateCount[mode] do		rates[i] = args[4 + i] or '' if rates[i] == '' then rates[i] = '-' else rates[i] = rates[i] .. "%"		end end if tonumber(monNum) >= 100 then monNum = tonumber(monNum) end local monName = pokedex[monNum] local bpLink = monName

if args['bp'] then bpLink = frame:expandTemplate{ title = 'bp', args = { monName } } end local row = {} if forms then row={ "|-\n", '| class="t_pkmn_wild_img" | ', '', '\n', '| class="t_pkmn_wild_name" | ', bpLink, '\n', '| ', level, '\n', '| ', table.concat(rates, ' || ') }   else row={ "|-\n", '| class="t_pkmn_wild_img" | ', '', '\n', '| class="t_pkmn_wild_name" | ', bpLink, '\n', '| ', level, '\n', '| ', table.concat(rates, ' || ') }   end return table.concat( row ) end

return p