Apply suggestions from code review made by SirzBenjie

This commit is contained in:
Sophia Alencar 2025-04-23 23:23:52 +01:00
parent 92e39d2548
commit 66505b7825
2 changed files with 11 additions and 11 deletions

View File

@ -6398,12 +6398,23 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return (user, target, move) => {
const switchOutTarget = (this.selfSwitch ? user : target);
const player = switchOutTarget instanceof PlayerPokemon;
const forceSwitchAttr = move.getAttrs(ForceSwitchOutAttr).find(attr => attr.switchType === SwitchType.FORCE_SWITCH);
if (!this.selfSwitch) {
if (move.hitsSubstitute(user, target)) {
return false;
}
// Check if the move is Roar or Whirlwind and if there is a trainer with only Pokémon left.
if (forceSwitchAttr && globalScene.currentBattle.trainer) {
const enemyParty = globalScene.getEnemyParty();
// Filter out any Pokémon that are not allowed in battle (e.g. fainted ones)
const remainingPokemon = enemyParty.filter(p => p.hp > 0 && p.isAllowedInBattle());
if (remainingPokemon.length <= 1) {
return false;
}
}
// Dondozo with an allied Tatsugiri in its mouth cannot be forced out
const commandedTag = switchOutTarget.getTag(BattlerTagType.COMMANDED);
if (commandedTag?.getSourcePokemon()?.isActive(true)) {

View File

@ -376,17 +376,6 @@ export class MovePhase extends BattlePhase {
const move = this.move.getMove();
// Check if the move is Roar or Whirlwind and if there is a trainer with only Pokémon left.
if ([Moves.ROAR, Moves.WHIRLWIND].includes(this.move.moveId) && globalScene.currentBattle.trainer) {
const enemyParty = globalScene.getEnemyParty();
// Filter out any Pokémon that are not allowed in battle (e.g. fainted ones)
const remainingPokemon = enemyParty.filter(pokemon => pokemon.hp > 0 && pokemon.isAllowedInBattle());
if (remainingPokemon.length <= 1) {
success = false;
}
}
/**
* Move conditions assume the move has a single target
* TODO: is this sustainable?