From c65212882215df90fc34a9bb1812ed1f6570fea0 Mon Sep 17 00:00:00 2001 From: EmoUsedHM01 <131687820+EmoUsedHM01@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:25:03 +0100 Subject: [PATCH] Updated ElectroShotChargeAttr to raise SPATK before the move fires --- src/data/move.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 5eb9f0aaeb2..971757684cf 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1221,19 +1221,36 @@ export class SunlightChargeAttr extends ChargeAttr { } export class ElectroShotChargeAttr extends ChargeAttr { + private statIncreaseApplied: boolean; constructor() { super(ChargeAnim.ELECTRO_SHOT_CHARGING, 'absorbed electricity!', null, true); - // Add the StatChangeAttr functionality here so it always applies first - this.attr(StatChangeAttr, BattleStat.SPATK, 1, true); + this.statIncreaseApplied = false; } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { const weatherType = user.scene.arena.weather?.weatherType; - if (!user.scene.arena.weather?.isEffectSuppressed(user.scene) && (weatherType === WeatherType.RAIN || weatherType === WeatherType.HEAVY_RAIN)) + if (!user.scene.arena.weather?.isEffectSuppressed(user.scene) && (weatherType === WeatherType.RAIN || weatherType === WeatherType.HEAVY_RAIN)) { + // Apply the SPATK increase if the move is used in the rain + const statChangeAttr = new StatChangeAttr(BattleStat.SPATK, 1, true); + statChangeAttr.apply(user, target, move, args); resolve(false); - else - super.apply(user, target, move, args).then(result => resolve(result)); + } + else { + if (!this.statIncreaseApplied) { + // Apply the SPATK increase only if it hasn't been applied before + const statChangeAttr = new StatChangeAttr(BattleStat.SPATK, 1, true); + statChangeAttr.apply(user, target, move, args); + this.statIncreaseApplied = true; + } + super.apply(user, target, move, args).then(result => { + if (!result) { + // On the second turn, reset the statIncreaseApplied flag + this.statIncreaseApplied = false; + } + resolve(result); + }); + } }); } }