Bugfix and code cleaning
This commit is contained in:
53
flashdex.js
53
flashdex.js
@ -14,8 +14,6 @@ $(document).ready(function()
|
||||
var GIGA = [1061, 1092];
|
||||
var REG = [1093, 1147];
|
||||
|
||||
var EXCEPTION = 1092; // urshifu g-max
|
||||
|
||||
/************ GAME *************/
|
||||
/*******************************/
|
||||
|
||||
@ -49,7 +47,6 @@ $(document).ready(function()
|
||||
}
|
||||
})
|
||||
|
||||
// start the game when clicking on start game
|
||||
$('article #container .button input.start').click(function()
|
||||
{
|
||||
var lang = $('article select.lang option:selected').attr('id');
|
||||
@ -86,8 +83,6 @@ $(document).ready(function()
|
||||
return '<span class="form LA"></span>'
|
||||
else if (pkmn["origin"] == "Paldea")
|
||||
return '<span class="form SV"></span>'
|
||||
else if (pkmn["origin"] == "9G")
|
||||
return '<span class="form SV"></span>'
|
||||
else if (pkmn["form"] == "mega")
|
||||
return '<span class="form mega"></span>';
|
||||
else if (pkmn["form"] == "giga")
|
||||
@ -156,19 +151,20 @@ $(document).ready(function()
|
||||
if (form > 0)
|
||||
form--;
|
||||
else
|
||||
form = pklist.mn[pokemon-1]["sprite"] - 1;
|
||||
form = pklist.mn[pokemon]["sprite"] - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (form < pklist.mn[pokemon-1]["sprite"] - 1)
|
||||
if (form < pklist.mn[pokemon]["sprite"] - 1)
|
||||
form++;
|
||||
else
|
||||
form = 0;
|
||||
}
|
||||
|
||||
var newUrl = 'pokemon/' + pokemon + '-' + form + '.png';
|
||||
var newUrl = 'pokemon/' + pokemonUrl + '-' + form + '.png';
|
||||
|
||||
origin.parent().parent().find("img").attr('src', newUrl);
|
||||
handleChangeType(form, pokemon-1)
|
||||
handleChangeType(form, pokemon);
|
||||
}
|
||||
|
||||
function handleKanto()
|
||||
@ -183,7 +179,7 @@ $(document).ready(function()
|
||||
if (left)
|
||||
{
|
||||
if (KantoForm == "RG")
|
||||
KantoForm = "RB"
|
||||
KantoForm = "RB";
|
||||
else if (KantoForm == "RB")
|
||||
KantoForm = "";
|
||||
else
|
||||
@ -192,28 +188,18 @@ $(document).ready(function()
|
||||
else
|
||||
{
|
||||
if (KantoForm == "RB")
|
||||
KantoForm = "RG"
|
||||
KantoForm = "RG";
|
||||
else if (KantoForm == "RG")
|
||||
KantoForm = "";
|
||||
else
|
||||
KantoForm = "RB";
|
||||
}
|
||||
|
||||
var newUrl = 'pokemon/' + pokemon + KantoForm + '.png';
|
||||
origin.parent().parent().find("img").attr('src', newUrl);
|
||||
}
|
||||
|
||||
function handleException()
|
||||
{
|
||||
var form = url.split('-')[1];
|
||||
if (form == 0)
|
||||
form = 1;
|
||||
else
|
||||
form = 0;
|
||||
if (KantoForm)
|
||||
KantoForm = "-" + KantoForm;
|
||||
|
||||
var newUrl = 'pokemon/' + pokemonUrl + '-' + form + '.png';
|
||||
var newUrl = 'pokemon/' + pokemonUrl + KantoForm + '.png';
|
||||
origin.parent().parent().find("img").attr('src', newUrl);
|
||||
handleChangeType(form, EXCEPTION-1)
|
||||
}
|
||||
|
||||
function handleChangeType(form, num)
|
||||
@ -229,22 +215,19 @@ $(document).ready(function()
|
||||
|
||||
var url = origin.parent().parent().find("img").attr('src');
|
||||
var originalUrl = url;
|
||||
|
||||
url = url.split('/')[1];
|
||||
url = url.split('.')[0];
|
||||
|
||||
var pokemonUrl = url.split('-')[0];
|
||||
var pokemon = '';
|
||||
for (var i = 0; i < pokemonUrl.length; i++)
|
||||
{
|
||||
if (pokemonUrl[i].match(/[0-9]/))
|
||||
pokemon += pokemonUrl[i];
|
||||
}
|
||||
|
||||
if (pokemonUrl == "G892" || pokemonUrl == "R128") // TODO: not finished, Tauros issue
|
||||
handleException();
|
||||
else if (pklist.mn[pokemon-1]["origin"] == "Kanto" && !pklist.mn[pokemon-1]["sprite"])
|
||||
var pokemon = pklist.mn.findIndex(function(item, i)
|
||||
{
|
||||
return item.num == pokemonUrl;
|
||||
});
|
||||
|
||||
if (pklist.mn[pokemon]["origin"] == "Kanto" && !pklist.mn[pokemon]["sprite"])
|
||||
handleKanto();
|
||||
else if (pklist.mn[pokemon-1]["sprite"])
|
||||
else if (pklist.mn[pokemon]["sprite"])
|
||||
handleDefault();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user