From 96a154f5e0e0ff085008c4af5e110524aceca4f3 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 21 Oct 2023 20:52:19 -0400 Subject: [PATCH] Add Pokemon heal function --- src/battle-phases.ts | 2 +- src/pokemon.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 6d943d8b2..d57e15587 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -2485,7 +2485,7 @@ export class PokemonHealPhase extends CommonAnimPhase { const hpRestoreMultiplier = new Utils.IntegerHolder(1); if (!this.revive) this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier); - pokemon.hp = Math.min(pokemon.hp + this.hpHealed * hpRestoreMultiplier.value, pokemon.getMaxHp()); + pokemon.heal(this.hpHealed * hpRestoreMultiplier.value); pokemon.updateInfo().then(() => super.end()); } else if (this.showFullHpMessage) this.message = getPokemonMessage(pokemon, `'s\nHP is full!`); diff --git a/src/pokemon.ts b/src/pokemon.ts index de07c2e53..3e04b289e 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -759,6 +759,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } + heal(amount: integer): void { + if (this.isFainted()) + return; + + this.hp = Math.min(this.hp + amount, this.getMaxHp()); + } + addTag(tagType: BattlerTagType, turnCount?: integer, sourceMove?: Moves, sourceId?: integer): boolean { const existingTag = this.getTag(tagType); if (existingTag) {