From fd586ecd8ea211dcb0a45de8f31378d688dce59e Mon Sep 17 00:00:00 2001 From: ReneGV Date: Fri, 28 Jun 2024 18:59:06 -0600 Subject: [PATCH] [Bug] Fix purify (#2697) --- src/data/move.ts | 4 +- src/test/moves/purify.test.ts | 81 +++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/test/moves/purify.test.ts diff --git a/src/data/move.ts b/src/data/move.ts index 3161dec0c60..b6f55ed14b8 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7577,9 +7577,9 @@ export function initMoves() { new AttackMove(Moves.SMART_STRIKE, Type.STEEL, MoveCategory.PHYSICAL, 70, -1, 10, -1, 0, 7), new StatusMove(Moves.PURIFY, Type.POISON, -1, 20, -1, 0, 7) .condition( - (user: Pokemon, target: Pokemon, move: Move) => isNonVolatileStatusEffect(user.status?.effect)) + (user: Pokemon, target: Pokemon, move: Move) => isNonVolatileStatusEffect(target.status?.effect)) .attr(HealAttr, 0.5) - .attr(HealStatusEffectAttr, true, ...getNonVolatileStatusEffects()) + .attr(HealStatusEffectAttr, false, ...getNonVolatileStatusEffects()) .triageMove(), new AttackMove(Moves.REVELATION_DANCE, Type.NORMAL, MoveCategory.SPECIAL, 90, 100, 15, -1, 0, 7) .danceMove() diff --git a/src/test/moves/purify.test.ts b/src/test/moves/purify.test.ts new file mode 100644 index 00000000000..21ebb3d5515 --- /dev/null +++ b/src/test/moves/purify.test.ts @@ -0,0 +1,81 @@ +import {afterEach, beforeAll, beforeEach, describe, expect, test, vi} from "vitest"; +import Phaser from "phaser"; +import GameManager from "#app/test/utils/gameManager"; +import * as overrides from "#app/overrides"; +import { + MoveEndPhase, +} from "#app/phases"; +import {getMovePosition} from "#app/test/utils/gameManagerUtils"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon.js"; +import { Status, StatusEffect } from "#app/data/status-effect.js"; + +const TIMEOUT = 20 * 1000; + +describe("Moves - Purify", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); + + vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.PYUKUMUKU); + vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(10); + vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.PURIFY, Moves.SIZZLY_SLIDE]); + + vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MAGIKARP); + vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(10); + vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]); + }); + + test( + "Purify heals opponent status effect and restores user hp", + async () => { + await game.startBattle(); + + const enemyPokemon: EnemyPokemon = game.scene.getEnemyPokemon(); + const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon(); + + playerPokemon.hp = playerPokemon.getMaxHp() - 1; + enemyPokemon.status = new Status(StatusEffect.BURN); + + game.doAttack(getMovePosition(game.scene, 0, Moves.PURIFY)); + await game.phaseInterceptor.to(MoveEndPhase); + + expect(enemyPokemon.status).toBe(undefined); + expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); + }, + TIMEOUT + ); + + test( + "Purify does not heal if opponent doesnt have any status effect", + async () => { + await game.startBattle(); + + const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon(); + + playerPokemon.hp = playerPokemon.getMaxHp() - 1; + const playerInitialHp = playerPokemon.hp; + + game.doAttack(getMovePosition(game.scene, 0, Moves.PURIFY)); + await game.phaseInterceptor.to(MoveEndPhase); + + expect(playerPokemon.hp).toBe(playerInitialHp); + }, + TIMEOUT + ); + +});