From 93f658b624a8311a77369a1db1cac15925531b7a Mon Sep 17 00:00:00 2001 From: schmidtc1 <62030095+schmidtc1@users.noreply.github.com> Date: Sun, 25 Aug 2024 15:58:28 -0400 Subject: [PATCH] [Bug] Fixes Lunar Blessing only healing twice on the user instead of ally (#3701) * Sets Lunar Blessing selfTarget healing to false * Removes redundant lines * Adds unit test for Lunar Blessing * Adjusts unit tests to spy on function calls --- src/data/move.ts | 4 +- src/test/moves/lunar_blessing.test.ts | 83 +++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 src/test/moves/lunar_blessing.test.ts diff --git a/src/data/move.ts b/src/data/move.ts index 2a6ac78d6ec..78ddd790f75 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -8632,7 +8632,6 @@ export function initMoves() { .attr(StatusEffectAttr, StatusEffect.BURN), new StatusMove(Moves.JUNGLE_HEALING, Type.GRASS, -1, 10, -1, 0, 8) .attr(HealAttr, 0.25, true, false) - .attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) .attr(HealStatusEffectAttr, false, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) .target(MoveTarget.USER_AND_ALLIES), new AttackMove(Moves.WICKED_BLOW, Type.DARK, MoveCategory.PHYSICAL, 75, 100, 5, -1, 0, 8) @@ -8736,8 +8735,7 @@ export function initMoves() { .windMove() .target(MoveTarget.ALL_NEAR_ENEMIES), new StatusMove(Moves.LUNAR_BLESSING, Type.PSYCHIC, -1, 5, -1, 0, 8) - .attr(HealAttr, 0.25) - .attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) + .attr(HealAttr, 0.25, true, false) .attr(HealStatusEffectAttr, false, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN, StatusEffect.SLEEP) .target(MoveTarget.USER_AND_ALLIES) .triageMove(), diff --git a/src/test/moves/lunar_blessing.test.ts b/src/test/moves/lunar_blessing.test.ts new file mode 100644 index 00000000000..73647716f06 --- /dev/null +++ b/src/test/moves/lunar_blessing.test.ts @@ -0,0 +1,83 @@ +import { StatusEffect } from "#app/enums/status-effect.js"; +import { CommandPhase } from "#app/phases/command-phase.js"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import { SPLASH_ONLY } from "#test/utils/testUtils"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; + +describe("Moves - Lunar Blessing", () => { + 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.battleType("double"); + + game.override.enemySpecies(Species.SHUCKLE); + game.override.enemyMoveset(SPLASH_ONLY); + game.override.enemyAbility(Abilities.BALL_FETCH); + + game.override.moveset([Moves.LUNAR_BLESSING, Moves.SPLASH]); + game.override.ability(Abilities.BALL_FETCH); + }); + + it("should restore 25% HP of the user and its ally", async () => { + await game.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); + + vi.spyOn(leftPlayer, "getMaxHp").mockReturnValue(100); + vi.spyOn(rightPlayer, "getMaxHp").mockReturnValue(100); + + const initialHp = 1; + leftPlayer["hp"] = initialHp; + rightPlayer["hp"] = initialHp; + const expectedHeal = 25; + + vi.spyOn(leftPlayer, "heal"); + vi.spyOn(rightPlayer, "heal"); + + + game.move.select(Moves.LUNAR_BLESSING, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); + + expect(leftPlayer.heal).toHaveBeenCalledOnce(); + expect(leftPlayer.heal).toHaveReturnedWith(expectedHeal); + + expect(rightPlayer.heal).toHaveBeenCalledOnce(); + expect(rightPlayer.heal).toHaveReturnedWith(expectedHeal); + }); + + it("should cure status effect of the user and its ally", async () => { + game.override.statusEffect(StatusEffect.BURN); + await game.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); + + vi.spyOn(leftPlayer, "resetStatus"); + vi.spyOn(rightPlayer, "resetStatus"); + + game.move.select(Moves.LUNAR_BLESSING, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); + + expect(leftPlayer.resetStatus).toHaveBeenCalledOnce(); + expect(rightPlayer.resetStatus).toHaveBeenCalledOnce(); + + expect(leftPlayer.status?.effect).toBeUndefined(); + expect(rightPlayer.status?.effect).toBeUndefined(); + }); +});