[Bug][Beta] Fix Hyper Beam, etc. permanently recharging (#3115)
* Fix Hyper Beam, etc. permanently recharging * Fix override in hyper beam test
This commit is contained in:
parent
1563b8e581
commit
9c80e6d80d
|
@ -92,25 +92,29 @@ export interface TerrainBattlerTag {
|
||||||
terrainTypes: TerrainType[];
|
terrainTypes: TerrainType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BattlerTag that represents the "recharge" effects of moves like Hyper Beam.
|
||||||
|
*/
|
||||||
export class RechargingTag extends BattlerTag {
|
export class RechargingTag extends BattlerTag {
|
||||||
constructor(sourceMove: Moves) {
|
constructor(sourceMove: Moves) {
|
||||||
super(BattlerTagType.RECHARGING, BattlerTagLapseType.PRE_MOVE, 1, sourceMove);
|
super(BattlerTagType.RECHARGING, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 2, sourceMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
super.onAdd(pokemon);
|
super.onAdd(pokemon);
|
||||||
|
|
||||||
|
// Queue a placeholder move for the Pokemon to "use" next turn
|
||||||
pokemon.getMoveQueue().push({ move: Moves.NONE, targets: [] });
|
pokemon.getMoveQueue().push({ move: Moves.NONE, targets: [] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Cancels the source's move this turn and queues a "__ must recharge!" message */
|
||||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
super.lapse(pokemon, lapseType);
|
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||||
|
pokemon.scene.queueMessage(i18next.t("battle:battlerTagsRechargingLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
||||||
pokemon.scene.queueMessage(i18next.t("battle:battlerTagsRechargingLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
(pokemon.scene.getCurrentPhase() as MovePhase).cancel();
|
||||||
(pokemon.scene.getCurrentPhase() as MovePhase).cancel();
|
pokemon.getMoveQueue().shift();
|
||||||
pokemon.getMoveQueue().shift();
|
}
|
||||||
|
return super.lapse(pokemon, lapseType);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
|
import overrides from "#app/overrides";
|
||||||
|
import { Abilities } from "#app/enums/abilities.js";
|
||||||
|
import { Species } from "#app/enums/species.js";
|
||||||
|
import { Moves } from "#app/enums/moves.js";
|
||||||
|
import { allMoves } from "#app/data/move.js";
|
||||||
|
import { getMovePosition } from "../utils/gameManagerUtils";
|
||||||
|
import { BerryPhase, TurnEndPhase } from "#app/phases.js";
|
||||||
|
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
|
||||||
|
|
||||||
|
const TIMEOUT = 20 * 1000; // 20 sec timeout for all tests
|
||||||
|
|
||||||
|
describe("Moves - Hyper Beam", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
|
||||||
|
vi.spyOn(overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single");
|
||||||
|
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH);
|
||||||
|
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SNORLAX);
|
||||||
|
vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH);
|
||||||
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.SPLASH));
|
||||||
|
|
||||||
|
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.HYPER_BEAM, Moves.TACKLE]);
|
||||||
|
vi.spyOn(allMoves[Moves.HYPER_BEAM], "accuracy", "get").mockReturnValue(100);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should force the user to recharge on the next turn (and only that turn)",
|
||||||
|
async () => {
|
||||||
|
await game.startBattle([Species.MAGIKARP]);
|
||||||
|
|
||||||
|
const leadPokemon = game.scene.getPlayerPokemon();
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.HYPER_BEAM));
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
||||||
|
expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined();
|
||||||
|
|
||||||
|
const enemyPostAttackHp = enemyPokemon.hp;
|
||||||
|
|
||||||
|
/** Game should progress without a new command from the player */
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
expect(enemyPokemon.hp).toBe(enemyPostAttackHp);
|
||||||
|
expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined();
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(BerryPhase, false);
|
||||||
|
|
||||||
|
expect(enemyPokemon.hp).toBeLessThan(enemyPostAttackHp);
|
||||||
|
}, TIMEOUT
|
||||||
|
);
|
||||||
|
});
|
Loading…
Reference in New Issue