diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index d2290fd92a3..646ec44b2d2 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -969,14 +969,20 @@ export class EncoreTag extends MoveRestrictionBattlerTag { } } - public isMoveRestricted(move: Moves, user?: Pokemon): boolean { + /** + * Checks if the move matches the moveId stored within the tag and returns a boolean value + * @param move {@linkcode Moves} the move selected + * @param user {@linkcode Pokemon} + * @returns `true` if the move does not match with the moveId stored and as a result, restricted + */ + override isMoveRestricted(move: Moves, _user?: Pokemon): boolean { if (move !== this.moveId) { return true; } return false; } - selectionDeniedText(pokemon: Pokemon, move: Moves): string { + override selectionDeniedText(_pokemon: Pokemon, move: Moves): string { return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name }); } diff --git a/src/test/moves/encore.test.ts b/src/test/moves/encore.test.ts new file mode 100644 index 00000000000..928848b4367 --- /dev/null +++ b/src/test/moves/encore.test.ts @@ -0,0 +1,59 @@ +import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BattlerIndex } from "#app/battle"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Moves - Encore", () => { + 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 + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH); + }); + + it("Pokemon under both Encore and Torment should alternate between Struggle and restricted move", async () => { + const turnOrder = [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]; + game.override.moveset([ Moves.ENCORE, Moves.TORMENT, Moves.SPLASH ]); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + const enemyPokemon = game.scene.getEnemyPokemon(); + game.move.select(Moves.ENCORE); + await game.setTurnOrder(turnOrder); + await game.phaseInterceptor.to("BerryPhase"); + expect(enemyPokemon?.getTag(BattlerTagType.ENCORE)).toBeDefined(); + + await game.toNextTurn(); + game.move.select(Moves.TORMENT); + await game.setTurnOrder(turnOrder); + await game.phaseInterceptor.to("BerryPhase"); + expect(enemyPokemon?.getTag(BattlerTagType.TORMENT)).toBeDefined(); + + await game.toNextTurn(); + game.move.select(Moves.SPLASH); + await game.setTurnOrder(turnOrder); + await game.phaseInterceptor.to("BerryPhase"); + const lastMove = enemyPokemon?.getLastXMoves()[0]; + expect(lastMove?.move).toBe(Moves.STRUGGLE); + }); +});