2024-09-14 17:11:54 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-14 17:11:54 -07:00
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { BattlerIndex } from "#app/battle";
|
|
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-09-14 17:11:54 -07:00
|
|
|
describe("Moves - Baneful Bunker", () => {
|
|
|
|
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");
|
|
|
|
|
|
|
|
game.override.moveset(Moves.SLASH);
|
|
|
|
|
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
|
|
|
game.override.enemyAbility(Abilities.INSOMNIA);
|
|
|
|
game.override.enemyMoveset(Moves.BANEFUL_BUNKER);
|
|
|
|
|
|
|
|
game.override.startingLevel(100);
|
|
|
|
game.override.enemyLevel(100);
|
|
|
|
});
|
|
|
|
test(
|
|
|
|
"should protect the user and poison attackers that make contact",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
|
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.SLASH);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
|
|
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy();
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-14 17:11:54 -07:00
|
|
|
);
|
|
|
|
test(
|
|
|
|
"should protect the user and poison attackers that make contact, regardless of accuracy checks",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
|
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.SLASH);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
|
|
|
|
|
|
await game.move.forceMiss();
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
|
|
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy();
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-14 17:11:54 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should not poison attackers that don't make contact",
|
|
|
|
async () => {
|
|
|
|
game.override.moveset(Moves.FLASH_CANNON);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
|
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.FLASH_CANNON);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-14 17:11:54 -07:00
|
|
|
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
|
|
|
|
|
|
await game.move.forceMiss();
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
|
|
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy();
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-14 17:11:54 -07:00
|
|
|
);
|
|
|
|
});
|