[Test] Update/modernize/fix some tests (#3968)

This commit is contained in:
NightKev 2024-09-01 22:06:20 -07:00 committed by GitHub
parent 0cbdaab28e
commit 744c8f8845
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 52 deletions

View File

@ -1,8 +1,6 @@
import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities";
import { Stat } from "#app/enums/stat";
import { DamagePhase } from "#app/phases/damage-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
@ -26,18 +24,18 @@ describe("Abilities - Hustle", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.ability(Abilities.HUSTLE);
game.override.moveset([Moves.TACKLE, Moves.GIGA_DRAIN, Moves.FISSURE]);
game.override.startingLevel(5);
game.override.disableCrits();
game.override.enemyLevel(5);
game.override.enemyMoveset(SPLASH_ONLY);
game.override.enemySpecies(Species.SHUCKLE);
game.override.enemyAbility(Abilities.BALL_FETCH);
game.override
.ability(Abilities.HUSTLE)
.moveset([Moves.TACKLE, Moves.GIGA_DRAIN, Moves.FISSURE])
.disableCrits()
.battleType("single")
.enemyMoveset(SPLASH_ONLY)
.enemySpecies(Species.SHUCKLE)
.enemyAbility(Abilities.BALL_FETCH);
});
it("increases the user's Attack stat by 50%", async () => {
await game.startBattle([Species.PIKACHU]);
await game.classicMode.startBattle([Species.PIKACHU]);
const pikachu = game.scene.getPlayerPokemon()!;
const atk = pikachu.stats[Stat.ATK];
@ -45,25 +43,25 @@ describe("Abilities - Hustle", () => {
game.move.select(Moves.TACKLE);
await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to("DamagePhase");
expect(pikachu.getBattleStat).toHaveReturnedWith(atk * 1.5);
expect(pikachu.getBattleStat).toHaveReturnedWith(Math.floor(atk * 1.5));
});
it("lowers the accuracy of the user's physical moves by 20%", async () => {
await game.startBattle([Species.PIKACHU]);
await game.classicMode.startBattle([Species.PIKACHU]);
const pikachu = game.scene.getPlayerPokemon()!;
vi.spyOn(pikachu, "getAccuracyMultiplier");
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase);
await game.phaseInterceptor.to("MoveEffectPhase");
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(0.8);
});
it("does not affect non-physical moves", async () => {
await game.startBattle([Species.PIKACHU]);
await game.classicMode.startBattle([Species.PIKACHU]);
const pikachu = game.scene.getPlayerPokemon()!;
const spatk = pikachu.stats[Stat.SPATK];
@ -71,7 +69,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getAccuracyMultiplier");
game.move.select(Moves.GIGA_DRAIN);
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to("DamagePhase");
expect(pikachu.getBattleStat).toHaveReturnedWith(spatk);
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);
@ -81,7 +79,7 @@ describe("Abilities - Hustle", () => {
game.override.startingLevel(100);
game.override.enemyLevel(30);
await game.startBattle([Species.PIKACHU]);
await game.classicMode.startBattle([Species.PIKACHU]);
const pikachu = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -89,7 +87,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy");
game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to("DamagePhase");
expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp());
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);

View File

@ -1,5 +1,4 @@
import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
@ -24,22 +23,23 @@ describe("Abilities - Wind Rider", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single");
game.override.enemySpecies(Species.SHIFTRY);
game.override.enemyAbility(Abilities.WIND_RIDER);
game.override.moveset([Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM]);
game.override.enemyMoveset(SPLASH_ONLY);
game.override
.battleType("single")
.enemySpecies(Species.SHIFTRY)
.enemyAbility(Abilities.WIND_RIDER)
.moveset([Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM])
.enemyMoveset(SPLASH_ONLY);
});
it("takes no damage from wind moves and its Attack is increased by one stage when hit by one", async () => {
await game.startBattle([Species.MAGIKARP]);
await game.classicMode.startBattle([Species.MAGIKARP]);
const shiftry = game.scene.getEnemyPokemon()!;
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.move.select(Moves.PETAL_BLIZZARD);
await game.phaseInterceptor.to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
expect(shiftry.isFullHp()).toBe(true);
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(1);
@ -49,14 +49,14 @@ describe("Abilities - Wind Rider", () => {
game.override.ability(Abilities.WIND_RIDER);
game.override.enemySpecies(Species.MAGIKARP);
await game.startBattle([Species.SHIFTRY]);
await game.classicMode.startBattle([Species.SHIFTRY]);
const shiftry = game.scene.getPlayerPokemon()!;
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(1);
});
@ -65,7 +65,7 @@ describe("Abilities - Wind Rider", () => {
game.override.ability(Abilities.WIND_RIDER);
game.override.enemySpecies(Species.MAGIKARP);
await game.startBattle([Species.SHIFTRY]);
await game.classicMode.startBattle([Species.SHIFTRY]);
const magikarp = game.scene.getEnemyPokemon()!;
const shiftry = game.scene.getPlayerPokemon()!;
@ -74,16 +74,18 @@ describe("Abilities - Wind Rider", () => {
game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(1);
expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0);
});
it("does not increase Attack when Tailwind is present on opposing side", async () => {
game.override.enemySpecies(Species.MAGIKARP);
game.override
.enemySpecies(Species.MAGIKARP)
.ability(Abilities.WIND_RIDER);
await game.startBattle([Species.SHIFTRY]);
await game.classicMode.startBattle([Species.SHIFTRY]);
const magikarp = game.scene.getEnemyPokemon()!;
const shiftry = game.scene.getPlayerPokemon()!;
@ -92,7 +94,7 @@ describe("Abilities - Wind Rider", () => {
game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(1);
expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0);
@ -101,7 +103,7 @@ describe("Abilities - Wind Rider", () => {
it("does not interact with Sandstorm", async () => {
game.override.enemySpecies(Species.MAGIKARP);
await game.startBattle([Species.SHIFTRY]);
await game.classicMode.startBattle([Species.SHIFTRY]);
const shiftry = game.scene.getPlayerPokemon()!;
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
@ -109,7 +111,7 @@ describe("Abilities - Wind Rider", () => {
game.move.select(Moves.SANDSTORM);
await game.phaseInterceptor.to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
expect(shiftry.hp).lessThan(shiftry.getMaxHp());

View File

@ -1,5 +1,4 @@
import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
@ -32,28 +31,28 @@ describe("Moves - Fake Out", () => {
});
it("can only be used on the first turn a pokemon is sent out", async() => {
await game.startBattle();
await game.classicMode.startBattle();
const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.FAKE_OUT));
game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
const postTurnOneHp = enemy.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.FAKE_OUT));
game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();
expect(enemy.hp).toBe(postTurnOneHp);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.toNextWave();
const newEnemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.FAKE_OUT));
game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();
expect(newEnemy.hp).toBe(newEnemy.getMaxHp());
@ -61,11 +60,11 @@ describe("Moves - Fake Out", () => {
it("can be used again if recalled and sent back out", async() => {
game.override.startingWave(4);
await game.startBattle();
await game.classicMode.startBattle();
const enemy1 = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.FAKE_OUT));
game.move.select(Moves.FAKE_OUT);
await game.phaseInterceptor.to("MoveEndPhase");
expect(enemy1.hp).toBeLessThan(enemy1.getMaxHp());
@ -73,7 +72,7 @@ describe("Moves - Fake Out", () => {
await game.doKillOpponents();
await game.toNextWave();
game.doAttack(getMovePosition(game.scene, 0, Moves.FAKE_OUT));
game.move.select(Moves.FAKE_OUT);
await game.toNextTurn();
const enemy2 = game.scene.getEnemyPokemon()!;

View File

@ -1,6 +1,5 @@
import { BattlerIndex } from "#app/battle.js";
import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
@ -35,11 +34,11 @@ describe("Moves - Gigaton Hammer", () => {
});
it("can't be used two turns in a row", async() => {
await game.startBattle();
await game.classicMode.startBattle();
const enemy1 = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.GIGATON_HAMMER));
game.move.select(Moves.GIGATON_HAMMER);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to("MoveEndPhase");
@ -48,7 +47,7 @@ describe("Moves - Gigaton Hammer", () => {
await game.doKillOpponents();
await game.toNextWave();
game.doAttack(getMovePosition(game.scene, 0, Moves.GIGATON_HAMMER));
game.move.select(Moves.GIGATON_HAMMER);
await game.toNextTurn();
const enemy2 = game.scene.getEnemyPokemon()!;
@ -58,11 +57,11 @@ describe("Moves - Gigaton Hammer", () => {
it("can be used again if recalled and sent back out", async() => {
game.override.startingWave(4);
await game.startBattle();
await game.classicMode.startBattle();
const enemy1 = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.GIGATON_HAMMER));
game.move.select(Moves.GIGATON_HAMMER);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to("MoveEndPhase");
@ -71,7 +70,7 @@ describe("Moves - Gigaton Hammer", () => {
await game.doKillOpponents();
await game.toNextWave();
game.doAttack(getMovePosition(game.scene, 0, Moves.GIGATON_HAMMER));
game.move.select(Moves.GIGATON_HAMMER);
await game.toNextTurn();
const enemy2 = game.scene.getEnemyPokemon()!;