From 950b3a14b49388578faa709b64423f18242a1ed2 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 12 Apr 2023 12:56:37 -0400 Subject: [PATCH] Fix crash with modifiers --- src/battle-phases.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 3c1f800e2..b202cf189 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -1294,7 +1294,7 @@ export class SelectModifierPhase extends BattlePhase { regenerateModifierPoolThresholds(party); const modifierCount = new Utils.IntegerHolder(3); this.scene.applyModifiers(ExtraModifierModifier, modifierCount); - const types: Array = getModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex - 1, modifierCount.value, party); + const typeOptions: Array = getModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex - 1, modifierCount.value, party); const modifierSelectCallback = (cursor: integer) => { if (cursor < 0) { @@ -1303,30 +1303,30 @@ export class SelectModifierPhase extends BattlePhase { return; } - const modifierType = types[cursor]; + const modifierType = typeOptions[cursor].type; if (modifierType instanceof PokemonModifierType) { const pokemonModifierType = modifierType as PokemonModifierType; const isMoveModifier = modifierType instanceof PokemonMoveModifierType; this.scene.ui.setModeWithoutClear(Mode.PARTY, !isMoveModifier ? PartyUiMode.MODIFIER : PartyUiMode.MOVE_MODIFIER, (slotIndex: integer, option: PartyOption) => { if (slotIndex < 6) { this.scene.ui.setMode(Mode.MODIFIER_SELECT); - const modifierType = types[cursor]; + const modifierType = typeOptions[cursor].type; const modifier = !isMoveModifier - ? modifierType.type.newModifier(party[slotIndex]) - : modifierType.type.newModifier(party[slotIndex], option - PartyOption.MOVE_1); + ? modifierType.newModifier(party[slotIndex]) + : modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1); this.scene.addModifier(modifier).then(() => super.end()); this.scene.ui.clearText(); this.scene.ui.setMode(Mode.MESSAGE); } else - this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, modifierSelectCallback); + this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback); }, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined); } else { - this.scene.addModifier(types[cursor].type.newModifier()).then(() => super.end()); + this.scene.addModifier(typeOptions[cursor].type.newModifier()).then(() => super.end()); this.scene.ui.clearText(); this.scene.ui.setMode(Mode.MESSAGE); } }; - this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, modifierSelectCallback); + this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback); } }