Imprison and Taunt Tests

This commit is contained in:
frutescens 2024-09-24 13:16:11 -07:00
parent 1f09561518
commit 11de99b43c
2 changed files with 60 additions and 13 deletions

View File

@ -4,8 +4,8 @@ import { Abilities } from "#enums/abilities";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MoveResult } from "#app/field/pokemon";
import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { ArenaTagType } from "#app/enums/arena-tag-type";
describe("Moves - Imprison", () => { describe("Moves - Imprison", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -25,28 +25,75 @@ describe("Moves - Imprison", () => {
game.override game.override
.battleType("single") .battleType("single")
.enemyAbility(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset([Moves.IMPRISON, Moves.SPLASH]) .enemyMoveset([Moves.IMPRISON, Moves.SPLASH, Moves.GROWL])
.enemySpecies(Species.SHUCKLE) .enemySpecies(Species.SHUCKLE)
.moveset([Moves.GROWL]); .moveset([Moves.TRANSFORM, Moves.SPLASH]);
}); });
it("Pokemon should not be able to use the same move consecutively", async () => { it("Pokemon under Imprison cannot use shared moves", async () => {
await game.classicMode.startBattle([Species.REGIELEKI]); await game.classicMode.startBattle([Species.REGIELEKI]);
const playerPokemon = game.scene.getPlayerPokemon(); const playerPokemon = game.scene.getPlayerPokemon();
// First turn, Player Pokemon fails usin game.move.select(Moves.TRANSFORM);
game.move.select(Moves.GROWL);
await game.forceEnemyMove(Moves.IMPRISON); await game.forceEnemyMove(Moves.IMPRISON);
await game.toNextTurn(); await game.toNextTurn();
const move1 = playerPokemon?.getLastXMoves(1)[0]!; const playerMoveset = playerPokemon!.getMoveset().map(x => x?.moveId);
expect(move1.move).toBe(Moves.GROWL); const enemyMoveset = game.scene.getEnemyPokemon()!.getMoveset().map(x => x?.moveId);
expect(move1.result).toBe(MoveResult.SUCCESS); expect(enemyMoveset.includes(playerMoveset[0])).toBeTruthy();
expect(playerPokemon?.getTag(BattlerTagType.IMPRISON)).toBeDefined(); const imprisonArenaTag = game.scene.arena.getTag(ArenaTagType.IMPRISON);
const imprisonBattlerTag = playerPokemon!.getTag(BattlerTagType.IMPRISON);
expect(imprisonArenaTag).toBeDefined();
expect(imprisonBattlerTag).toBeDefined();
// Second turn, Taunt forces Struggle to occur // Second turn, Imprison forces Struggle to occur
game.move.select(Moves.GROWL); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
const move1 = playerPokemon?.getLastXMoves(1)[0]!;
expect(move1.move).toBe(Moves.STRUGGLE);
});
it("Imprison applies to Pokemon switched into Battle", async () => {
game.override.battleType("single");
await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]);
const playerPokemon1 = game.scene.getPlayerPokemon();
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.IMPRISON);
await game.toNextTurn();
const imprisonArenaTag = game.scene.arena.getTag(ArenaTagType.IMPRISON);
const imprisonBattlerTag1 = playerPokemon1!.getTag(BattlerTagType.IMPRISON);
expect(imprisonArenaTag).toBeDefined();
expect(imprisonBattlerTag1).toBeDefined();
// Second turn, Imprison forces Struggle to occur
game.doSwitchPokemon(1);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
const playerPokemon2 = game.scene.getPlayerPokemon();
const imprisonBattlerTag2 = playerPokemon2!.getTag(BattlerTagType.IMPRISON);
expect(playerPokemon1).not.toEqual(playerPokemon2);
expect(imprisonBattlerTag2).toBeDefined();
});
it("The effects of Imprison only end when the source is no longer active", async () => {
game.override.battleType("single");
game.override.moveset([Moves.SPLASH, Moves.IMPRISON]);
await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]);
const playerPokemon = game.scene.getPlayerPokemon();
const enemyPokemon = game.scene.getEnemyPokemon();
game.move.select(Moves.IMPRISON);
await game.forceEnemyMove(Moves.IMPRISON);
await game.toNextTurn();
expect(game.scene.arena.getTag(ArenaTagType.IMPRISON)).toBeDefined();
expect(enemyPokemon!.getTag(BattlerTagType.IMPRISON)).toBeDefined();
game.doSwitchPokemon(1);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
expect(playerPokemon?.isActive(true)).toBeFalsy();
expect(enemyPokemon!.getTag(BattlerTagType.IMPRISON)).toBeUndefined();
}); });
}); });

View File

@ -35,7 +35,7 @@ describe("Moves - Taunt", () => {
const playerPokemon = game.scene.getPlayerPokemon(); const playerPokemon = game.scene.getPlayerPokemon();
// First turn, Player Pokemon succeeds using Growl // First turn, Player Pokemon succeeds using Growl without Torment
game.move.select(Moves.GROWL); game.move.select(Moves.GROWL);
await game.forceEnemyMove(Moves.TAUNT); await game.forceEnemyMove(Moves.TAUNT);
await game.toNextTurn(); await game.toNextTurn();