From d70ab3eaf68c8f70205b3492f4750dfa9c11bc53 Mon Sep 17 00:00:00 2001 From: Ethan <71776311+EvasiveAce@users.noreply.github.com> Date: Thu, 30 May 2024 17:01:42 -0400 Subject: [PATCH] [Move] Implement Punishment (#1610) * Implement Punishment and reopen pull request 373 * Fix console log and () --- src/data/move.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 90ed36af2dd..e20768c69e9 100755 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2704,12 +2704,57 @@ export class HitCountPowerAttr extends VariablePowerAttr { } } +/** + * Turning a once was (StatChangeCountPowerAttr) statement and making it available to call for any attribute. + * @param {Pokemon} pokemon The pokemon that is being used to calculate the count of positive stats + * @returns {number} Returns the amount of positive stats + */ +const countPositiveStats = (pokemon: Pokemon): number => { + return pokemon.summonData.battleStats.reduce((total, stat) => (stat && stat > 0) ? total + stat : total, 0); +}; + +/** + * Attribute that increases power based on the amount of positive stat increases. + */ export class StatChangeCountPowerAttr extends VariablePowerAttr { + + /** + * @param {Pokemon} user The pokemon that is being used to calculate the amount of positive stats + * @param {Pokemon} target N/A + * @param {Move} move N/A + * @param {any[]} args The argument for VariablePowerAttr, accumulates and sets the amount of power multiplied by stats + * @returns {boolean} Returns true if attribute is applied + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const positiveStats: number = user.summonData.battleStats.reduce((total, stat) => stat > 0 && stat ? total + stat : total, 0); + const positiveStats: number = countPositiveStats(user); (args[0] as Utils.NumberHolder).value += positiveStats * 20; + return true; + } +} +/** + * Punishment normally has a base power of 60, + * but gains 20 power for every increased stat stage the target has, + * up to a maximum of 200 base power in total. + */ +export class PunishmentPowerAttr extends VariablePowerAttr { + private PUNISHMENT_MIN_BASE_POWER = 60; + private PUNISHMENT_MAX_BASE_POWER = 200; + + /** + * @param {Pokemon} user N/A + * @param {Pokemon} target The pokemon that the move is being used against, as well as calculating the stats for the min/max base power + * @param {Move} move N/A + * @param {any[]} args The value that is being changed due to VariablePowerAttr + * @returns Returns true if attribute is applied + */ + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + const positiveStats: number = countPositiveStats(target); + (args[0] as Utils.NumberHolder).value = Math.min( + this.PUNISHMENT_MAX_BASE_POWER, + this.PUNISHMENT_MIN_BASE_POWER + positiveStats * 20 + ); return true; } } @@ -6065,7 +6110,8 @@ export function initMoves() { new StatusMove(Moves.GUARD_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4) .unimplemented(), new AttackMove(Moves.PUNISHMENT, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4) - .unimplemented(), + .makesContact(true) + .attr(PunishmentPowerAttr), new AttackMove(Moves.LAST_RESORT, Type.NORMAL, MoveCategory.PHYSICAL, 140, 100, 5, -1, 0, 4) .attr(LastResortAttr), new StatusMove(Moves.WORRY_SEED, Type.GRASS, 100, 10, -1, 0, 4)