pokerogue/test/moves/aurora_veil.test.ts
Bertie690 2fe50cb761
[Test] Made game.move.select fail if move not in moveset (#5998)
* Made `game.phaseInterceptor` fail if move not in moveset

also added a few assorted doc fixes

* Fixed fail comment

* added `map` statement

* Fixed tests

* Fixed test

* Fixed test and comment

* Fixed tests

* Fixed test v2

* Fixed various tests

* Update error msg to not use fullcaps

* Fixed remaining tests

* Fixed test 0.5

* Fixed up tetss

* Fixed test

* Fixed imposter tests

* Fixed imposter tests

* Fiexd remainig tests

* Marked test as TODO

wasn't as if it was doing anything beforehand but w/e

* Update moveHelper.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update moveHelper.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Apply Biome

* Update comment in `spikes.test.ts`

* Add faint checks to Spikes test

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-07-02 12:46:26 -07:00

157 lines
4.8 KiB
TypeScript

import type BattleScene from "#app/battle-scene";
import { ArenaTagSide } from "#enums/arena-tag-side";
import type Move from "#app/data/moves/move";
import { allMoves } from "#app/data/data-lists";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import type Pokemon from "#app/field/pokemon";
import { NumberHolder } from "#app/utils/common";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
let globalScene: BattleScene;
describe("Moves - Aurora Veil", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const singleBattleMultiplier = 0.5;
const doubleBattleMultiplier = 2732 / 4096;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
globalScene = game.scene;
game.override
.battleStyle("single")
.ability(AbilityId.BALL_FETCH)
.moveset([MoveId.ABSORB, MoveId.ROCK_SLIDE, MoveId.TACKLE])
.enemyLevel(100)
.enemySpecies(SpeciesId.MAGIKARP)
.enemyMoveset(MoveId.AURORA_VEIL)
.criticalHits(false)
.weather(WeatherType.HAIL);
});
it("reduces damage of physical attacks by half in a single battle", async () => {
const moveToUse = MoveId.TACKLE;
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
game.move.select(moveToUse);
await game.toEndOfTurn();
const mockedDmg = getMockedMoveDamage(
game.field.getEnemyPokemon(),
game.field.getPlayerPokemon(),
allMoves[moveToUse],
);
expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier);
});
it("reduces damage of physical attacks by a third in a double battle", async () => {
game.override.battleStyle("double");
const moveToUse = MoveId.ROCK_SLIDE;
await game.classicMode.startBattle([SpeciesId.SHUCKLE, SpeciesId.SHUCKLE]);
game.move.select(moveToUse);
game.move.select(moveToUse, 1);
await game.toEndOfTurn();
const mockedDmg = getMockedMoveDamage(
game.field.getEnemyPokemon(),
game.field.getPlayerPokemon(),
allMoves[moveToUse],
);
expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier);
});
it("reduces damage of special attacks by half in a single battle", async () => {
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
game.move.use(MoveId.ABSORB);
await game.toEndOfTurn();
const mockedDmg = getMockedMoveDamage(
game.field.getEnemyPokemon(),
game.field.getPlayerPokemon(),
allMoves[MoveId.ABSORB],
);
expect(mockedDmg).toBe(allMoves[MoveId.ABSORB].power * singleBattleMultiplier);
});
it("reduces damage of special attacks by a third in a double battle", async () => {
game.override.battleStyle("double");
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
game.move.use(MoveId.ABSORB);
await game.toEndOfTurn();
const mockedDmg = getMockedMoveDamage(
game.field.getEnemyPokemon(),
game.field.getPlayerPokemon(),
allMoves[MoveId.ABSORB],
);
expect(mockedDmg).toBe(allMoves[MoveId.ABSORB].power * doubleBattleMultiplier);
});
it("does not affect critical hits", async () => {
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
game.move.use(MoveId.WICKED_BLOW);
await game.toEndOfTurn();
const mockedDmg = getMockedMoveDamage(
game.field.getEnemyPokemon(),
game.field.getPlayerPokemon(),
allMoves[MoveId.WICKED_BLOW],
);
expect(mockedDmg).toBe(allMoves[MoveId.WICKED_BLOW].power);
});
});
/**
* Calculates the damage of a move multiplied by screen's multiplier, Auroa Veil in this case {@linkcode MoveId.AURORA_VEIL}.
* Please note this does not consider other damage calculations except the screen multiplier.
*
* @param defender - The defending Pokémon.
* @param attacker - The attacking Pokémon.
* @param move - The move being used.
* @returns The calculated move damage considering any weakening effects.
*/
const getMockedMoveDamage = (defender: Pokemon, attacker: Pokemon, move: Move) => {
const multiplierHolder = new NumberHolder(1);
const side = defender.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY;
if (globalScene.arena.getTagOnSide(ArenaTagType.AURORA_VEIL, side)) {
if (move.getAttrs("CritOnlyAttr").length === 0) {
globalScene.arena.applyTagsForSide(
ArenaTagType.AURORA_VEIL,
side,
false,
attacker,
move.category,
multiplierHolder,
);
}
}
return move.power * multiplierHolder.value;
};