mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 14:29:28 +02:00
Wrote test and added documentation
This commit is contained in:
parent
36eb88bac6
commit
34e75899b3
@ -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) {
|
if (move !== this.moveId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionDeniedText(pokemon: Pokemon, move: Moves): string {
|
override selectionDeniedText(_pokemon: Pokemon, move: Moves): string {
|
||||||
return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name });
|
return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
src/test/moves/encore.test.ts
Normal file
59
src/test/moves/encore.test.ts
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user