2024-07-25 16:10:38 -07:00
|
|
|
import { BattlerIndex } from "#app/battle.js";
|
2024-06-17 15:05:21 -07:00
|
|
|
import {
|
|
|
|
CommandPhase,
|
|
|
|
SelectTargetPhase,
|
|
|
|
TurnEndPhase,
|
|
|
|
} from "#app/phases";
|
2024-07-25 16:10:38 -07:00
|
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
|
|
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
2024-06-17 15:05:21 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-07-25 16:10:38 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
|
|
|
describe("Moves - Rage Powder", () => {
|
|
|
|
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-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("double");
|
2024-07-25 15:24:07 -07:00
|
|
|
game.override.starterSpecies(Species.AMOONGUSS);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(100);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]);
|
2024-06-17 15:05:21 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move effect should be bypassed by Grass type",
|
|
|
|
async () => {
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
await game.startBattle([ Species.AMOONGUSS, Species.VENUSAUR ]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
expect(playerPokemon.length).toBe(2);
|
|
|
|
playerPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
expect(enemyPokemon.length).toBe(2);
|
|
|
|
enemyPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
|
2024-06-20 12:02:17 -07:00
|
|
|
const enemyStartingHp = enemyPokemon.map(p => p.hp);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
|
|
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
|
|
game.doSelectTarget(BattlerIndex.ENEMY);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK));
|
|
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
|
|
game.doSelectTarget(BattlerIndex.ENEMY_2);
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
2024-06-20 12:02:17 -07:00
|
|
|
expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]);
|
|
|
|
expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]);
|
2024-06-17 15:05:21 -07:00
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"move effect should be bypassed by Overcoat",
|
|
|
|
async () => {
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.OVERCOAT);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
// Test with two non-Grass type player Pokemon
|
|
|
|
await game.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
expect(playerPokemon.length).toBe(2);
|
|
|
|
playerPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
expect(enemyPokemon.length).toBe(2);
|
|
|
|
enemyPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
|
2024-06-20 12:02:17 -07:00
|
|
|
const enemyStartingHp = enemyPokemon.map(p => p.hp);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
|
|
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
|
|
game.doSelectTarget(BattlerIndex.ENEMY);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK));
|
|
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
|
|
game.doSelectTarget(BattlerIndex.ENEMY_2);
|
2024-06-20 02:11:29 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
2024-06-17 15:05:21 -07:00
|
|
|
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
2024-06-20 12:02:17 -07:00
|
|
|
expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]);
|
|
|
|
expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]);
|
2024-06-17 15:05:21 -07:00
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
});
|