[Ability] fix damage taken by disguise (#2601)

This commit is contained in:
Adrian T 2024-06-26 03:32:45 +08:00 committed by GitHub
parent eae2d0a144
commit fd08983181
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 1 deletions

View File

@ -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;
}

View File

@ -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
);
});