From 548d66d3fd28d91d697b015bf74f30d505287daa Mon Sep 17 00:00:00 2001 From: Chase Manning <chase@manning.dev> Date: Fri, 13 Oct 2023 08:30:31 +0100 Subject: [PATCH] :bug: not exiting trainer battles --- src/components/PokemonEncounter.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/PokemonEncounter.tsx b/src/components/PokemonEncounter.tsx index ec1e599..8a7c6ba 100644 --- a/src/components/PokemonEncounter.tsx +++ b/src/components/PokemonEncounter.tsx @@ -611,7 +611,14 @@ const PokemonEncounter = () => { const isTrainer = !!trainer; const isThrowingEnemyPokeball = stage >= 34 && stage <= 38 && isTrainer; - const endEncounter_ = () => { + const endEncounter_ = (exitBattle = false) => { + if (exitBattle) { + setTrainerPokemonIndex(0); + dispatch(endEncounter()); + dispatch(faintToTrainer()); + return; + } + // Bringing out the trainers next pokemon if (isTrainer && trainerPokemonIndex < trainer?.pokemon.length - 1) { const newIndex = trainerPokemonIndex + 1; @@ -896,7 +903,7 @@ const PokemonEncounter = () => { dispatch(recoverFromFainting()); }, 1000); setTimeout(() => { - endEncounter_(); + endEncounter_(true); }, 1000 + 500); }