Fixed bug and such

This commit is contained in:
Bertie690 2025-06-24 18:59:44 -04:00
parent 25cbe6397e
commit 41f066cb4b
3 changed files with 16 additions and 16 deletions

View File

@ -1932,19 +1932,21 @@ export class AddSubstituteAttr extends MoveEffectAttr {
* @see {@linkcode apply} * @see {@linkcode apply}
*/ */
export class HealAttr extends MoveEffectAttr { export class HealAttr extends MoveEffectAttr {
/** The percentage of {@linkcode Stat.HP} to heal */ constructor(
private healRatio: number; /** The percentage of {@linkcode Stat.HP} to heal; default `1` */
/** Should an animation be shown? */ protected healRatio = 1,
private showAnim: boolean; /** Whether to display a healing animation upon healing the target; default `false` */
private showAnim = false,
constructor(healRatio?: number, showAnim?: boolean, selfTarget?: boolean) { selfTarget = true
super(selfTarget === undefined || selfTarget); ) {
super(selfTarget);
this.healRatio = healRatio || 1;
this.showAnim = !!showAnim;
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { 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); this.addHealPhase(this.selfTarget ? user : target, this.healRatio);
return true; return true;
} }
@ -1998,9 +2000,8 @@ export class VariableHealAttr extends HealAttr {
} }
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
const healRatio = this.healFunc(user, target, move) this.healRatio = this.healFunc(user, target, move)
this.addHealPhase(target, healRatio); return super.apply(user, target, move, args);
return true;
} }
} }

View File

@ -1601,6 +1601,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.getMaxHp() - this.hp; return this.getMaxHp() - this.hp;
} }
// TODO: Why does this default to `false`?
getHpRatio(precise = false): number { getHpRatio(precise = false): number {
return precise ? this.hp / this.getMaxHp() : Math.round((this.hp / this.getMaxHp()) * 100) / 100; return precise ? this.hp / this.getMaxHp() : Math.round((this.hp / this.getMaxHp()) * 100) / 100;
} }

View File

@ -2,7 +2,6 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { getEnumValues, toReadableString } from "#app/utils/common"; import { getEnumValues, toReadableString } from "#app/utils/common";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { WeatherType } from "#enums/weather-type"; import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
@ -27,7 +26,7 @@ describe("Moves - Recovery Moves - ", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.ability(AbilityId.BALL_FETCH) .ability(AbilityId.MAGIC_GUARD) // prevents passive weather damage
.battleStyle("single") .battleStyle("single")
.criticalHits(false) .criticalHits(false)
.enemySpecies(SpeciesId.MAGIKARP) .enemySpecies(SpeciesId.MAGIKARP)
@ -37,7 +36,6 @@ describe("Moves - Recovery Moves - ", () => {
.enemyLevel(100); .enemyLevel(100);
}); });
describe.each<{ name: string; move: MoveId }>([ describe.each<{ name: string; move: MoveId }>([
{ name: "Recover", move: MoveId.RECOVER }, { name: "Recover", move: MoveId.RECOVER },
{ name: "Soft-Boiled", move: MoveId.SOFT_BOILED }, { name: "Soft-Boiled", move: MoveId.SOFT_BOILED },