This commit is contained in:
Bertie690 2025-06-17 16:05:43 -04:00
parent c6c3cd9f3c
commit 7f2766f832
2 changed files with 17 additions and 60 deletions

View File

@ -5,11 +5,8 @@ import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
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";
import { MoveResult } from "#enums/move-result";
import { getPokemonNameWithAffix } from "#app/messages";
import i18next from "i18next";
describe("Move - Pollen Puff", () => { describe("Moves - Pollen Puff", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -26,80 +23,42 @@ describe("Move - Pollen Puff", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.moveset([MoveId.POLLEN_PUFF])
.ability(AbilityId.BALL_FETCH) .ability(AbilityId.BALL_FETCH)
.battleStyle("single") .battleStyle("single")
.criticalHits(false) .criticalHits(false)
.enemyLevel(100)
.enemySpecies(SpeciesId.MAGIKARP) .enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH); .enemyMoveset(MoveId.SPLASH);
}); });
it("should damage an enemy when used, or heal an ally for 50% max HP", async () => { it("should not heal more than once when the user has a source of multi-hit", async () => {
game.override.battleStyle("double").ability(AbilityId.PARENTAL_BOND); game.override.battleStyle("double").moveset([MoveId.POLLEN_PUFF, MoveId.ENDURE]).ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]); await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]);
const [_, omantye, karp1] = game.scene.getField(); const [_, rightPokemon] = game.scene.getPlayerField();
omantye.hp = 1;
game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2); rightPokemon.damageAndUpdate(rightPokemon.hp - 1);
game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
await game.toNextTurn();
expect(karp1.hp).toBeLessThan(karp1.getMaxHp()); game.move.select(MoveId.POLLEN_PUFF, 0, BattlerIndex.PLAYER_2);
expect(omantye.hp).toBeCloseTo(0.5 * omantye.getMaxHp() + 1, 1); game.move.select(MoveId.ENDURE, 1);
expect(game.phaseInterceptor.log).toContain("PokemonHealPhase");
});
it.todo("should display message & count as failed when hitting a full HP ally", async () => { await game.phaseInterceptor.to("BerryPhase");
game.override.battleStyle("double").ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]);
const [bulbasaur, omantye] = game.scene.getPlayerField(); // Pollen Puff heals with a ratio of 0.5, as long as Pollen Puff triggers only once the pokemon will always be <= (0.5 * Max HP) + 1
expect(rightPokemon.hp).toBeLessThanOrEqual(0.5 * rightPokemon.getMaxHp() + 1);
game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.toEndOfTurn();
// move failed without unshifting a phase
expect(omantye.hp).toBe(omantye.getMaxHp());
expect(bulbasaur.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(game.textInterceptor.logs).toContain(
i18next.t("battle:hpIsFull", {
pokemonName: getPokemonNameWithAffix(omantye),
}),
);
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
});
it("should not heal more than once if the user has a source of multi-hit", async () => {
game.override.battleStyle("double").ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]);
const [bulbasaur, omantye] = game.scene.getPlayerField();
omantye.hp = 1;
game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.toEndOfTurn();
expect(bulbasaur.turnData.hitCount).toBe(1);
expect(omantye.hp).toBeLessThanOrEqual(0.5 * omantye.getMaxHp() + 1);
expect(
game.phaseInterceptor.log.filter(l => l === "PokemonHealPhase"),
game.phaseInterceptor.log.join("\n"),
).toHaveLength(1);
}); });
it("should damage an enemy multiple times when the user has a source of multi-hit", async () => { it("should damage an enemy multiple times when the user has a source of multi-hit", async () => {
game.override.ability(AbilityId.PARENTAL_BOND); game.override.moveset([MoveId.POLLEN_PUFF]).ability(AbilityId.PARENTAL_BOND).enemyLevel(100);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]); await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
game.move.use(MoveId.POLLEN_PUFF); const target = game.scene.getEnemyPokemon()!;
await game.toEndOfTurn();
game.move.select(MoveId.POLLEN_PUFF);
await game.phaseInterceptor.to("BerryPhase");
const target = game.field.getEnemyPokemon();
expect(target.battleData.hitCount).toBe(2); expect(target.battleData.hitCount).toBe(2);
}); });
}); });

View File

@ -64,7 +64,6 @@ import { PostGameOverPhase } from "#app/phases/post-game-over-phase";
import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase"; import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase";
import type { PhaseClass, PhaseString } from "#app/@types/phase-types"; import type { PhaseClass, PhaseString } from "#app/@types/phase-types";
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
export interface PromptHandler { export interface PromptHandler {
phaseTarget?: string; phaseTarget?: string;
@ -144,7 +143,6 @@ export default class PhaseInterceptor {
[AttemptRunPhase, this.startPhase], [AttemptRunPhase, this.startPhase],
[SelectBiomePhase, this.startPhase], [SelectBiomePhase, this.startPhase],
[MysteryEncounterPhase, this.startPhase], [MysteryEncounterPhase, this.startPhase],
[PokemonHealPhase, this.startPhase],
[MysteryEncounterOptionSelectedPhase, this.startPhase], [MysteryEncounterOptionSelectedPhase, this.startPhase],
[MysteryEncounterBattlePhase, this.startPhase], [MysteryEncounterBattlePhase, this.startPhase],
[MysteryEncounterRewardsPhase, this.startPhase], [MysteryEncounterRewardsPhase, this.startPhase],