From 8db0d37a2ab7efda619eac92a5a16d969094782f Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sat, 2 Nov 2024 09:46:25 -0700 Subject: [PATCH] Minor formatting changes --- src/data/ability.ts | 12 +++++++----- src/data/move.ts | 6 +++--- src/field/pokemon.ts | 6 +----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 734912fafcb..c7460a0fdfa 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -4841,13 +4841,13 @@ async function applyAbAttrsInternal( class ForceSwitchOutHelper { constructor(private switchType: SwitchType) {} + /** * Handles the logic for switching out a Pokémon based on battle conditions, HP, and the switch type. * * @param pokemon The {@linkcode Pokemon} attempting to switch out. * @returns `true` if the switch is successful */ - public switchOutLogic(pokemon: Pokemon): boolean { const switchOutTarget = pokemon; /** @@ -4938,7 +4938,7 @@ class ForceSwitchOutHelper { } const party = player ? pokemon.scene.getParty() : pokemon.scene.getEnemyParty(); - return (!player && !pokemon.scene.currentBattle.battleType) + return (!player && pokemon.scene.currentBattle.battleType !== BattleType.WILD) || party.filter(p => p.isAllowedInBattle() && (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > pokemon.scene.currentBattle.getBattlerCount(); } @@ -4989,16 +4989,18 @@ export class PostDamageAbAttr extends AbAttr { * This attribute checks various conditions related to the damage received, the moves used by the Pokémon * and its opponents, and determines whether a forced switch-out should occur. * + * Used by Wimp Out and Emergency Exit + * * @extends PostDamageAbAttr + * @see {@linkcode applyPostDamage} */ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { - private helper: ForceSwitchOutHelper; + private helper: ForceSwitchOutHelper = new ForceSwitchOutHelper(SwitchType.SWITCH); private hpRatio: number; constructor(hpRatio: number = 0.5) { super(); this.hpRatio = hpRatio; - this.helper = new ForceSwitchOutHelper(SwitchType.SWITCH); } /** @@ -5020,7 +5022,6 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { const fordbiddenAttackingMoves = [ Moves.BELLY_DRUM, Moves.SUBSTITUTE, Moves.CURSE, Moves.PAIN_SPLIT ]; if (moveHistory.length > 0) { const lastMoveUsed = moveHistory[moveHistory.length - 1]; - // Will not activate if the Pokémon's HP falls below half while it is in the air during Sky Drop. if (fordbiddenAttackingMoves.includes(lastMoveUsed.move)) { return false; } @@ -5032,6 +5033,7 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { const enemyMoveHistory = source.getMoveHistory(); if (enemyMoveHistory.length > 0) { const enemyLastMoveUsed = enemyMoveHistory[enemyMoveHistory.length - 1]; + // Will not activate if the Pokémon's HP falls below half while it is in the air during Sky Drop. if (fordbiddenDefendingMoves.includes(enemyLastMoveUsed.move) || enemyLastMoveUsed.move === Moves.SKY_DROP && enemyLastMoveUsed.result === MoveResult.OTHER) { return false; // Will not activate if the Pokémon's HP falls below half by a move affected by Sheer Force. diff --git a/src/data/move.ts b/src/data/move.ts index c44021926e0..d128d6ba04e 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5697,8 +5697,8 @@ export class RevivalBlessingAttr extends MoveEffectAttr { } /** -* Helper function to check if the Pokémon's health is below half after taking damage -* Used for an edge case interaction with Wimp Out/Emergency Exit +* Helper function to check if the Pokémon's health is below half after taking damage. +* Used for an edge case interaction with Wimp Out/Emergency Exit. * If the Ability activates due to being hit by U-turn or Volt Switch, the user of that move will not be switched out. */ function shouldPreventSwitchOut(target: Pokemon): boolean { @@ -5729,11 +5729,11 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { return false; } + const switchOutTarget = this.selfSwitch ? user : target; /** * Check if Wimp Out/Emergency Exit activates due to being hit by U-turn or Volt Switch * If it did, the user of U-turn or Volt Switch will not be switched out. */ - const switchOutTarget = this.selfSwitch ? user : target; if (switchOutTarget instanceof PlayerPokemon) { if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) && (move.id === Moves.U_TURN || move.id === Moves.VOLT_SWITCH)) { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 4c17eafb417..61c31e7b76c 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2919,11 +2919,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); // Damage amount may have changed, but needed to be queued before calling damage function damagePhase.updateAmount(damage); - if (source) { - applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); - } else { - applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, []); - } + applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); return damage; }