Fixed up pollen puff tests

This commit is contained in:
Bertie690 2025-06-17 16:07:53 -04:00
parent 3d20235fa5
commit aee33fe625
2 changed files with 60 additions and 17 deletions

View File

@ -5,8 +5,11 @@ 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("Moves - Pollen Puff", () => { describe("Move - Pollen Puff", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -23,42 +26,80 @@ describe("Moves - 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 not heal more than once when the user has a source of multi-hit", async () => { it("should damage an enemy when used, or heal an ally for 50% max HP", async () => {
game.override.battleStyle("double").moveset([MoveId.POLLEN_PUFF, MoveId.ENDURE]).ability(AbilityId.PARENTAL_BOND); game.override.battleStyle("double").ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]); await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]);
const [_, rightPokemon] = game.scene.getPlayerField(); const [_, omantye, karp1] = game.scene.getField();
omantye.hp = 1;
rightPokemon.damageAndUpdate(rightPokemon.hp - 1); game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
game.move.use(MoveId.POLLEN_PUFF, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
await game.toNextTurn();
game.move.select(MoveId.POLLEN_PUFF, 0, BattlerIndex.PLAYER_2); expect(karp1.hp).toBeLessThan(karp1.getMaxHp());
game.move.select(MoveId.ENDURE, 1); expect(omantye.hp).toBeCloseTo(0.5 * omantye.getMaxHp() + 1, 1);
expect(game.phaseInterceptor.log).toContain("PokemonHealPhase");
});
await game.phaseInterceptor.to("BerryPhase"); it.todo("should display message & count as failed when hitting a full HP ally", async () => {
game.override.battleStyle("double").ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.OMANYTE]);
// 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 const [bulbasaur, omantye] = game.scene.getPlayerField();
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.moveset([MoveId.POLLEN_PUFF]).ability(AbilityId.PARENTAL_BOND).enemyLevel(100); game.override.ability(AbilityId.PARENTAL_BOND);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]); await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
const target = game.scene.getEnemyPokemon()!; game.move.use(MoveId.POLLEN_PUFF);
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,6 +64,7 @@ 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;
@ -143,6 +144,7 @@ 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],