From af86bdeb068388c2aa8d835c8e1413a335d99563 Mon Sep 17 00:00:00 2001 From: LaukkaE <73663099+LaukkaE@users.noreply.github.com> Date: Tue, 14 May 2024 02:48:47 +0300 Subject: [PATCH] Prevent applying item boosts when power is <1 (#795) * Prevent applying item boosts when power is <1 * add comments --- src/modifier/modifier.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index ba009cb7a..8a5fba17d 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -635,6 +635,9 @@ export class PokemonBaseStatModifier extends PokemonHeldItemModifier { } } + /** + * Applies Specific Type item boosts (e.g., Magnet) + */ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { private moveType: Type; private boostMultiplier: number; @@ -667,8 +670,15 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { return super.shouldApply(args) && args.length === 3 && typeof args[1] === 'number' && args[2] instanceof Utils.NumberHolder; } + /** + * @param {Array} args Array + * - Index 0: {Pokemon} Pokemon + * - Index 1: {number} Move type + * - Index 2: {Utils.NumberHolder} Move power + * @returns {boolean} Returns true if boosts have been applied to the move. + */ apply(args: any[]): boolean { - if (args[1] === this.moveType) { + if (args[1] === this.moveType && (args[2] as Utils.NumberHolder).value >= 1) { (args[2] as Utils.NumberHolder).value = Math.floor((args[2] as Utils.NumberHolder).value * (1 + (this.getStackCount() * this.boostMultiplier))); return true; }