Update tests

This commit is contained in:
NightKev 2024-08-08 14:41:02 -07:00
parent 0692ef4fe7
commit 97b1c8ce54
2 changed files with 32 additions and 65 deletions

View File

@ -1,5 +1,5 @@
import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims"; import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { BattleEndPhase, MoveEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchPhase, SwitchSummonPhase } from "../phases"; import { BattleEndPhase, MessagePhase, MoveEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, PokemonHealPhase, StatChangePhase, SwitchPhase, SwitchSummonPhase } from "../phases";
import { BattleStat, getBattleStatName } from "./battle-stat"; import { BattleStat, getBattleStatName } from "./battle-stat";
import { EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerableTag, StockpilingTag, TypeBoostTag } from "./battler-tags"; import { EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerableTag, StockpilingTag, TypeBoostTag } from "./battler-tags";
import { getPokemonNameWithAffix } from "../messages"; import { getPokemonNameWithAffix } from "../messages";

View File

@ -1,24 +1,16 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser"; import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager"; import GameManager from "#app/test/utils/gameManager";
import * as overrides from "#app/overrides"; import { CommandPhase, SelectTargetPhase, TurnEndPhase } from "#app/phases";
import {
CommandPhase,
SelectTargetPhase,
TurnEndPhase,
} from "#app/phases";
import { getMovePosition } from "#app/test/utils/gameManagerUtils"; import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { BattlerIndex } from "#app/battle.js"; import { BattlerIndex } from "#app/battle.js";
import { Stat } from "#app/data/pokemon-stat"; import { Abilities } from "#app/enums/abilities.js";
import { ArenaTagType } from "#app/enums/arena-tag-type.js"; import { mockTurnOrder } from "../utils/testUtils";
import { ArenaTagSide } from "#app/data/arena-tag.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
const SAFEGUARD = Moves.SAFEGUARD;
describe("Moves - Safeguard", () => { describe("Moves - Safeguard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -35,57 +27,46 @@ describe("Moves - Safeguard", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); game.override
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.AMOONGUSS); .battleType("single")
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.DEOXYS); .enemySpecies(Species.DRATINI)
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100); .enemyMoveset(Array(4).fill(Moves.SAFEGUARD))
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100); .enemyAbility(Abilities.BALL_FETCH)
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPORE, Moves.SPORE, Moves.SPORE, Moves.SPORE]); .enemyLevel(5)
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SAFEGUARD, Moves.SAFEGUARD, Moves.SAFEGUARD, Moves.SAFEGUARD]); .starterSpecies(Species.DRATINI)
.moveset([Moves.NUZZLE, Moves.SPORE])
.ability(Abilities.BALL_FETCH);
}); });
it("protects from nuzzle status", it("protects from nuzzle status",
async () => { async () => {
await game.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SENTRET); game.doAttack(getMovePosition(game.scene, 0, Moves.NUZZLE));
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.NUZZLE, await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
Moves.NUZZLE, await game.toNextTurn();
Moves.NUZZLE,
Moves.NUZZLE]);
await game.startBattle([Species.DEOXYS]);
const enemyPokemon = game.scene.getEnemyField();
const playerPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, SAFEGUARD)); expect(enemy.status).toBeUndefined();
expect(enemyPokemon[0].status).toBe(undefined);
expect(playerPokemon[0].status).toBe(undefined);
}, TIMEOUT }, TIMEOUT
); );
it("protects from spore", it("protects from spore",
async () => { async () => {
await game.startBattle([Species.DEOXYS]); await game.startBattle();
const enemyPokemon = game.scene.getEnemyField(); const enemyPokemon = game.scene.getEnemyPokemon()!;
const playerPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.SAFEGUARD)); game.doAttack(getMovePosition(game.scene, 0, Moves.SPORE));
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.toNextTurn();
expect(enemyPokemon[0].status).toBe(undefined); expect(enemyPokemon.status).toBeUndefined();
expect(playerPokemon[0].status).toBe(undefined);
}, TIMEOUT }, TIMEOUT
); );
it("protects ally from status", it("protects ally from status",
async () => { async () => {
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(false); game.override.battleType("double");
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.DEOXYS); await game.startBattle();
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.AMOONGUSS);
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SAFEGUARD, Moves.SAFEGUARD, Moves.SAFEGUARD, Moves.SAFEGUARD]);
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPORE, Moves.NUZZLE, Moves.SPORE, Moves.SPORE]);
await game.startBattle([Species.AMOONGUSS, Species.FURRET]);
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPORE)); game.doAttack(getMovePosition(game.scene, 0, Moves.SPORE));
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
@ -97,28 +78,14 @@ describe("Moves - Safeguard", () => {
await game.phaseInterceptor.to(SelectTargetPhase, false); await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(BattlerIndex.ENEMY_2); game.doSelectTarget(BattlerIndex.ENEMY_2);
await mockTurnOrder(game, [BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const enemyPokemon = game.scene.getEnemyField(); const enemyPokemon = game.scene.getEnemyField();
const playerPokemon = game.scene.getPlayerField();
expect(enemyPokemon[0].status).toBe(undefined); expect(enemyPokemon[0].status).toBeUndefined();
expect(enemyPokemon[1].status).toBe(undefined); expect(enemyPokemon[1].status).toBeUndefined();
expect(playerPokemon[0].status).toBe(undefined);
expect(playerPokemon[1].status).toBe(undefined);
}, TIMEOUT
);
it("applys arena tag for 5 turns",
async () => {
await game.startBattle([Species.DEOXYS]);
for (let i=0;i<5;i++) {
game.doAttack(getMovePosition(game.scene, 0, Moves.SAFEGUARD));
await game.phaseInterceptor.to(CommandPhase);
}
expect(game.scene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, ArenaTagSide.PLAYER)).toBeUndefined();
}, TIMEOUT }, TIMEOUT
); );
}); });