From bcfeaf06396af3e5502749263f3d6d725f7e32c5 Mon Sep 17 00:00:00 2001 From: Adrian T <68144167+torranx@users.noreply.github.com> Date: Tue, 11 Jun 2024 01:40:00 +0800 Subject: [PATCH] [Bug] add move effectiveness text color check to ignore ability (#2042) --- src/field/pokemon.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 9ac45c4c299..8a4a0ab837a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1070,6 +1070,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } /** + * Calculates the effectiveness of a move against the Pokémon. + * + * @param source - The Pokémon using the move. + * @param move - The move being used. * @returns The type damage multiplier or undefined if it's a status move */ getMoveEffectiveness(source: Pokemon, move: PokemonMove): TypeDamageMultiplier | undefined { @@ -1077,19 +1081,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return undefined; } - return this.getAttackMoveEffectiveness(source, move); + return this.getAttackMoveEffectiveness(source, move, true); } - getAttackMoveEffectiveness(source: Pokemon, pokemonMove: PokemonMove): TypeDamageMultiplier { + /** + * Calculates the effectiveness of an attack move against the Pokémon. + * + * @param source - The attacking Pokémon. + * @param pokemonMove - The move being used by the attacking Pokémon. + * @param ignoreAbility - Whether to check for abilities that might affect type effectiveness or immunity. + * @returns The type damage multiplier, indicating the effectiveness of the move + */ + getAttackMoveEffectiveness(source: Pokemon, pokemonMove: PokemonMove, ignoreAbility: boolean = false): TypeDamageMultiplier { const move = pokemonMove.getMove(); const typeless = move.hasAttr(TypelessAttr); const typeMultiplier = new Utils.NumberHolder(this.getAttackTypeEffectiveness(move.type, source)); const cancelled = new Utils.BooleanHolder(false); applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); - if (!typeless) { + if (!typeless && !ignoreAbility) { applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelled, typeMultiplier, true); } - if (!cancelled.value) { + if (!cancelled.value && !ignoreAbility) { applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelled, typeMultiplier, true); } return (!cancelled.value ? typeMultiplier.value : 0) as TypeDamageMultiplier;