2024-09-01 18:21:11 -07:00
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
import { Moves } from "#app/enums/moves";
|
|
|
|
import { Species } from "#app/enums/species";
|
2024-09-07 21:37:37 -07:00
|
|
|
import { HitResult } from "#app/field/pokemon";
|
2024-09-01 18:21:11 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
describe("Abilities - Tera Shell", () => {
|
|
|
|
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")
|
|
|
|
.ability(Abilities.TERA_SHELL)
|
|
|
|
.moveset([Moves.SPLASH])
|
|
|
|
.enemySpecies(Species.SNORLAX)
|
|
|
|
.enemyAbility(Abilities.INSOMNIA)
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset([Moves.MACH_PUNCH])
|
2024-09-01 18:21:11 -07:00
|
|
|
.startingLevel(100)
|
|
|
|
.enemyLevel(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should change the effectiveness of non-resisted attacks when the source is at full HP",
|
|
|
|
async () => {
|
|
|
|
await game.classicMode.startBattle([Species.SNORLAX]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
vi.spyOn(playerPokemon, "getMoveEffectiveness");
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.5);
|
|
|
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(2);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-01 18:21:11 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should not override type immunities",
|
|
|
|
async () => {
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.SHADOW_SNEAK]);
|
2024-09-01 18:21:11 -07:00
|
|
|
|
|
|
|
await game.classicMode.startBattle([Species.SNORLAX]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
vi.spyOn(playerPokemon, "getMoveEffectiveness");
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-01 18:21:11 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should not override type multipliers less than 0.5x",
|
|
|
|
async () => {
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.QUICK_ATTACK]);
|
2024-09-01 18:21:11 -07:00
|
|
|
|
|
|
|
await game.classicMode.startBattle([Species.AGGRON]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
vi.spyOn(playerPokemon, "getMoveEffectiveness");
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.25);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-01 18:21:11 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should not affect the effectiveness of fixed-damage moves",
|
|
|
|
async () => {
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.DRAGON_RAGE]);
|
2024-09-01 18:21:11 -07:00
|
|
|
|
|
|
|
await game.classicMode.startBattle([Species.CHARIZARD]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
vi.spyOn(playerPokemon, "apply");
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.EFFECTIVE);
|
|
|
|
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp() - 40);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-01 18:21:11 -07:00
|
|
|
);
|
|
|
|
});
|