2024-10-03 16:33:12 +02:00
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
import { Stat } from "#app/enums/stat";
|
2024-09-07 02:15:15 +08:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-11-08 14:44:34 -08:00
|
|
|
import { WeatherType } from "#enums/weather-type";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-07 02:15:15 +08:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
describe("Weather - Sandstorm", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
game.override
|
|
|
|
.weather(WeatherType.SANDSTORM)
|
|
|
|
.battleType("single")
|
2024-09-09 09:55:11 -07:00
|
|
|
.moveset(Moves.SPLASH)
|
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-09-07 02:15:15 +08:00
|
|
|
.enemySpecies(Species.MAGIKARP);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("inflicts damage equal to 1/16 of Pokemon's max HP at turn end", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
2024-09-07 02:15:15 +08:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
|
|
|
|
game.scene.getField(true).forEach(pokemon => {
|
2024-10-03 16:33:12 +02:00
|
|
|
expect(pokemon.hp).toBe(pokemon.getMaxHp() - Math.max(Math.floor(pokemon.getMaxHp() / 16), 1));
|
2024-09-07 02:15:15 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("does not inflict damage to a Pokemon that is underwater (Dive) or underground (Dig)", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.DIVE ]);
|
|
|
|
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
2024-09-07 02:15:15 +08:00
|
|
|
|
|
|
|
game.move.select(Moves.DIVE);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp());
|
2024-10-03 16:33:12 +02:00
|
|
|
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - Math.max(Math.floor(enemyPokemon.getMaxHp() / 16), 1));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("does not inflict damage to Rock, Ground and Steel type Pokemon", async () => {
|
|
|
|
game.override
|
|
|
|
.battleType("double")
|
|
|
|
.enemySpecies(Species.SANDSHREW)
|
|
|
|
.ability(Abilities.BALL_FETCH)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH);
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.ROCKRUFF, Species.KLINK ]);
|
2024-10-03 16:33:12 +02:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH, 0);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
|
|
|
|
game.scene.getField(true).forEach(pokemon => {
|
|
|
|
expect(pokemon.hp).toBe(pokemon.getMaxHp());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("increases Rock type Pokemon Sp.Def by 50%", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.ROCKRUFF ]);
|
2024-10-03 16:33:12 +02:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const playerSpdef = playerPokemon.getStat(Stat.SPDEF);
|
|
|
|
expect(playerPokemon.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(playerSpdef * 1.5));
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
const enemySpdef = enemyPokemon.getStat(Stat.SPDEF);
|
|
|
|
expect(enemyPokemon.getEffectiveStat(Stat.SPDEF)).toBe(enemySpdef);
|
2024-09-07 02:15:15 +08:00
|
|
|
});
|
|
|
|
});
|