pokerogue/test/moves/secret_power.test.ts
Dean 1d7f916240
[Refactor] Align ability display with mainline (#5267)
* Stop ShowAbilityPhase from ending until the bar has popped out

* Remove ability bar hiding from messagePhase

* Remove abilityBar reference from base Phase class

* Add HideAbilityPhase to hide ability bar after effects

* Add willSucceed to ability attrs

* Update AbAttrs and PostInitAbAttrs

* Update PreDefendAbAttrs

* Update postDefend, postMoveUsed, StatStage, postSetStatus, and PostDamage

* Update preAttack and fieldStat

* Partially implement postAttack

* Finish PostAttack

* Update PostSummon

* Update PreSwitchOut

* Update preStatStageChange

* Update PostStatStageChange, PreSetStatus, PreApplyBattlerTag

* Update postTurn and preWeatherEffect

* Update postWeatherChange

* Update postWeatherChange

* Update PostTerrainChange

* Update CheckTrapped and PostBattle

* Update postFaint

* Update PostItemLost

* Bug fixes from test cases

* Fix intimidate display

* Stop trace from displaying itself

* Rename to canApply

* Fix ability displays using getTriggerMessage

* Ensure abilities which are mistakenly shown are still hidden

* Fix ability bar showing the wrong ability with imposter

* Add canApply for imposter

* Update abilities using promises and `trySet...` functions

* Committing overrides changes is bad

* Document apply and canApply

* Update PreLeaveFieldAbAttr

* Remove boolean return type apply functions

* Remove redundant  assignment

* Remove ability display from abilities that shouldn't have it

* Move queueAbilityDisplay to battlescene

* Remove unused shown variable

* Minor changes

* Fix using id instead of battlerindex in queueAbilityDisplay

* Fix PostBattleInitFormChangeAbAttr displaying

* Prevent crashes in case an ability for a pokemon not on the field is shown

* Stop more abilities from displaying

* Move enemy ability bar to the right side

* Automatically reload bar if shown while already out, fix specific abilities

* Remove duplicate call to clearPhaseQueueSplice

* Remove ShowAbilityPhase import from ability.ts

* Update PostDefendTypeChangeAbAttr to use PokemonType

* Update PostSummonAddArenaTagAbAttr

* Minor changes
2025-03-16 02:51:02 +00:00

95 lines
3.5 KiB
TypeScript

import { Abilities } from "#enums/abilities";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Stat } from "#enums/stat";
import { allMoves } from "#app/data/moves/move";
import { Species } from "#enums/species";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { StatusEffect } from "#enums/status-effect";
import { BattlerIndex } from "#app/battle";
import { ArenaTagType } from "#enums/arena-tag-type";
import { ArenaTagSide } from "#app/data/arena-tag";
import { allAbilities, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
describe("Moves - Secret Power", () => {
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
.moveset([Moves.SECRET_POWER])
.ability(Abilities.BALL_FETCH)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyLevel(60)
.enemyAbility(Abilities.BALL_FETCH);
});
it("Secret Power checks for an active terrain first then looks at the biome for its secondary effect", async () => {
game.override.startingBiome(Biome.VOLCANO).enemyMoveset([Moves.SPLASH, Moves.MISTY_TERRAIN]);
vi.spyOn(allMoves[Moves.SECRET_POWER], "chance", "get").mockReturnValue(100);
await game.classicMode.startBattle([Species.FEEBAS]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// No Terrain + Biome.VOLCANO --> Burn
game.move.select(Moves.SECRET_POWER);
await game.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN);
// Misty Terrain --> SpAtk -1
game.move.select(Moves.SECRET_POWER);
await game.forceEnemyMove(Moves.MISTY_TERRAIN);
await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1);
});
it("Secret Power's effect chance is doubled by Serene Grace, but not by the 'rainbow' effect from Fire/Water Pledge", async () => {
game.override
.moveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.SECRET_POWER, Moves.SPLASH])
.ability(Abilities.SERENE_GRACE)
.enemyMoveset([Moves.SPLASH])
.battleType("double");
await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
const sereneGraceAttr = allAbilities[Abilities.SERENE_GRACE].getAttrs(MoveEffectChanceMultiplierAbAttr)[0];
vi.spyOn(sereneGraceAttr, "canApply");
game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY);
game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2);
await game.phaseInterceptor.to("TurnEndPhase");
let rainbowEffect = game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER);
expect(rainbowEffect).toBeDefined();
rainbowEffect = rainbowEffect!;
vi.spyOn(rainbowEffect, "apply");
game.move.select(Moves.SECRET_POWER, 0, BattlerIndex.ENEMY);
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to("BerryPhase", false);
expect(sereneGraceAttr.canApply).toHaveBeenCalledOnce();
expect(sereneGraceAttr.canApply).toHaveLastReturnedWith(true);
expect(rainbowEffect.apply).toHaveBeenCalledTimes(0);
});
});