diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 120d1d413c4..b76db93a63e 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -8481,7 +8481,7 @@ export function initAbilities() { .attr(PokemonTypeChangeAbAttr), //.condition((p) => !p.summonData.abilitiesApplied.includes(AbilityId.PROTEAN)), //Gen 9 Implementation new Ability(AbilityId.FUR_COAT, 6) - .attr(ReceivedMoveDamageMultiplierAbAttr, (_target, _user, move) => move.category === MoveCategory.PHYSICAL, 0.5) + .attr(ReceivedMoveDamageMultiplierAbAttr, (_target, _user, move) => move.category === MoveCategory.PHYSICAL || move.hasAttr("DefDefAttr"), 0.5) .ignorable(), new Ability(AbilityId.MAGICIAN, 6) .attr(PostAttackStealHeldItemAbAttr), diff --git a/test/abilities/fur_coat.test.ts b/test/abilities/fur_coat.test.ts new file mode 100644 index 00000000000..0211072fd6d --- /dev/null +++ b/test/abilities/fur_coat.test.ts @@ -0,0 +1,90 @@ +import { AbilityId } from "#enums/ability-id"; +import { MoveId } from "#enums/move-id"; +import { SpeciesId } from "#enums/species-id"; +import GameManager from "#test/testUtils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Abilities - Fur Coat", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .battleStyle("single") + .ability(AbilityId.BALL_FETCH) + .enemySpecies(SpeciesId.MILOTIC) + .enemyAbility(AbilityId.BALL_FETCH) + .enemyMoveset([MoveId.SPLASH]) + .enemyLevel(20) + .criticalHits(false); + }); + + it("should reduce damage from a physical move after gaining Fur Coat", async () => { + await game.classicMode.startBattle([SpeciesId.PIKACHU]); + const enemy = game.field.getEnemyPokemon(); + // Use Tackle before Fur Coat + game.move.use(MoveId.TACKLE); + await game.toEndOfTurn(); + const damageBefore = enemy.getMaxHp() - enemy.hp; + // Give Fur Coat + game.field.mockAbility(enemy, AbilityId.FUR_COAT); + enemy.hp = enemy.getMaxHp(); + // Use Tackle after Fur Coat + game.move.use(MoveId.TACKLE); + await game.toEndOfTurn(); + const damageAfter = enemy.getMaxHp() - enemy.hp; + expect(damageAfter).toBeLessThan(damageBefore); + }); + + it("should not reduce damage from a special move", async () => { + await game.classicMode.startBattle([SpeciesId.PIKACHU]); + const enemy = game.field.getEnemyPokemon(); + // Use Scald before Fur Coat + game.move.use(MoveId.SCALD); + await game.toEndOfTurn(); + const damageBefore = enemy.getMaxHp() - enemy.hp; + // Give Fur Coat + game.field.mockAbility(enemy, AbilityId.FUR_COAT); + enemy.hp = enemy.getMaxHp(); + // Use Scald after Fur Coat + game.move.use(MoveId.SCALD); + await game.toEndOfTurn(); + const damageAfter = enemy.getMaxHp() - enemy.hp; + expect(damageAfter).toBeCloseTo(damageBefore, 1); + }); + + it.each([ + { moveName: "Psyshock", moveId: MoveId.PSYSHOCK }, + { moveName: "Psystrike", moveId: MoveId.PSYSTRIKE }, + { moveName: "Secret Sword", moveId: MoveId.SECRET_SWORD }, + ])("should reduce damage from $moveName after gaining Fur Coat", async ({ moveId }) => { + await game.classicMode.startBattle([SpeciesId.PIKACHU]); + const enemy = game.field.getEnemyPokemon(); + + game.move.use(moveId); + await game.toEndOfTurn(); + + const attackDamageBefore = enemy.getMaxHp() - enemy.hp; + + game.field.mockAbility(enemy, AbilityId.FUR_COAT); + enemy.hp = enemy.getMaxHp(); + + game.move.use(moveId); + await game.toEndOfTurn(); + + const attackDamageAfter = enemy.getMaxHp() - enemy.hp; + expect(attackDamageAfter).toBeLessThan(attackDamageBefore); + }); +});