From 1b73d4c29f1454ba5364f053bef13901d1d8fa64 Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 16 Apr 2024 19:11:16 -0400 Subject: [PATCH] Implement Charge and more abilities --- src/data/ability.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 9ca07286705..a69ad2912aa 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -415,6 +415,26 @@ export class MoveImmunityAbAttr extends PreDefendAbAttr { } } +export class MoveImmunityStatChangeAbAttr extends MoveImmunityAbAttr { + private stat: BattleStat; + private levels: integer; + + constructor(immuneCondition: PreDefendAbAttrCondition, stat: BattleStat, levels: integer) { + super(immuneCondition); + this.stat = stat; + this.levels = levels; + } + + applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { + const ret = super.applyPreDefend(pokemon, passive, attacker, move, cancelled, args) + if (ret) { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); + } + + return ret; + } +} + export class PostDefendStatChangeAbAttr extends PostDefendAbAttr { private condition: PokemonDefendCondition; private stat: BattleStat; @@ -2837,7 +2857,8 @@ export function initAbilities() { .bypassFaint(), new Ability(Abilities.SEED_SOWER, "Seed Sower", "Turns the ground into Grassy Terrain when the Pokémon is hit by an attack.", 9) .attr(PostDefendTerrainChangeAbAttr, TerrainType.GRASSY), - new Ability(Abilities.THERMAL_EXCHANGE, "Thermal Exchange (P)", "Boosts the Attack stat when the Pokémon is hit by a Fire-type move. The Pokémon also cannot be burned.", 9) + new Ability(Abilities.THERMAL_EXCHANGE, "Thermal Exchange", "Boosts the Attack stat when the Pokémon is hit by a Fire-type move. The Pokémon also cannot be burned.", 9) + .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.type === Type.FIRE && move.category !== MoveCategory.STATUS, BattleStat.ATK, 1) .attr(StatusEffectImmunityAbAttr, StatusEffect.BURN) .ignorable(), new Ability(Abilities.ANGER_SHELL, "Anger Shell (N)", "When an attack causes its HP to drop to half or less, the Pokémon gets angry. This lowers its Defense and Sp. Def stats but boosts its Attack, Sp. Atk, and Speed stats.", 9), @@ -2849,8 +2870,7 @@ export function initAbilities() { .attr(TypeImmunityStatChangeAbAttr, Type.FIRE, BattleStat.DEF, 2) .ignorable(), new Ability(Abilities.WIND_RIDER, "Wind Rider (P)", "Boosts the Pokémon's Attack stat if Tailwind takes effect or if the Pokémon is hit by a wind move. The Pokémon also takes no damage from wind moves.", 9) - .attr(MoveImmunityAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.getMove().hasFlag(MoveFlags.WIND_MOVE)) - .attr(PostDefendStatChangeAbAttr, (target, user, move) => move.hasFlag(MoveFlags.WIND_MOVE), BattleStat.ATK, 1) + .attr(MoveImmunityStatChangeAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.getMove().hasFlag(MoveFlags.WIND_MOVE), BattleStat.ATK, 1) .ignorable(), new Ability(Abilities.GUARD_DOG, "Guard Dog (N)", "Boosts the Pokémon's Attack stat if intimidated. Moves and items that would force the Pokémon to switch out also fail to work.", 9) .ignorable(),