2020-04-25 16:29:59 +00:00
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
/****** Generations ******/
|
|
|
|
|
var G1 = [1, 151];
|
|
|
|
|
var G2 = [152, 251];
|
|
|
|
|
var G3 = [252, 386];
|
|
|
|
|
var G4 = [387, 493];
|
|
|
|
|
var G5 = [494, 649];
|
|
|
|
|
var G6 = [650, 721];
|
|
|
|
|
var G7 = [722, 809];
|
2022-02-23 12:58:51 +00:00
|
|
|
|
var G8 = [810, 905];
|
|
|
|
|
var MEGA = [906, 955];
|
|
|
|
|
var GIGA = [956, 987];
|
|
|
|
|
var REG = [988, 1040];
|
2020-04-25 16:29:59 +00:00
|
|
|
|
|
|
|
|
|
/************ GAME *************/
|
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
|
|
// loading json file
|
|
|
|
|
var json = $.getJSON('pokemon.json', function(pk) {
|
|
|
|
|
|
|
|
|
|
$('article #container #game #loading').hide();
|
|
|
|
|
var pklist = pk;
|
|
|
|
|
|
|
|
|
|
$('article #container #flashdex_config .all').click(function() {
|
|
|
|
|
|
|
|
|
|
if ($(this).hasClass("unselected")) {
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < 9; ++i)
|
|
|
|
|
$('input[name="'+i+'g"]').prop('checked', true);
|
|
|
|
|
$('input[name="mega"]').prop('checked', true);
|
|
|
|
|
$('input[name="regional"]').prop('checked', true);
|
|
|
|
|
$('input[name="gigantamax"]').prop('checked', true);
|
|
|
|
|
$(this).removeClass("unselected").addClass("selected");
|
|
|
|
|
$(this).text("Unselect all");
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 1; i < 9; ++i)
|
|
|
|
|
$('input[name="'+i+'g"]').prop('checked', false);
|
|
|
|
|
$('input[name="mega"]').prop('checked', false);
|
|
|
|
|
$('input[name="regional"]').prop('checked', false);
|
|
|
|
|
$('input[name="gigantamax"]').prop('checked', false);
|
|
|
|
|
$(this).removeClass("selected").addClass("unselected");
|
|
|
|
|
$(this).text("Select all");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// start the game when clicking on start game
|
|
|
|
|
$('article #container .button input.start').click(function() {
|
|
|
|
|
|
|
|
|
|
$('article #container #game #loading').show();
|
|
|
|
|
$('article #container #game #flashdex').empty();
|
|
|
|
|
|
|
|
|
|
var lang = $('article select.lang option:selected').attr('id');
|
|
|
|
|
var gen_list = new Array();
|
|
|
|
|
var pokemon_generation_list = new Array();
|
|
|
|
|
|
|
|
|
|
generations();
|
|
|
|
|
|
|
|
|
|
$('article #container #game #flashdex').hide();
|
|
|
|
|
|
|
|
|
|
function getFormText(pkmn) {
|
|
|
|
|
if (pkmn["origin"] == "Kanto")
|
|
|
|
|
return '<span class="form RB"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Johto")
|
|
|
|
|
return '<span class="form GS"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Hoenn")
|
|
|
|
|
return '<span class="form RS"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Sinnoh")
|
|
|
|
|
return '<span class="form DP"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Unova")
|
|
|
|
|
return '<span class="form BW"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Kalos")
|
|
|
|
|
return '<span class="form XY"></span>'
|
|
|
|
|
else if (pkmn["origin"] == "Alola")
|
|
|
|
|
return '<span class="form SM"></span>'
|
2022-02-23 12:58:51 +00:00
|
|
|
|
else if (pkmn["origin"] == "Galar" || pkmn["origin"] == "Hisui")
|
2020-04-25 16:29:59 +00:00
|
|
|
|
return '<span class="form SWSH"></span>'
|
|
|
|
|
else if (pkmn["type"] == "mega")
|
|
|
|
|
return '<span class="form mega"></span>';
|
|
|
|
|
else if (pkmn["type"] == "giga")
|
|
|
|
|
return '<span class="form giga"></span>';
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFormattedNumber(num) {
|
|
|
|
|
if (num[0] == 'M' || num[0] == 'R' || num[0] == 'G')
|
|
|
|
|
return num.substring(1, num.length);
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i in pokemon_generation_list) {
|
|
|
|
|
$('article #container #game #flashdex').append(
|
|
|
|
|
'<div class="pokedex id_'+pklist.mn[pokemon_generation_list[i]]["num"]+'">'
|
|
|
|
|
+ getFormText(pklist.mn[pokemon_generation_list[i]]) // either gigantamax or mega-evolution
|
|
|
|
|
+ '<img src="pokemon/'+ imageType((pklist.mn[pokemon_generation_list[i]]["num"])) +'.png"/>'
|
|
|
|
|
+ '<span class="name">' + '<strong>' + '#' + getFormattedNumber(pklist.mn[[pokemon_generation_list[i]]]["num"]) + '</strong> '
|
|
|
|
|
+ pklist.mn[[pokemon_generation_list[i]]][lang] + '</span>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('article #container #game #flashdex').waitForImages(function() {
|
|
|
|
|
$(this).show();
|
|
|
|
|
$('article #container #game #loading').hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function generations() {
|
|
|
|
|
|
|
|
|
|
// create the list of the different generations
|
|
|
|
|
function createGenerationList(name) {
|
|
|
|
|
if ( $('article input[name="'+name+'"]').is(':checked') )
|
|
|
|
|
gen_list[gen_list.length] = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create the list of all possible pokemons for selected options
|
|
|
|
|
function generatePokemonList() {
|
|
|
|
|
|
|
|
|
|
function evaluateByGeneration(index, name, variable) {
|
|
|
|
|
if (gen_list[index] == name) {
|
|
|
|
|
for (j = (variable[0] - 1); j <= (variable[1] - 1); j++)
|
|
|
|
|
pokemon_generation_list[pokemon_generation_list.length] = j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gen_list.length > 0) {
|
|
|
|
|
for (i in gen_list) {
|
|
|
|
|
evaluateByGeneration(i, "1g", G1); evaluateByGeneration(i, "2g", G2); evaluateByGeneration(i, "3g", G3);
|
|
|
|
|
evaluateByGeneration(i, "4g", G4); evaluateByGeneration(i, "5g", G5); evaluateByGeneration(i, "6g", G6);
|
|
|
|
|
evaluateByGeneration(i, "7g", G7); evaluateByGeneration(i, "8g", G8);
|
|
|
|
|
evaluateByGeneration(i, "mega", MEGA); evaluateByGeneration(i, "regional", REG); evaluateByGeneration(i, "gigantamax", GIGA);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 9; i++)
|
|
|
|
|
createGenerationList((i + "g"));
|
|
|
|
|
createGenerationList("regional");
|
2022-02-23 12:58:51 +00:00
|
|
|
|
createGenerationList("mega");
|
2020-04-25 16:29:59 +00:00
|
|
|
|
createGenerationList("gigantamax");
|
|
|
|
|
|
|
|
|
|
generatePokemonList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// multiple artworks
|
|
|
|
|
function imageType(result) {
|
|
|
|
|
var four_types = [351, 386, 585, 586, 676, 741, 800];
|
2021-01-10 11:28:37 +00:00
|
|
|
|
var three_types = [249, 250, 384, 412, 413, 718, 745, 898];
|
2020-04-25 16:29:59 +00:00
|
|
|
|
var two_types = [251, 252, 255, 258, 374, 387, 390, 393, 421, 422, 423, 487, 492, 495, 498, 501, 521, 550, 555,
|
|
|
|
|
592, 593, 641, 642, 643, 644, 645, 647, 648, 668, 678, 681, 720, 746, 774, 791, 792, 802, 849,
|
2022-02-23 12:58:51 +00:00
|
|
|
|
876, 877, 888, 889, 892, 905, "G892"];
|
2020-04-25 16:29:59 +00:00
|
|
|
|
|
|
|
|
|
function no_randomizer() {
|
|
|
|
|
if (result === 25)
|
|
|
|
|
return (result+'-9');
|
|
|
|
|
if (result === 666)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
if (result === 646)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
if (result === 479)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
for (a in four_types) {
|
|
|
|
|
if (four_types[a] == result)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
}
|
|
|
|
|
for (a in three_types) {
|
|
|
|
|
if (three_types[a] == result)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
}
|
|
|
|
|
for (a in two_types) {
|
|
|
|
|
if (two_types[a] == result)
|
|
|
|
|
return (result+'-0');
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return no_randomizer(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|