Add failsafe for held item on nonexistent Pokemon

pull/2/head
Flashfyre 2023-07-05 13:03:51 -04:00
parent 2ec0c32487
commit f2c35e36ef
1 changed files with 5 additions and 0 deletions

View File

@ -898,6 +898,11 @@ export default class BattleScene extends Phaser.Scene {
player = true; player = true;
return new Promise(resolve => { return new Promise(resolve => {
const modifiers = player ? this.modifiers : this.enemyModifiers as PersistentModifier[]; const modifiers = player ? this.modifiers : this.enemyModifiers as PersistentModifier[];
for (let m = 0; m < modifiers.length; m++) {
const modifier = modifiers[m];
if (modifier instanceof PokemonHeldItemModifier && !this.getPokemonById((modifier as PokemonHeldItemModifier).pokemonId))
modifiers.splice(m--, 1);
}
for (let modifier of modifiers) { for (let modifier of modifiers) {
if (modifier instanceof PersistentModifier) if (modifier instanceof PersistentModifier)
(modifier as PersistentModifier).virtualStackCount = 0; (modifier as PersistentModifier).virtualStackCount = 0;