From fd08983181ff4cc7794229135afa40109e520932 Mon Sep 17 00:00:00 2001 From: Adrian T <68144167+torranx@users.noreply.github.com> Date: Wed, 26 Jun 2024 03:32:45 +0800 Subject: [PATCH] [Ability] fix damage taken by disguise (#2601) --- src/data/ability.ts | 2 +- src/test/abilities/disguise.test.ts | 31 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 9d86142644e..0d6681a56a6 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -333,7 +333,7 @@ export class PreDefendMoveDamageToOneAbAttr extends ReceivedMoveDamageMultiplier applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.condition(pokemon, attacker, move)) { - (args[0] as Utils.NumberHolder).value = 1; + (args[0] as Utils.NumberHolder).value = Math.floor(pokemon.getMaxHp() / 8); return true; } diff --git a/src/test/abilities/disguise.test.ts b/src/test/abilities/disguise.test.ts index cf8ba386b2e..297aa33e06c 100644 --- a/src/test/abilities/disguise.test.ts +++ b/src/test/abilities/disguise.test.ts @@ -64,4 +64,35 @@ describe("Abilities - DISGUISE", () => { }, TIMEOUT ); + + test( + "damage taken should be equal to 1/8 of its maximum HP, rounded down", + async () => { + const baseForm = 0, + bustedForm = 1; + + vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.DARK_PULSE, Moves.DARK_PULSE, Moves.DARK_PULSE, Moves.DARK_PULSE]); + vi.spyOn(Overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(20); + vi.spyOn(Overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(20); + vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MAGIKARP); + vi.spyOn(Overrides, "STARTER_FORM_OVERRIDES", "get").mockReturnValue({ + [Species.MIMIKYU]: baseForm, + }); + + await game.startBattle([Species.MIMIKYU]); + + const mimikyu = game.scene.getPlayerPokemon(); + const damage = (Math.floor(mimikyu.getMaxHp()/8)); + + expect(mimikyu).not.toBe(undefined); + expect(mimikyu.formIndex).toBe(baseForm); + + game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + await game.phaseInterceptor.to(TurnEndPhase); + + expect(mimikyu.formIndex).toBe(bustedForm); + expect(game.scene.getEnemyPokemon().turnData.currDamageDealt).toBe(damage); + }, + TIMEOUT + ); });