2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-07-25 16:18:47 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-09-23 12:37:21 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
2024-06-13 09:49:40 -04:00
|
|
|
|
|
|
|
// See also: TypeImmunityAbAttr
|
|
|
|
describe("Abilities - Volt Absorb", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 16:18:47 -07:00
|
|
|
game.override.disableCrits();
|
2024-06-13 09:49:40 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it("does not activate when CHARGE is used", async () => {
|
|
|
|
const moveToUse = Moves.CHARGE;
|
|
|
|
const ability = Abilities.VOLT_ABSORB;
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ moveToUse ]);
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(ability);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE ]);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.DUSKULL);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.BALL_FETCH);
|
2024-06-13 09:49:40 -04:00
|
|
|
|
2024-09-23 12:37:21 -07:00
|
|
|
await game.classicMode.startBattle();
|
2024-06-13 09:49:40 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-13 09:49:40 -04:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(1);
|
|
|
|
expect(playerPokemon.getTag(BattlerTagType.CHARGED)).toBeDefined();
|
2024-06-13 09:49:40 -04:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
|
|
|
});
|
2024-10-23 08:08:40 -07:00
|
|
|
|
2024-09-23 12:37:21 -07:00
|
|
|
it("should activate regardless of accuracy checks", async () => {
|
|
|
|
game.override.moveset(Moves.THUNDERBOLT);
|
|
|
|
game.override.enemyMoveset(Moves.SPLASH);
|
|
|
|
game.override.enemySpecies(Species.MAGIKARP);
|
|
|
|
game.override.enemyAbility(Abilities.VOLT_ABSORB);
|
|
|
|
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.THUNDERBOLT);
|
|
|
|
enemyPokemon.hp = enemyPokemon.hp - 1;
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-23 12:37:21 -07:00
|
|
|
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
|
|
|
|
|
|
await game.move.forceMiss();
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
|
|
});
|
2024-10-23 08:08:40 -07:00
|
|
|
|
2024-10-15 07:04:26 -07:00
|
|
|
it("regardless of accuracy should not trigger on pokemon in semi invulnerable state", async () => {
|
|
|
|
game.override.moveset(Moves.THUNDERBOLT);
|
|
|
|
game.override.enemyMoveset(Moves.DIVE);
|
|
|
|
game.override.enemySpecies(Species.MAGIKARP);
|
|
|
|
game.override.enemyAbility(Abilities.VOLT_ABSORB);
|
|
|
|
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.THUNDERBOLT);
|
|
|
|
enemyPokemon.hp = enemyPokemon.hp - 1;
|
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
|
|
|
});
|
2024-06-13 09:49:40 -04:00
|
|
|
});
|