2024-08-22 06:49:33 -07:00
|
|
|
import { Species } from "#app/enums/species";
|
2024-08-07 09:23:12 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-11-08 14:44:34 -08:00
|
|
|
import { PokeballType } from "#enums/pokeball";
|
2025-01-12 15:33:05 -08:00
|
|
|
import type BattleScene from "#app/battle-scene";
|
2024-09-29 19:00:29 -07:00
|
|
|
import { Moves } from "#app/enums/moves";
|
2025-02-02 03:32:37 +01:00
|
|
|
import { Type } from "#app/enums/type";
|
|
|
|
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
2024-08-07 09:23:12 -07:00
|
|
|
|
|
|
|
describe("Spec - Pokemon", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not crash when trying to set status of undefined", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.runToSummon([ Species.ABRA ]);
|
2024-08-07 09:23:12 -07:00
|
|
|
|
|
|
|
const pkm = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(pkm).toBeDefined();
|
|
|
|
|
|
|
|
expect(pkm.trySetStatus(undefined)).toBe(true);
|
|
|
|
});
|
2024-09-08 22:10:47 -07:00
|
|
|
|
|
|
|
describe("Add To Party", () => {
|
|
|
|
let scene: BattleScene;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
game.override.enemySpecies(Species.ZUBAT);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.runToSummon([ Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA ]); // 5 Abra, only 1 slot left
|
2024-09-08 22:10:47 -07:00
|
|
|
scene = game.scene;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should append a new pokemon by default", async () => {
|
|
|
|
const zubat = scene.getEnemyPokemon()!;
|
|
|
|
zubat.addToParty(PokeballType.LUXURY_BALL);
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
const party = scene.getPlayerParty();
|
2024-09-08 22:10:47 -07:00
|
|
|
expect(party).toHaveLength(6);
|
|
|
|
party.forEach((pkm, index) =>{
|
|
|
|
expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should put a new pokemon into the passed slotIndex", async () => {
|
|
|
|
const slotIndex = 1;
|
|
|
|
const zubat = scene.getEnemyPokemon()!;
|
|
|
|
zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex);
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
const party = scene.getPlayerParty();
|
2024-09-08 22:10:47 -07:00
|
|
|
expect(party).toHaveLength(6);
|
|
|
|
party.forEach((pkm, index) =>{
|
|
|
|
expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2024-09-29 19:00:29 -07:00
|
|
|
|
|
|
|
it("should not share tms between different forms", async () => {
|
|
|
|
game.override.starterForms({ [Species.ROTOM]: 4 });
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.ROTOM ]);
|
2024-09-29 19:00:29 -07:00
|
|
|
|
|
|
|
const fanRotom = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
expect(fanRotom.compatibleTms).not.toContain(Moves.BLIZZARD);
|
|
|
|
expect(fanRotom.compatibleTms).toContain(Moves.AIR_SLASH);
|
|
|
|
});
|
2025-02-02 03:32:37 +01:00
|
|
|
|
|
|
|
describe("Get correct fusion type", () => {
|
|
|
|
let scene: BattleScene;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
game.override.enemySpecies(Species.ZUBAT);
|
|
|
|
game.override.starterSpecies(Species.ABRA);
|
|
|
|
game.override.enableStarterFusion();
|
|
|
|
scene = game.scene;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Fusing two mons with a single type", async () => {
|
|
|
|
game.override.starterFusionSpecies(Species.CHARMANDER);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const pokemon = scene.getPlayerParty()[0];
|
|
|
|
|
|
|
|
let types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
2025-02-03 03:17:08 +01:00
|
|
|
pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
|
2025-02-02 03:32:37 +01:00
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
2025-02-03 03:17:08 +01:00
|
|
|
pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
|
2025-02-02 03:32:37 +01:00
|
|
|
types = pokemon.getTypes();
|
2025-02-03 03:17:08 +01:00
|
|
|
expect(types[0]).toBe(Type.NORMAL);
|
2025-02-02 03:32:37 +01:00
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
|
|
|
if (!pokemon.fusionCustomPokemonData) {
|
|
|
|
pokemon.fusionCustomPokemonData = new CustomPokemonData();
|
|
|
|
}
|
|
|
|
pokemon.customPokemonData.types = [];
|
|
|
|
|
2025-02-03 03:17:08 +01:00
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
|
2025-02-02 03:32:37 +01:00
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
2025-02-03 03:17:08 +01:00
|
|
|
expect(types[1]).toBe(Type.NORMAL);
|
2025-02-02 03:32:37 +01:00
|
|
|
|
2025-02-03 03:17:08 +01:00
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
|
2025-02-02 03:32:37 +01:00
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
2025-02-03 03:17:08 +01:00
|
|
|
expect(types[1]).toBe(Type.NORMAL);
|
2025-02-02 03:32:37 +01:00
|
|
|
|
2025-02-03 03:17:08 +01:00
|
|
|
pokemon.customPokemonData.types = [ Type.NORMAL, Type.UNKNOWN ];
|
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.NORMAL ];
|
2025-02-02 03:32:37 +01:00
|
|
|
types = pokemon.getTypes();
|
2025-02-03 03:17:08 +01:00
|
|
|
expect(types[0]).toBe(Type.NORMAL);
|
2025-02-02 03:32:37 +01:00
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Fusing two mons with same single type", async () => {
|
|
|
|
game.override.starterFusionSpecies(Species.DROWZEE);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const pokemon = scene.getPlayerParty()[0];
|
|
|
|
|
|
|
|
const types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Fusing mons with one and two types", async () => {
|
|
|
|
game.override.starterSpecies(Species.CHARMANDER);
|
|
|
|
game.override.starterFusionSpecies(Species.HOUNDOUR);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const pokemon = scene.getPlayerParty()[0];
|
|
|
|
|
|
|
|
const types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.FIRE);
|
|
|
|
expect(types[1]).toBe(Type.DARK);
|
|
|
|
});
|
|
|
|
|
2025-02-14 18:40:13 +11:00
|
|
|
it("Fusing mons with two and one types", async () => {
|
|
|
|
game.override.starterSpecies(Species.NUMEL);
|
|
|
|
game.override.starterFusionSpecies(Species.CHARMANDER);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const pokemon = scene.getPlayerParty()[0];
|
|
|
|
|
|
|
|
const types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.FIRE);
|
|
|
|
expect(types[1]).toBe(Type.GROUND);
|
|
|
|
});
|
|
|
|
|
2025-02-02 03:32:37 +01:00
|
|
|
it("Fusing two mons with two types", async () => {
|
|
|
|
game.override.starterSpecies(Species.NATU);
|
|
|
|
game.override.starterFusionSpecies(Species.HOUNDOUR);
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
const pokemon = scene.getPlayerParty()[0];
|
|
|
|
|
|
|
|
let types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
|
|
|
// Natu Psychic/Grass
|
|
|
|
pokemon.customPokemonData.types = [ Type.UNKNOWN, Type.GRASS ];
|
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
|
|
|
// Natu Grass/Flying
|
|
|
|
pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ];
|
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.GRASS);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
|
|
|
if (!pokemon.fusionCustomPokemonData) {
|
|
|
|
pokemon.fusionCustomPokemonData = new CustomPokemonData();
|
|
|
|
}
|
|
|
|
pokemon.customPokemonData.types = [];
|
|
|
|
|
|
|
|
// Houndour Dark/Grass
|
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ];
|
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.GRASS);
|
|
|
|
|
|
|
|
// Houndour Grass/Fire
|
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.GRASS, Type.UNKNOWN ];
|
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.PSYCHIC);
|
|
|
|
expect(types[1]).toBe(Type.FIRE);
|
|
|
|
|
|
|
|
// Natu Grass/Flying
|
|
|
|
// Houndour Dark/Grass
|
|
|
|
pokemon.customPokemonData.types = [ Type.GRASS, Type.UNKNOWN ];
|
|
|
|
pokemon.fusionCustomPokemonData.types = [ Type.UNKNOWN, Type.GRASS ];
|
|
|
|
types = pokemon.getTypes();
|
|
|
|
expect(types[0]).toBe(Type.GRASS);
|
|
|
|
expect(types[1]).toBe(Type.DARK);
|
|
|
|
});
|
|
|
|
});
|
2024-08-07 09:23:12 -07:00
|
|
|
});
|