Minor formatting changes

This commit is contained in:
NightKev 2024-11-02 09:46:25 -07:00
parent ba4915728f
commit 8db0d37a2a
3 changed files with 11 additions and 13 deletions

View File

@ -4841,13 +4841,13 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
class ForceSwitchOutHelper { class ForceSwitchOutHelper {
constructor(private switchType: SwitchType) {} constructor(private switchType: SwitchType) {}
/** /**
* Handles the logic for switching out a Pokémon based on battle conditions, HP, and the switch type. * 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. * @param pokemon The {@linkcode Pokemon} attempting to switch out.
* @returns `true` if the switch is successful * @returns `true` if the switch is successful
*/ */
public switchOutLogic(pokemon: Pokemon): boolean { public switchOutLogic(pokemon: Pokemon): boolean {
const switchOutTarget = pokemon; const switchOutTarget = pokemon;
/** /**
@ -4938,7 +4938,7 @@ class ForceSwitchOutHelper {
} }
const party = player ? pokemon.scene.getParty() : pokemon.scene.getEnemyParty(); 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() || party.filter(p => p.isAllowedInBattle()
&& (player || (p as EnemyPokemon).trainerSlot === (switchOutTarget as EnemyPokemon).trainerSlot)).length > pokemon.scene.currentBattle.getBattlerCount(); && (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 * 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. * and its opponents, and determines whether a forced switch-out should occur.
* *
* Used by Wimp Out and Emergency Exit
*
* @extends PostDamageAbAttr * @extends PostDamageAbAttr
* @see {@linkcode applyPostDamage}
*/ */
export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr {
private helper: ForceSwitchOutHelper; private helper: ForceSwitchOutHelper = new ForceSwitchOutHelper(SwitchType.SWITCH);
private hpRatio: number; private hpRatio: number;
constructor(hpRatio: number = 0.5) { constructor(hpRatio: number = 0.5) {
super(); super();
this.hpRatio = hpRatio; 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 ]; const fordbiddenAttackingMoves = [ Moves.BELLY_DRUM, Moves.SUBSTITUTE, Moves.CURSE, Moves.PAIN_SPLIT ];
if (moveHistory.length > 0) { if (moveHistory.length > 0) {
const lastMoveUsed = moveHistory[moveHistory.length - 1]; 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)) { if (fordbiddenAttackingMoves.includes(lastMoveUsed.move)) {
return false; return false;
} }
@ -5032,6 +5033,7 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr {
const enemyMoveHistory = source.getMoveHistory(); const enemyMoveHistory = source.getMoveHistory();
if (enemyMoveHistory.length > 0) { if (enemyMoveHistory.length > 0) {
const enemyLastMoveUsed = enemyMoveHistory[enemyMoveHistory.length - 1]; 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) { if (fordbiddenDefendingMoves.includes(enemyLastMoveUsed.move) || enemyLastMoveUsed.move === Moves.SKY_DROP && enemyLastMoveUsed.result === MoveResult.OTHER) {
return false; return false;
// Will not activate if the Pokémon's HP falls below half by a move affected by Sheer Force. // Will not activate if the Pokémon's HP falls below half by a move affected by Sheer Force.

View File

@ -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 * 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 * 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. * 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 { function shouldPreventSwitchOut(target: Pokemon): boolean {
@ -5729,11 +5729,11 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return false; 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 * 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. * 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 (switchOutTarget instanceof PlayerPokemon) {
if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) && if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) &&
(move.id === Moves.U_TURN || move.id === Moves.VOLT_SWITCH)) { (move.id === Moves.U_TURN || move.id === Moves.VOLT_SWITCH)) {

View File

@ -2919,11 +2919,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase);
// Damage amount may have changed, but needed to be queued before calling damage function // Damage amount may have changed, but needed to be queued before calling damage function
damagePhase.updateAmount(damage); damagePhase.updateAmount(damage);
if (source) {
applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source);
} else {
applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, []);
}
return damage; return damage;
} }