// Generating commentary message using events from above
await createBattleEvent(attacker, move, damage, effectivenessMessage);
if (newHP <= 0) {
setEvents(prevEvents => [...prevEvents, `${capitalizeAndFormat(defender.pokemon.name)} has fainted!`]);
if (attacker === currentPokemon) {
// If Cynthia's Pokémon faints, select the next Pokémon
const nextPokemon = selectNextCynthiaPokemon();
if (nextPokemon) {
// setCynthiaPokemon(nextPokemon);
} else {
alert("Cynthia has no more Pokémon left! You win!");
}
} else {
return
}
}
i.e. in BattlePage.jsx
See
if (nextPokemon)
line