Updated ElectroShotChargeAttr to raise SPATK before the move fires

This commit is contained in:
EmoUsedHM01 2024-04-12 11:25:03 +01:00 committed by GitHub
parent 7f099f76c8
commit c652128822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1221,19 +1221,36 @@ export class SunlightChargeAttr extends ChargeAttr {
} }
export class ElectroShotChargeAttr extends ChargeAttr { export class ElectroShotChargeAttr extends ChargeAttr {
private statIncreaseApplied: boolean;
constructor() { constructor() {
super(ChargeAnim.ELECTRO_SHOT_CHARGING, 'absorbed electricity!', null, true); super(ChargeAnim.ELECTRO_SHOT_CHARGING, 'absorbed electricity!', null, true);
// Add the StatChangeAttr functionality here so it always applies first this.statIncreaseApplied = false;
this.attr(StatChangeAttr, BattleStat.SPATK, 1, true);
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => { return new Promise(resolve => {
const weatherType = user.scene.arena.weather?.weatherType; 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); 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);
});
}
}); });
} }
} }