From 1d8cf50f1b83557510fa9738b0541714aad17d7e Mon Sep 17 00:00:00 2001 From: xDasone <149128906+xDasone@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:12:53 -0700 Subject: [PATCH] Implemented Anger Point Ability --- src/data/ability.ts | 25 ++++++++++++++++++++++++- src/pokemon.ts | 5 +++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 60d8f08f5..65af91071 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -320,6 +320,28 @@ export class PostDefendContactApplyTagChanceAbAttr extends PostDefendAbAttr { } } +export class PostDefendCritStatChangeAbAttr extends PostDefendAbAttr { + private stat: BattleStat; + private levels: integer; + + constructor(stat: BattleStat, levels: integer) { + super(true); + + this.stat = stat; + this.levels = levels; + } + + applyPostDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ this.stat ], this.levels)); + + return true; + } + + getCondition(): AbAttrCondition { + return (pokemon: Pokemon) => pokemon.turnData.attacksReceived.length && pokemon.turnData.attacksReceived[pokemon.turnData.attacksReceived.length - 1].critical; + } +} + export class PreAttackAbAttr extends AbAttr { applyPreAttack(pokemon: Pokemon, defender: Pokemon, move: PokemonMove, args: any[]): boolean { return false; @@ -1342,7 +1364,8 @@ export function initAbilities() { new Ability(Abilities.ADAPTABILITY, "Adaptability", "Powers up moves of the same type.", 4) .attr(StabBoostAbAttr), new Ability(Abilities.AFTERMATH, "Aftermath (N)", "Damages the attacker landing the finishing hit.", 4), - new Ability(Abilities.ANGER_POINT, "Anger Point (N)", "Maxes Attack after taking a critical hit.", 4), + new Ability(Abilities.ANGER_POINT, "Anger Point", "Maxes Attack after taking a critical hit.", 4) + .attr(PostDefendCritStatChangeAbAttr, BattleStat.ATK, 6), new Ability(Abilities.ANTICIPATION, "Anticipation (N)", "Senses a foe's dangerous moves.", 4), new Ability(Abilities.BAD_DREAMS, "Bad Dreams (N)", "Reduces a sleeping foe's HP.", 4), new Ability(Abilities.DOWNLOAD, "Download (N)", "Adjusts power according to a foe's defenses.", 4), diff --git a/src/pokemon.ts b/src/pokemon.ts index a4214886d..5498a1933 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -23,7 +23,7 @@ import { WeatherType } from './data/weather'; import { TempBattleStat } from './data/temp-battle-stat'; import { ArenaTagType, WeakenMoveTypeTag } from './data/arena-tag'; import { Biome } from './data/biome'; -import { Abilities, Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, abilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from './data/ability'; +import { Abilities, Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, abilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from './data/ability'; import PokemonData from './system/pokemon-data'; import { BattlerIndex } from './battle'; @@ -721,7 +721,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { damage = Math.min(damage, this.hp); this.damage(damage); source.turnData.damageDealt += damage; - this.turnData.attacksReceived.unshift({ move: move.id, result: result as DamageResult, damage: damage, sourceId: source.id }); + this.turnData.attacksReceived.unshift({ move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id }); } switch (result) { @@ -1363,6 +1363,7 @@ export interface AttackMoveResult { move: Moves; result: DamageResult; damage: integer; + critical: boolean; sourceId: integer; }