From 029175bce6d86a701b0c0c88fccdb7ae7d556a79 Mon Sep 17 00:00:00 2001 From: Jacob Hatchett <152253273+newmattock@users.noreply.github.com> Date: Thu, 30 May 2024 08:36:12 -0700 Subject: [PATCH] [Ability] Added Perish Body ability (#1554) * Added Perish Body ability * fix linting issues * Documentation + Checking if either pokemon has perish song tag * Fixed typo and improved TriggerMessage --- src/data/ability.ts | 35 ++++++++++++++++++++++++++++++- src/locales/en/ability-trigger.ts | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 7a31a264a3d..9cb03a5bc44 100755 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -819,6 +819,39 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr { return getPokemonMessage(pokemon, `'s ${abilityName}\nhurt its attacker!`); } } +/** + * @description: This ability applies the Perish Song tag to the attacking pokemon + * and the defending pokemon if the move makes physical contact and neither pokemon + * already has the Perish Song tag. + * @class PostDefendPerishSongAbAttr + * @extends {PostDefendAbAttr} + */ +export class PostDefendPerishSongAbAttr extends PostDefendAbAttr { + private turns: integer; + + constructor(turns: integer) { + super(); + + this.turns = turns; + } + + applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { + if (pokemon.getTag(BattlerTagType.PERISH_SONG) || attacker.getTag(BattlerTagType.PERISH_SONG)) { + return false; + } else { + attacker.addTag(BattlerTagType.PERISH_SONG, this.turns); + pokemon.addTag(BattlerTagType.PERISH_SONG, this.turns); + return true; + } + } + return false; + } + + getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { + return i18next.t("abilityTriggers:perishBody", {pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, abilityName: abilityName}); + } +} export class PostDefendWeatherChangeAbAttr extends PostDefendAbAttr { private weatherType: WeatherType; @@ -4164,7 +4197,7 @@ export function initAbilities() { .attr(MoveTypePowerBoostAbAttr, Type.STEEL) .partial(), new Ability(Abilities.PERISH_BODY, 8) - .unimplemented(), + .attr(PostDefendPerishSongAbAttr, 4), new Ability(Abilities.WANDERING_SPIRIT, 8) .attr(PostDefendAbilitySwapAbAttr) .bypassFaint() diff --git a/src/locales/en/ability-trigger.ts b/src/locales/en/ability-trigger.ts index 562ddd9c250..e7542eee4e3 100644 --- a/src/locales/en/ability-trigger.ts +++ b/src/locales/en/ability-trigger.ts @@ -3,4 +3,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { "blockRecoilDamage" : "{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!", "badDreams": "{{pokemonName}} is tormented!", + "perishBody": "{{pokemonName}}'s {{abilityName}}\n will faint both pokemon in 3 turns!", } as const;