diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 42596a47204..26ffa0c0656 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -1932,19 +1932,21 @@ export class AddSubstituteAttr extends MoveEffectAttr { * @see {@linkcode apply} */ export class HealAttr extends MoveEffectAttr { - /** The percentage of {@linkcode Stat.HP} to heal */ - private healRatio: number; - /** Should an animation be shown? */ - private showAnim: boolean; - - constructor(healRatio?: number, showAnim?: boolean, selfTarget?: boolean) { - super(selfTarget === undefined || selfTarget); - - this.healRatio = healRatio || 1; - this.showAnim = !!showAnim; + constructor( + /** The percentage of {@linkcode Stat.HP} to heal; default `1` */ + protected healRatio = 1, + /** Whether to display a healing animation upon healing the target; default `false` */ + private showAnim = false, + selfTarget = true + ) { + super(selfTarget); } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.apply(user, target, move, args)) { + return false; + } + this.addHealPhase(this.selfTarget ? user : target, this.healRatio); return true; } @@ -1998,9 +2000,8 @@ export class VariableHealAttr extends HealAttr { } apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean { - const healRatio = this.healFunc(user, target, move) - this.addHealPhase(target, healRatio); - return true; + this.healRatio = this.healFunc(user, target, move) + return super.apply(user, target, move, args); } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index eee6c309859..f62542fcaac 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1601,6 +1601,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.getMaxHp() - this.hp; } + // TODO: Why does this default to `false`? getHpRatio(precise = false): number { return precise ? this.hp / this.getMaxHp() : Math.round((this.hp / this.getMaxHp()) * 100) / 100; } diff --git a/test/moves/recovery-moves.test.ts b/test/moves/recovery-moves.test.ts index 6b3b84c5539..0a6daaa209c 100644 --- a/test/moves/recovery-moves.test.ts +++ b/test/moves/recovery-moves.test.ts @@ -2,7 +2,6 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { getEnumValues, toReadableString } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; -import { MoveResult } from "#enums/move-result"; import { SpeciesId } from "#enums/species-id"; import { WeatherType } from "#enums/weather-type"; import GameManager from "#test/testUtils/gameManager"; @@ -27,7 +26,7 @@ describe("Moves - Recovery Moves - ", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .ability(AbilityId.BALL_FETCH) + .ability(AbilityId.MAGIC_GUARD) // prevents passive weather damage .battleStyle("single") .criticalHits(false) .enemySpecies(SpeciesId.MAGIKARP) @@ -37,7 +36,6 @@ describe("Moves - Recovery Moves - ", () => { .enemyLevel(100); }); - describe.each<{ name: string; move: MoveId }>([ { name: "Recover", move: MoveId.RECOVER }, { name: "Soft-Boiled", move: MoveId.SOFT_BOILED },