Fix broken call in force switch out

pull/101/head
Matthew Olker 2024-04-12 07:44:45 -04:00
parent fba98ffa0c
commit d2ebb499d8
1 changed files with 3 additions and 7 deletions

View File

@ -2511,10 +2511,8 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return new Promise(resolve => { return new Promise(resolve => {
// Check if the move category is not STATUS or if the switch out condition is not met // Check if the move category is not STATUS or if the switch out condition is not met
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) { if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) {
//Apply effects that need to be executed before switch out //Apply effects before switch out i.e. poison point, flame body, etc
//For example, applying poison or any other status condition applyPostDefendAbAttrs(PostDefendContactApplyStatusEffectAbAttr, target, user, new PokemonMove(move.id), null);
applyPostDefendAbAttrs(PostDefendContactApplyStatusEffectAbAttr, target, user, move);
//Resolve the Promise after the switch out is complete
return resolve(false); return resolve(false);
} }
@ -2522,8 +2520,6 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
// This ensures that the switch out only happens when the conditions are met // This ensures that the switch out only happens when the conditions are met
const switchOutTarget = this.user ? user : target; const switchOutTarget = this.user ? user : target;
if (switchOutTarget instanceof PlayerPokemon) { if (switchOutTarget instanceof PlayerPokemon) {
// Switch out logic for PlayerPokemon
// This includes applying any necessary effects before switching out
if (switchOutTarget.hp) { if (switchOutTarget.hp) {
applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, switchOutTarget); applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, switchOutTarget);
(switchOutTarget as PlayerPokemon).switchOut(this.batonPass, true).then(() => resolve(true)); (switchOutTarget as PlayerPokemon).switchOut(this.batonPass, true).then(() => resolve(true));
@ -2546,7 +2542,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, switchOutTarget.getFieldIndex(), user.scene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot), false, this.batonPass, false)); user.scene.unshiftPhase(new SwitchSummonPhase(user.scene, switchOutTarget.getFieldIndex(), user.scene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot), false, this.batonPass, false));
} }
else { else {
// Switch out logic for everything else // Switch out logic for everything else
switchOutTarget.setVisible(false); switchOutTarget.setVisible(false);
if (switchOutTarget.hp) { if (switchOutTarget.hp) {