Module:Pokemon Number

From Moegirlpedia
Jump to: navigation, search
Template-info.svg Module Documentation  [Create] [Refresh]
local module = {}
local data = require('Module:Pokemon Number/Data')
local getArgs = require('Module:Arguments').getArgs

function module.main(frame)
	local args = getArgs(frame)
	local name = args[1]
	local text = ''
	if data['kanto'][name] ~= nil then
		text = text .. string.format('\n* kanto: %03d %s', data['kanto'][name], '{{ArticleCategory|Pokémon series/Kanto region}}')
	end
	if data['johto2'][name] ~= nil then
		if data['johto'][name] == data['johto2'][name] then
			text = text .. string.format('\n* Johto: %03d %s', data['johto'][name], '{{ArticleCategory|Pokémon series/Johto region}}')
		elseif data['johto'][name] == nil then
			text = text .. string.format('\n* Johto: %03d (HGSS) %s', data['johto2'][name], '{{ArticleCategory|Pokémon series/Johto region}}')
		else
			text = text .. string.format('\n* Johto: %03d (GSC)/%03d (HGSS) %s', data['johto'][name], data['johto2'][name], '{{ArticleCategory|Pokémon series/Johto region}}')
		end
	end
	if data['hoenn'][name] ~= nil then
		if data['hoenn'][name] == data['johto2'][name] then
			text = text .. string.format('\n* Hoenn: %03d %s', data['hoenn'][name], '{{ArticleCategory|Pokémon series/Hoenn region}}')
		elseif data['hoenn'][name] == nil then
			text = text .. string.format('\n* Hoenn: %03d (ORAS) %s', data['hoenn2'][name], '{{ArticleCategory|Pokémon series/Hoenn region}}')
		else
			text = text .. string.format('\n* Hoenn: %03d (RSE)/%03d (ORAS) %s', data['hoenn'][name], data['hoenn2'][name], '{{ArticleCategory|Pokémon series/Hoenn region}}')
		end
	end
	if data['sinnoh'][name] ~= nil then
		text = text .. string.format('\n* Sinnoh: %03d %s', data['sinnoh'][name], '{{ArticleCategory|Pokémon series/Sinnoh region}}')
	end
	if data['unova2'][name] ~= nil then
		if data['unova'][name] == data['unova2'][name] then
			text = text .. string.format('\n* Unova: %03d %s', data['unova'][name], '{{ArticleCategory|Pokémon series/Unova region}}')
		elseif data['unova'][name] == nil then
			text = text .. string.format('\n* Unova: %03d (B2W2) %s', data['unova2'][name], '{{ArticleCategory|Pokémon series/Unova region}}')
		else
			text = text .. string.format('\n* Unova: %03d (BW)/%03d (B2W2) %s', data['unova'][name], data['unova2'][name], '{{ArticleCategory|Pokémon series/Unova region}}')
		end
	end
	if data['kalos_central'][name] ~= nil then
		text = text .. string.format('\n* Kalos: %03d (Central) %s', data['kalos_central'][name], '{{ArticleCategory|Pokémon series/Kalos region}}')
	end
	if data['kalos_coastal'][name] ~= nil then
		text = text .. string.format('\n* Kalos: %03d (Coastal) %s', data['kalos_coastal'][name], '{{ArticleCategory|Pokémon series/Kalos region}}')
	end
	if data['kalos_mountain'][name] ~= nil then
		text = text .. string.format('\n* Kalos: %03d (Mountain) %s', data['kalos_mountain'][name], '{{ArticleCategory|Pokémon series/Kalos region}}')
	end
	if data['alola2'][name] ~= nil then
		if data['alola'][name] == data['alola2'][name] then
			text = text .. string.format('\n* Alola: %03d %s', data['alola'][name], '{{ArticleCategory|Pokémon series/Alola region}}')
		elseif data['alola'][name] == nil then
			text = text .. string.format('\n* Alola: %03d (USUM) %s', data['alola2'][name], '{{ArticleCategory|Pokémon series/Alola region}}')
		else
			text = text .. string.format('\n* Alola: %03d (SM)/%03d (USUM) %s', data['alola'][name], data['alola2'][name], '{{ArticleCategory|Pokémon series/Alola region}}')
		end
	end
	if data['alola2_melemele'][name] ~= nil then
		if data['alola_melemele'][name] == data['alola2_melemele'][name] then
			text = text .. string.format('\n** Melemele Island: %03d', data['alola_melemele'][name])
		elseif data['alola_melemele'][name] == nil then
			text = text .. string.format('\n** Melemele Island: %03d (USUM)', data['alola2_melemele'][name])
		else
			text = text .. string.format('\n** Melemele Island: %03d (SM)/%03d (USUM)', data['alola_melemele'][name], data['alola2_melemele'][name])
		end
	end
	if data['alola2_akala'][name] ~= nil then
		if data['alola_akala'][name] == data['alola2_akala'][name] then
			text = text .. string.format('\n** Akala Island: %03d', data['alola_akala'][name])
		elseif data['alola_akala'][name] == nil then
			text = text .. string.format('\n** Akala Island: %03d (USUM)', data['alola2_akala'][name])
		else
			text = text .. string.format('\n** Akala Island: %03d (SM)/%03d (USUM)', data['alola_akala'][name], data['alola2_akala'][name])
		end
	end
	if data['alola2_ulaula'][name] ~= nil then
		if data['alola_ulaula'][name] == data['alola2_ulaula'][name] then
			text = text .. string.format('\n** Ulaula Island: %03d', data['alola_ulaula'][name])
		elseif data['alola_ulaula'][name] == nil then
			text = text .. string.format('\n** Ulaula Island: %03d (USUM)', data['alola2_ulaula'][name])
		else
			text = text .. string.format('\n** Ulaula Island: %03d (SM)/%03d (USUM)', data['alola_ulaula'][name], data['alola2_ulaula'][name])
		end
	end
	if data['alola2_poni'][name] ~= nil then
		if data['alola_poni'][name] == data['alola2_poni'][name] then
			text = text .. string.format('\n** Poni Island: %03d', data['alola_poni'][name])
		elseif data['alola_poni'][name] == nil then
			text = text .. string.format('\n** Poni Island: %03d (USUM)', data['alola2_poni'][name])
		else
			text = text .. string.format('\n** Poni Island: %03d (SM)/%03d (USUM)', data['alola_poni'][name], data['alola2_poni'][name])
		end
	end
	if data['galar'][name] ~= nil then
		text = text .. string.format('\n* Galar: %03d %s', data['galar'][name], '{{ArticleCategory|Pokémon series/Galar region}}')
		if data['armor'][name] ~= nil then
			text = text .. string.format('\n** Isle of Armor: 03d', data['armor'][name])
		end
		if data['crown'][name] ~= nil then
			text = text .. string.format('\n** Crown Tundra: %03d', data['crown'][name])
		end
	elseif data['armor'][name] ~= nil then
		if data['crown'][name] ~= nil then
			text = text .. string.format('\n* Galar:  %s', '{{ArticleCategory|Pokémon series/Galar region}}')
			text = text .. string.format('\n** Isle of Armor: %03d', data['armor'][name])
			text = text .. string.format('\n** Crown Tundra: %03d', data['crown'][name])
		else
			text = text .. string.format('\n* Galar-Isle of Armor: %03d %s', data['armor'][name], '{{ArticleCategory|Pokémon series/Galar region}}')
		end
	elseif data['crown'][name] ~= nil then
		text = text .. string.format('\n* Galar-Crown Tundra: %03d %s', data['crown'][name], '{{ArticleCategory|Pokémon series/Galar region}}')
	end
	if data['hisui'][name] ~= nil then
		text = text .. string.format('\n* Hisui: %03d %s', data['hisui'][name], '{{ArticleCategory|Pokémon series/Hisui region}}')
	end
	if text == '' then
		text = '<center>Not in the Regional Pokédex {{ArticleCategory|Pokémon series/Not in the Regional Pokédex}}</center>'
	end
	return frame:preprocess(text)
end

return module