2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { TerrainType } from "#app/data/terrain";
|
|
|
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-07-25 16:18:47 -07:00
|
|
|
import Phaser from "phaser";
|
2024-11-09 13:15:24 -05:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import { allMoves, RandomMoveAttr } from "#app/data/move";
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-06-13 09:49:40 -04:00
|
|
|
// See also: TypeImmunityAbAttr
|
2024-06-12 14:46:45 -04:00
|
|
|
describe("Abilities - Sap Sipper", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.battleType("single")
|
|
|
|
.disableCrits()
|
|
|
|
.ability(Abilities.SAP_SIPPER)
|
|
|
|
.enemySpecies(Species.RATTATA)
|
|
|
|
.enemyAbility(Abilities.SAP_SIPPER)
|
|
|
|
.enemyMoveset(Moves.SPLASH);
|
2024-06-12 14:46:45 -04:00
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("raises ATK stat stage by 1 and block effects when activated against a grass attack", async() => {
|
2024-06-12 14:46:45 -04:00
|
|
|
const moveToUse = Moves.LEAFAGE;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
const initialEnemyHp = enemyPokemon.hp;
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-06-13 14:23:13 -04:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(initialEnemyHp - enemyPokemon.hp).toBe(0);
|
|
|
|
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1);
|
2024-06-12 14:46:45 -04:00
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("raises ATK stat stage by 1 and block effects when activated against a grass status move", async() => {
|
2024-06-12 14:46:45 -04:00
|
|
|
const moveToUse = Moves.SPORE;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-06-13 14:23:13 -04:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(enemyPokemon.status).toBeUndefined();
|
|
|
|
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1);
|
2024-06-12 14:46:45 -04:00
|
|
|
});
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("do not activate against status moves that target the field", async () => {
|
2024-06-12 14:46:45 -04:00
|
|
|
const moveToUse = Moves.GRASSY_TERRAIN;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
2024-06-13 14:23:13 -04:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
2024-06-12 14:46:45 -04:00
|
|
|
|
|
|
|
expect(game.scene.arena.terrain).toBeDefined();
|
2024-08-07 09:23:12 -07:00
|
|
|
expect(game.scene.arena.terrain!.terrainType).toBe(TerrainType.GRASSY);
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(0);
|
2024-06-12 14:46:45 -04:00
|
|
|
});
|
2024-06-13 09:49:40 -04:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("activate once against multi-hit grass attacks", async () => {
|
2024-06-13 14:23:13 -04:00
|
|
|
const moveToUse = Moves.BULLET_SEED;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
const initialEnemyHp = enemyPokemon.hp;
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(initialEnemyHp - enemyPokemon.hp).toBe(0);
|
|
|
|
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1);
|
2024-06-13 14:23:13 -04:00
|
|
|
});
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("do not activate against status moves that target the user", async () => {
|
2024-06-13 09:49:40 -04:00
|
|
|
const moveToUse = Moves.SPIKY_SHIELD;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
2024-06-13 09:49:40 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-13 09:49:40 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-13 09:49:40 -04:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getTag(BattlerTagType.SPIKY_SHIELD)).toBeDefined();
|
2024-06-13 09:49:40 -04:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0);
|
2024-06-13 09:49:40 -04:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
|
|
|
});
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
it("activate once against multi-hit grass attacks (metronome)", async () => {
|
2024-06-13 14:23:13 -04:00
|
|
|
const moveToUse = Moves.METRONOME;
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
const randomMoveAttr = allMoves[Moves.METRONOME].findAttr(attr => attr instanceof RandomMoveAttr) as RandomMoveAttr;
|
|
|
|
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.BULLET_SEED);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
game.override.moveset(moveToUse);
|
|
|
|
|
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
const initialEnemyHp = enemyPokemon.hp;
|
2024-06-13 14:23:13 -04:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-13 14:23:13 -04:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(initialEnemyHp - enemyPokemon.hp).toBe(0);
|
|
|
|
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1);
|
2024-06-13 14:23:13 -04:00
|
|
|
});
|
2024-09-23 12:37:21 -07:00
|
|
|
|
|
|
|
it("still activates regardless of accuracy check", async () => {
|
|
|
|
game.override.moveset(Moves.LEAF_BLADE);
|
|
|
|
|
2024-11-09 13:15:24 -05:00
|
|
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
2024-09-23 12:37:21 -07:00
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.LEAF_BLADE);
|
|
|
|
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
|
|
|
|
|
|
await game.move.forceMiss();
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1);
|
|
|
|
});
|
2024-06-12 14:46:45 -04:00
|
|
|
});
|