From c675c4789b069a59a087c5982b1951a0b219bbf8 Mon Sep 17 00:00:00 2001 From: kd8lvt Date: Sat, 6 Apr 2024 19:34:15 -0400 Subject: [PATCH] Implement Rough Skin --- src/data/ability.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index cb9cd098bb6..09fb8016ed4 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5,7 +5,7 @@ import { BattleStat, getBattleStatName } from "./battle-stat"; import { PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; import { getPokemonMessage } from "../messages"; import { Weather, WeatherType } from "./weather"; -import { BattlerTag } from "./battler-tags"; +import { BattlerTag, getBattlerTag } from "./battler-tags"; import { BattlerTagType } from "./enums/battler-tag-type"; import { StatusEffect, getStatusEffectDescriptor } from "./status-effect"; import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, RecoilAttr, StatusMoveTypeImmunityAttr, allMoves } from "./move"; @@ -528,6 +528,32 @@ export class PostDefendCritStatChangeAbAttr extends PostDefendAbAttr { } } +export class PostDefendContactDamageAttackerAbAttr extends PostDefendAbAttr { + percentMaxHealthDamage: number; + constructor(percentMaxHealthDamage: number) { + super(); + this.percentMaxHealthDamage = percentMaxHealthDamage; + } + + applyPostDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon)) { + attacker.damageAndUpdate(attacker.getMaxHp()*(this.percentMaxHealthDamage),HitResult.EFFECTIVE,false,false,false); + return true; + } + return false; + } +} + +export class RoughSkinAbAttr extends PostDefendContactDamageAttackerAbAttr { + constructor() { + super(1/8); + } + + getTriggerMessage(pokemon: Pokemon, ...args: any[]): string { + return `${pokemon.name}${(pokemon.name.endsWith('s')?`'`:`'s`)} Rough Skin hurt its attacker!`; + } +} + export class PreAttackAbAttr extends AbAttr { applyPreAttack(pokemon: Pokemon, defender: Pokemon, move: PokemonMove, args: any[]): boolean | Promise { return false; @@ -2107,7 +2133,9 @@ export function initAbilities() { .attr(PostSummonStatChangeAbAttr, BattleStat.ATK, -1), new Ability(Abilities.SHADOW_TAG, "Shadow Tag", "This Pokémon steps on the opposing Pokémon's shadow to prevent it from escaping.", 3) .attr(ArenaTrapAbAttr), - new Ability(Abilities.ROUGH_SKIN, "Rough Skin (N)", "This Pokémon inflicts damage with its rough skin to the attacker on contact.", 3), + new Ability(Abilities.ROUGH_SKIN, "Rough Skin", "This Pokémon inflicts damage with its rough skin to the attacker on contact.", 3) + .attr(RoughSkinAbAttr) + .ignorable(), new Ability(Abilities.WONDER_GUARD, "Wonder Guard", "Its mysterious power only lets supereffective moves hit the Pokémon.", 3) .attr(NonSuperEffectiveImmunityAbAttr) .attr(ProtectAbilityAbAttr)