mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-25 06:25:52 +02:00
* prevent double-application of status contact abilities and switch out abilities * use SwitchPhase for ForceSwitchOutAbAttr instead of switchOut() * add tests for baton pass/uturn * PR comments * Update src/test/moves/baton_pass.test.ts * add test for forced switch after mutual KO + revive * tweak condition to fix uturn/baton pass * improve docs * style/typo nits from CR Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * CR feedback * use doSelectPartyPokemon + rename * int -> number Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com>
99 lines
3.5 KiB
TypeScript
99 lines
3.5 KiB
TypeScript
import { Abilities } from "#app/enums/abilities.js";
|
|
import { SwitchPhase, TurnEndPhase } from "#app/phases";
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { StatusEffect } from "#app/enums/status-effect.js";
|
|
import { SPLASH_ONLY } from "../utils/testUtils";
|
|
|
|
describe("Moves - U-turn", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
game.override
|
|
.battleType("single")
|
|
.enemySpecies(Species.GENGAR)
|
|
.startingLevel(90)
|
|
.startingWave(97)
|
|
.moveset([Moves.U_TURN])
|
|
.enemyMoveset(SPLASH_ONLY)
|
|
.disableCrits();
|
|
});
|
|
|
|
it("triggers regenerator a single time when a regenerator user switches out with u-turn", async() => {
|
|
// arrange
|
|
const playerHp = 1;
|
|
game.override.ability(Abilities.REGENERATOR);
|
|
await game.startBattle([
|
|
Species.RAICHU,
|
|
Species.SHUCKLE
|
|
]);
|
|
game.scene.getPlayerPokemon().hp = playerHp;
|
|
|
|
// act
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN));
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
// assert
|
|
expect(game.scene.getParty()[1].hp).toEqual(Math.floor(game.scene.getParty()[1].getMaxHp() * 0.33 + playerHp));
|
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
|
expect(game.scene.getPlayerPokemon().species.speciesId).toBe(Species.SHUCKLE);
|
|
}, 20000);
|
|
|
|
it("triggers rough skin on the u-turn user before a new pokemon is switched in", async() => {
|
|
// arrange
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN);
|
|
await game.startBattle([
|
|
Species.RAICHU,
|
|
Species.SHUCKLE
|
|
]);
|
|
|
|
// act
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN));
|
|
game.doSelectPartyPokemon(1);
|
|
await game.phaseInterceptor.to(SwitchPhase, false);
|
|
|
|
// assert
|
|
expect(game.scene.getPlayerPokemon().hp).not.toEqual(game.scene.getPlayerPokemon().getMaxHp());
|
|
expect(game.scene.getEnemyPokemon().battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
|
expect(game.scene.getPlayerPokemon().species.speciesId).toEqual(Species.RAICHU);
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
}, 20000);
|
|
|
|
it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async() => {
|
|
// arrange
|
|
game.override.enemyAbility(Abilities.POISON_POINT);
|
|
await game.startBattle([
|
|
Species.RAICHU,
|
|
Species.SHUCKLE
|
|
]);
|
|
vi.spyOn(game.scene.getEnemyPokemon(), "randSeedInt").mockReturnValue(0);
|
|
|
|
// act
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN));
|
|
await game.phaseInterceptor.to(SwitchPhase, false);
|
|
|
|
// assert
|
|
expect(game.scene.getPlayerPokemon().status?.effect).toEqual(StatusEffect.POISON);
|
|
expect(game.scene.getPlayerPokemon().species.speciesId).toEqual(Species.RAICHU);
|
|
expect(game.scene.getEnemyPokemon().battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
|
}, 20000);
|
|
});
|