mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 16:32:16 +02:00
Apply suggestions from code review made by SirzBenjie
This commit is contained in:
parent
92e39d2548
commit
66505b7825
@ -6398,12 +6398,23 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
return (user, target, move) => {
|
return (user, target, move) => {
|
||||||
const switchOutTarget = (this.selfSwitch ? user : target);
|
const switchOutTarget = (this.selfSwitch ? user : target);
|
||||||
const player = switchOutTarget instanceof PlayerPokemon;
|
const player = switchOutTarget instanceof PlayerPokemon;
|
||||||
|
const forceSwitchAttr = move.getAttrs(ForceSwitchOutAttr).find(attr => attr.switchType === SwitchType.FORCE_SWITCH);
|
||||||
|
|
||||||
if (!this.selfSwitch) {
|
if (!this.selfSwitch) {
|
||||||
if (move.hitsSubstitute(user, target)) {
|
if (move.hitsSubstitute(user, target)) {
|
||||||
return false;
|
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
|
// Dondozo with an allied Tatsugiri in its mouth cannot be forced out
|
||||||
const commandedTag = switchOutTarget.getTag(BattlerTagType.COMMANDED);
|
const commandedTag = switchOutTarget.getTag(BattlerTagType.COMMANDED);
|
||||||
if (commandedTag?.getSourcePokemon()?.isActive(true)) {
|
if (commandedTag?.getSourcePokemon()?.isActive(true)) {
|
||||||
|
@ -376,17 +376,6 @@ export class MovePhase extends BattlePhase {
|
|||||||
|
|
||||||
const move = this.move.getMove();
|
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
|
* Move conditions assume the move has a single target
|
||||||
* TODO: is this sustainable?
|
* TODO: is this sustainable?
|
||||||
|
Loading…
Reference in New Issue
Block a user