Edited Electro Shot to raise stat before attacking (#87)

* Edited Electro Shot to raise stat before attacking

Should be a fix to issue #85

* Updated ElectroShotChargeAttr

Moved the Sp Atk boost to be inside the ElectroShotChargeAttr function

* Updated ElectroShotChargeAttr to raise SPATK before the move fires

* Updated ElectroShotChargeAttr with comments on process

* Updated formatting
pull/193/head
EmoUsedHM01 2024-04-19 14:28:44 +01:00 committed by GitHub
parent 85b47be0b8
commit 660663cffe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 4 deletions

View File

@ -1294,17 +1294,38 @@ 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 a flag because ChargeAttr skills use themselves twice instead of once over one-to-two turns
this.statIncreaseApplied = false;
} }
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 every call when used in the rain
const statChangeAttr = new StatChangeAttr(BattleStat.SPATK, 1, true);
statChangeAttr.apply(user, target, move, args);
// After the SPATK is raised, execute the move resolution e.g. deal damage
resolve(false); resolve(false);
else } else {
super.apply(user, target, move, args).then(result => resolve(result)); if (!this.statIncreaseApplied) {
// Apply the SPATK increase only if it hasn't been applied before e.g. on the first turn charge up animation
const statChangeAttr = new StatChangeAttr(BattleStat.SPATK, 1, true);
statChangeAttr.apply(user, target, move, args);
// Set the flag to true so that on the following turn it doesn't raise SPATK a second time
this.statIncreaseApplied = true;
}
super.apply(user, target, move, args).then(result => {
if (!result) {
// On the second turn, reset the statIncreaseApplied flag without applying the SPATK increase
this.statIncreaseApplied = false;
}
resolve(result);
});
}
}); });
} }
} }
@ -6128,7 +6149,6 @@ export function initMoves() {
.makesContact(false), .makesContact(false),
new AttackMove(Moves.ELECTRO_SHOT, Type.ELECTRIC, MoveCategory.SPECIAL, 130, 100, 10, 100, 0, 9) new AttackMove(Moves.ELECTRO_SHOT, Type.ELECTRIC, MoveCategory.SPECIAL, 130, 100, 10, 100, 0, 9)
.attr(ElectroShotChargeAttr) .attr(ElectroShotChargeAttr)
.attr(StatChangeAttr, BattleStat.SPATK, 1, true)
.ignoresVirtual(), .ignoresVirtual(),
new AttackMove(Moves.TERA_STARSTORM, Type.NORMAL, MoveCategory.SPECIAL, 120, 100, 5, -1, 0, 9) new AttackMove(Moves.TERA_STARSTORM, Type.NORMAL, MoveCategory.SPECIAL, 120, 100, 5, -1, 0, 9)
.attr(TeraBlastCategoryAttr) .attr(TeraBlastCategoryAttr)