pokerogue/test/moves/baneful-bunker.test.ts
Jimmybald1 3b36ab17e4
[Bug] Protect now tracks success chance properly (#5869)
* Protect rng now resets on new waves and fixed to look at all turns in the same wave.

* Added per-wave move history object to fix issues

@Jimmybald1 I added a commented out `console.log` in the protect code (L5797) for you to use for testing

* Added many tests

* Wave move history has to be looped in reverse

* Update src/data/moves/move.ts

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

* Update src/data/moves/move.ts

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

* comments

* Fixed forceEnemyMove references after merge

* Removed console log

Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>

* Fixed test message

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* Apply Biome

* Fix merge issues

* Fix Crafty Shield test

* Remove protect chance reset on wave change

* Fix merge issue

---------

Co-authored-by: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-08-05 07:35:14 +02:00

77 lines
2.3 KiB
TypeScript

import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
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
.battleStyle("single")
.moveset([MoveId.SLASH, MoveId.FLASH_CANNON])
.enemySpecies(SpeciesId.TOXAPEX)
.enemyAbility(AbilityId.INSOMNIA)
.enemyMoveset(MoveId.BANEFUL_BUNKER)
.startingLevel(100)
.enemyLevel(100);
});
function expectProtected() {
expect(game.scene.getEnemyPokemon()?.hp).toBe(game.scene.getEnemyPokemon()?.getMaxHp());
expect(game.scene.getPlayerPokemon()?.status?.effect).toBe(StatusEffect.POISON);
}
it("should protect the user and poison attackers that make contact", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
game.move.select(MoveId.SLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase", false);
expectProtected();
});
it("should ignore accuracy checks", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
game.move.select(MoveId.SLASH);
await game.phaseInterceptor.to("MoveEndPhase"); // baneful bunker
await game.move.forceMiss();
await game.phaseInterceptor.to("BerryPhase", false);
expectProtected();
});
it("should block non-contact moves without poisoning attackers", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.field.getPlayerPokemon();
const toxapex = game.field.getEnemyPokemon();
game.move.select(MoveId.FLASH_CANNON);
await game.phaseInterceptor.to("BerryPhase", false);
expect(toxapex.hp).toBe(toxapex.getMaxHp());
expect(charizard.status?.effect).toBeUndefined();
});
});