Suppress a few crashes

This commit is contained in:
Guangcong Luo
2014-10-21 02:19:11 -05:00
parent 73420d38c6
commit f40fac4fc2
2 changed files with 20 additions and 9 deletions

View File

@@ -959,10 +959,12 @@
text += '<p>HP: ' + pokemon.hpDisplay() +exacthp+(pokemon.status?' <span class="status '+pokemon.status+'">'+pokemon.status.toUpperCase()+'</span>':'')+'</p>';
if (this.battle.gen > 2) {
if (!pokemon.baseAbility && !pokemon.ability) {
text += '<p>Possible abilities: ' + Tools.getAbility(template.abilities['0']).name;
if (template.abilities['1']) text += ', ' + Tools.getAbility(template.abilities['1']).name;
if (template.abilities['H']) text += ', ' + Tools.getAbility(template.abilities['H']).name;
text += '</p>';
if (template.abilities) {
text += '<p>Possible abilities: ' + Tools.getAbility(template.abilities['0']).name;
if (template.abilities['1']) text += ', ' + Tools.getAbility(template.abilities['1']).name;
if (template.abilities['H']) text += ', ' + Tools.getAbility(template.abilities['H']).name;
text += '</p>';
}
} else if (pokemon.ability) {
text += '<p>Ability: ' + Tools.getAbility(pokemon.ability).name + '</p>';
} else if (pokemon.baseAbility) {

View File

@@ -14,9 +14,7 @@
this.update();
},
focus: function() {
if (!Tools.movelists) {
this.buildMovelists();
}
this.buildMovelists();
},
blur: function() {
if (this.saveFlag) {
@@ -813,7 +811,7 @@
// cache movelist ref
var speciesid = toId(this.curSet.species);
var g6 = (this.curTeam.format && this.curTeam.format.substr(0,7) === 'vgc2014');
this.movelist = (g6 ? Tools.g6movelists[speciesid] : Tools.movelists[speciesid]);
this.applyMovelist(g6, speciesid);
this.$chart.html('<em>Loading '+this.curChartType+'...</em>');
var self = this;
@@ -829,7 +827,7 @@
// cache movelist ref
var speciesid = toId(this.curSet.species);
var g6 = (this.curTeam.format && this.curTeam.format.substr(0,7) === 'vgc2014');
this.movelist = (g6 ? Tools.g6movelists[speciesid] : Tools.movelists[speciesid]);
this.applyMovelist(g6, speciesid);
var self = this;
if (this.updateChartTimeout) clearTimeout(this.updateChartTimeout);
@@ -1911,6 +1909,7 @@
// initialization
buildMovelists: function() {
if (Tools.movelists) return;
if (!window.BattlePokedex) return;
Tools.movelists = {};
Tools.g6movelists = {};
@@ -1939,6 +1938,16 @@
Tools.g6movelists[pokemon] = g6moves;
}
},
applyMovelist: function(g6only, speciesid) {
this.buildMovelists();
if (!Tools.movelists) {
this.movelist = false;
} else if (g6only) {
this.movelist = Tools.g6movelists[speciesid];
} else {
this.movelist = Tools.movelists[speciesid];
}
},
destroy: function() {
app.clearGlobalListeners();
Room.prototype.destroy.call(this);