mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
181 lines
5.7 KiB
TypeScript
181 lines
5.7 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, vi } 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.phaseInterceptor.to("TurnEndPhase");
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.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.phaseInterceptor.to("TurnEndPhase");
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.getPlayerPokemon()!,
|
|
allMoves[moveToUse],
|
|
);
|
|
|
|
expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier);
|
|
});
|
|
|
|
it("reduces damage of special attacks by half in a single battle", async () => {
|
|
const moveToUse = MoveId.ABSORB;
|
|
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
|
|
|
|
game.move.select(moveToUse);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.getPlayerPokemon()!,
|
|
allMoves[moveToUse],
|
|
);
|
|
|
|
expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier);
|
|
});
|
|
|
|
it("reduces damage of special attacks by a third in a double battle", async () => {
|
|
game.override.battleStyle("double");
|
|
|
|
const moveToUse = MoveId.DAZZLING_GLEAM;
|
|
await game.classicMode.startBattle([SpeciesId.SHUCKLE, SpeciesId.SHUCKLE]);
|
|
|
|
game.move.select(moveToUse);
|
|
game.move.select(moveToUse, 1);
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.getPlayerPokemon()!,
|
|
allMoves[moveToUse],
|
|
);
|
|
|
|
expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier);
|
|
});
|
|
|
|
it("does not affect physical critical hits", async () => {
|
|
game.override.moveset([MoveId.WICKED_BLOW]);
|
|
const moveToUse = MoveId.WICKED_BLOW;
|
|
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
|
|
|
|
game.move.select(moveToUse);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.getPlayerPokemon()!,
|
|
allMoves[moveToUse],
|
|
);
|
|
expect(mockedDmg).toBe(allMoves[moveToUse].power);
|
|
});
|
|
|
|
it("does not affect critical hits", async () => {
|
|
game.override.moveset([MoveId.FROST_BREATH]);
|
|
const moveToUse = MoveId.FROST_BREATH;
|
|
vi.spyOn(allMoves[MoveId.FROST_BREATH], "accuracy", "get").mockReturnValue(100);
|
|
await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
|
|
|
|
game.move.select(moveToUse);
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
const mockedDmg = getMockedMoveDamage(
|
|
game.scene.getEnemyPokemon()!,
|
|
game.scene.getPlayerPokemon()!,
|
|
allMoves[moveToUse],
|
|
);
|
|
expect(mockedDmg).toBe(allMoves[moveToUse].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;
|
|
};
|