mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 22:02:18 +02:00
Add tests to effectiveness.test.ts
This commit is contained in:
parent
6a6f8827e1
commit
15102d6300
@ -1,6 +1,7 @@
|
|||||||
import { allMoves } from "#app/data/move";
|
import { allMoves } from "#app/data/move";
|
||||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||||
import { TrainerSlot } from "#app/data/trainer-config";
|
import { TrainerSlot } from "#app/data/trainer-config";
|
||||||
|
import { Type } from "#app/data/type";
|
||||||
import { Abilities } from "#app/enums/abilities";
|
import { Abilities } from "#app/enums/abilities";
|
||||||
import { Moves } from "#app/enums/moves";
|
import { Moves } from "#app/enums/moves";
|
||||||
import { Species } from "#app/enums/species";
|
import { Species } from "#app/enums/species";
|
||||||
@ -10,14 +11,20 @@ import Phaser from "phaser";
|
|||||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Species,
|
function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Species,
|
||||||
expected: number, targetAbility: Abilities = Abilities.BALL_FETCH): void {
|
expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: Type): void {
|
||||||
// Suppress getPokemonNameWithAffix because it calls on a null battle spec
|
// Suppress getPokemonNameWithAffix because it calls on a null battle spec
|
||||||
vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue("");
|
vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue("");
|
||||||
game.override.enemyAbility(targetAbility);
|
game.override.enemyAbility(targetAbility);
|
||||||
|
|
||||||
|
if (teraType !== undefined) {
|
||||||
|
game.override.enemyHeldItems([{ name:"TERA_SHARD", type: teraType }]);
|
||||||
|
}
|
||||||
const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5);
|
const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5);
|
||||||
const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE);
|
const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE);
|
||||||
|
|
||||||
expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected);
|
expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected);
|
||||||
|
user.destroy();
|
||||||
|
target.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Moves - Type Effectiveness", () => {
|
describe("Moves - Type Effectiveness", () => {
|
||||||
@ -67,4 +74,30 @@ describe("Moves - Type Effectiveness", () => {
|
|||||||
it("Electric-type attacks are negated by Volt Absorb",
|
it("Electric-type attacks are negated by Volt Absorb",
|
||||||
() => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB)
|
() => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it("Electric-type attacks are super-effective against Tera-Water Pokemon",
|
||||||
|
() => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.EXCADRILL, 2, Abilities.BALL_FETCH, Type.WATER)
|
||||||
|
);
|
||||||
|
|
||||||
|
it("Powder moves have no effect on Grass-type Pokemon",
|
||||||
|
() => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.AMOONGUSS, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
it("Powder moves have no effect on Tera-Grass Pokemon",
|
||||||
|
() => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.GRASS)
|
||||||
|
);
|
||||||
|
|
||||||
|
it("Prankster-boosted status moves have no effect on Dark-type Pokemon",
|
||||||
|
() => {
|
||||||
|
game.override.ability(Abilities.PRANKSTER);
|
||||||
|
testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.MIGHTYENA, 0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it("Prankster-boosted status moves have no effect on Tera-Dark Pokemon",
|
||||||
|
() => {
|
||||||
|
game.override.ability(Abilities.PRANKSTER);
|
||||||
|
testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.DARK);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user