Fixed import issues i think

This commit is contained in:
Bertie690 2025-07-23 22:57:47 -04:00
parent 6ee2f89182
commit 06290774c2
3 changed files with 49 additions and 73 deletions

View File

@ -1972,17 +1972,17 @@ export class HealAttr extends MoveEffectAttr {
return Math.round(score / (1 - this.healRatio / 2)); return Math.round(score / (1 - this.healRatio / 2));
} }
// TODO: Change post move failure rework
override getCondition(): MoveConditionFunc { override getCondition(): MoveConditionFunc {
return (user, target) => { return (user, target) => !(this.selfTarget ? user : target).isFullHp();
const healedPokemon = this.selfTarget ? user : target; }
if (healedPokemon.isFullHp()) {
globalScene.phaseManager.queueMessage(i18next.t("battle:hpIsFull", { override getFailedText(user: Pokemon, target: Pokemon): string | undefined {
pokemonName: getPokemonNameWithAffix(healedPokemon), const healedPokemon = (this.selfTarget ? user : target);
})) if (healedPokemon.isFullHp()) {
return false; return i18next.t("battle:hpIsFull", {
pokemonName: getPokemonNameWithAffix(healedPokemon),
})
} }
return true;
} }
} }
@ -1990,7 +1990,11 @@ export class HealAttr extends MoveEffectAttr {
* Attribute for moves with variable healing amounts. * Attribute for moves with variable healing amounts.
* Heals the target by an amount depending on the return value of {@linkcode healFunc}. * Heals the target by an amount depending on the return value of {@linkcode healFunc}.
* *
* Used for {@linkcode MoveId.MOONLIGHT}, {@linkcode MoveId.SHORE_UP}, {@linkcode MoveId.JUNGLE_HEALING}, {@linkcode MoveId.SWALLOW} * Used for:
* - {@linkcode MoveId.MOONLIGHT} and variants
* - {@linkcode MoveId.SHORE_UP}
* - {@linkcode MoveId.JUNGLE_HEALING}
* - {@linkcode MoveId.SWALLOW}
*/ */
export class VariableHealAttr extends HealAttr { export class VariableHealAttr extends HealAttr {
constructor( constructor(
@ -2005,7 +2009,7 @@ 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 {
this.healRatio = this.healFunc(user, target, move) this.healRatio = this.healFunc(user, target, move)
return super.apply(user, target, move, args); return super.apply(user, target, move, _args);
} }
} }
@ -2023,8 +2027,8 @@ export class HealOnAllyAttr extends HealAttr {
return false; return false;
} }
override getCondition(user: Pokemon, target: Pokemon, _move: Move, _args?: any[]): boolean { override getCondition(): MoveConditionFunc {
return user.getAlly() !== target || super.getCondition()(user, target, _move); return (user, target, _move) => user.getAlly() !== target || super.getCondition()(user, target, _move)
} }
} }

View File

@ -1,11 +1,12 @@
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
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 { 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";
import { toReadableString } from "#utils/common";
import { getEnumValues } from "#utils/enums";
import i18next from "i18next"; import i18next from "i18next";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -94,7 +95,7 @@ describe("Moves - Recovery Moves - ", () => {
expect(blissey.getHpRatio()).toBeCloseTo(0.66, 1); expect(blissey.getHpRatio()).toBeCloseTo(0.66, 1);
}); });
const nonSunWTs = (getEnumValues(WeatherType) as WeatherType[]) const nonSunWTs = getEnumValues(WeatherType)
.filter( .filter(
wt => ![WeatherType.SUNNY, WeatherType.HARSH_SUN, WeatherType.NONE, WeatherType.STRONG_WINDS].includes(wt), wt => ![WeatherType.SUNNY, WeatherType.HARSH_SUN, WeatherType.NONE, WeatherType.STRONG_WINDS].includes(wt),
) )

View File

@ -1,27 +1,28 @@
import { Stat } from "#enums/stat";
import { StockpilingTag } from "#app/data/battler-tags"; import { StockpilingTag } from "#app/data/battler-tags";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { MoveResult } from "#enums/move-result";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
import { BattlerIndex } from "#enums/battler-index";
import { allMoves } from "#app/data/data-lists"; import { allMoves } from "#app/data/data-lists";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat";
import { GameManager } from "#test/testUtils/gameManager";
import i18next from "i18next"; import i18next from "i18next";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";
describe("Swallow & Spit Up", () => { describe("Moves - Swallow & Spit Up - ", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phaser.Game({ type: Phaser.HEADLESS }); phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
}); });
describe("Moves - Swallow", () => {
afterEach(() => { afterEach(() => {
game.phaseInterceptor.restoreOg(); game.phaseInterceptor.restoreOg();
}); });
@ -38,6 +39,7 @@ describe("Swallow & Spit Up", () => {
.ability(AbilityId.BALL_FETCH); .ability(AbilityId.BALL_FETCH);
}); });
describe("Swallow", () => {
it.each<{ stackCount: number; healPercent: number }>([ it.each<{ stackCount: number; healPercent: number }>([
{ stackCount: 1, healPercent: 25 }, { stackCount: 1, healPercent: 25 },
{ stackCount: 2, healPercent: 50 }, { stackCount: 2, healPercent: 50 },
@ -109,24 +111,10 @@ describe("Swallow & Spit Up", () => {
}); });
}); });
describe("Moves - Spit Up", () => { describe("Spit Up", () => {
let spitUpSpy: MockInstance; let spitUpSpy: MockInstance;
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleStyle("single")
.enemySpecies(SpeciesId.RATTATA)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyLevel(2000)
.enemyMoveset(MoveId.SPLASH)
.ability(AbilityId.BALL_FETCH);
spitUpSpy = vi.spyOn(allMoves[MoveId.SPIT_UP], "calculateBattlePower"); spitUpSpy = vi.spyOn(allMoves[MoveId.SPIT_UP], "calculateBattlePower");
}); });
@ -173,23 +161,6 @@ describe("Swallow & Spit Up", () => {
}); });
describe("Stockpile stack removal", () => { describe("Stockpile stack removal", () => {
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleStyle("single")
.enemySpecies(SpeciesId.RATTATA)
.enemyMoveset(MoveId.SPLASH)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyLevel(100)
.startingLevel(100)
.ability(AbilityId.BALL_FETCH);
});
it("should undo stat boosts when losing stacks", async () => { it("should undo stat boosts when losing stacks", async () => {
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]); await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);