mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-30 05:24:22 +01:00
* Update `battle-scene.ts` and `data/field/pokemon.ts` `battle-scene.ts` changes: - `getParty()` renamed to `getPlayerParty()` for clarity - `getNonSwitchedXPokemon()` consolidated into `getXPokemon()` - Some tsdocs were added/updated for `getXParty()`, `getXField()` and `getXPokemon()`; and those functions were explicitly marked as `public` - Helper function `getPokemonAllowedInBattle()` added `pokemon.ts` changes: - `isAllowed()` renamed to `isAllowedInChallenge()` for clarity - A redundant check for an active scene is removed in `isActive()` - Some tsdocs were added/updated for `isFainted()`, `isAllowedInChallenge()`, `isAllowedInBattle()` and `isActive()`; and those functions were explicitly marked as `public` - `isFainted()` now checks for `hp <= 0` instead of `!hp` Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Backport eslint change to reduce merge conflicts * Fix merge issues --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com>
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
import { allMoves } from "#app/data/move";
|
|
import { CommandPhase } from "#app/phases/command-phase";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
describe("Moves - Rollout", () => {
|
|
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.disableCrits();
|
|
game.override.battleType("single");
|
|
game.override.starterSpecies(Species.RATTATA);
|
|
game.override.ability(Abilities.BALL_FETCH);
|
|
game.override.enemySpecies(Species.BIDOOF);
|
|
game.override.enemyAbility(Abilities.BALL_FETCH);
|
|
game.override.startingLevel(100);
|
|
game.override.enemyLevel(100);
|
|
game.override.enemyMoveset(Moves.SPLASH);
|
|
});
|
|
|
|
it("should double it's dmg on sequential uses but reset after 5", async () => {
|
|
game.override.moveset([ Moves.ROLLOUT ]);
|
|
vi.spyOn(allMoves[Moves.ROLLOUT], "accuracy", "get").mockReturnValue(100); //always hit
|
|
|
|
const variance = 5;
|
|
const turns = 6;
|
|
const dmgHistory: number[] = [];
|
|
|
|
await game.startBattle();
|
|
|
|
const playerPkm = game.scene.getPlayerParty()[0];
|
|
vi.spyOn(playerPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD
|
|
|
|
const enemyPkm = game.scene.getEnemyParty()[0];
|
|
vi.spyOn(enemyPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD
|
|
vi.spyOn(enemyPkm, "getHeldItems").mockReturnValue([]); //no berries
|
|
|
|
enemyPkm.hp = enemyPkm.getMaxHp();
|
|
let previousHp = enemyPkm.hp;
|
|
|
|
for (let i = 0; i < turns; i++) {
|
|
game.move.select(Moves.ROLLOUT);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
|
|
dmgHistory.push(previousHp - enemyPkm.hp);
|
|
previousHp = enemyPkm.hp;
|
|
}
|
|
|
|
const [ turn1Dmg, turn2Dmg, turn3Dmg, turn4Dmg, turn5Dmg, turn6Dmg ] = dmgHistory;
|
|
|
|
expect(turn2Dmg).toBeGreaterThanOrEqual(turn1Dmg * 2 - variance);
|
|
expect(turn2Dmg).toBeLessThanOrEqual(turn1Dmg * 2 + variance);
|
|
expect(turn3Dmg).toBeGreaterThanOrEqual(turn2Dmg * 2 - variance);
|
|
expect(turn3Dmg).toBeLessThanOrEqual(turn2Dmg * 2 + variance);
|
|
expect(turn4Dmg).toBeGreaterThanOrEqual(turn3Dmg * 2 - variance);
|
|
expect(turn4Dmg).toBeLessThanOrEqual(turn3Dmg * 2 + variance);
|
|
expect(turn5Dmg).toBeGreaterThanOrEqual(turn4Dmg * 2 - variance);
|
|
expect(turn5Dmg).toBeLessThanOrEqual(turn4Dmg * 2 + variance);
|
|
// reset
|
|
expect(turn6Dmg).toBeGreaterThanOrEqual(turn1Dmg - variance);
|
|
expect(turn6Dmg).toBeLessThanOrEqual(turn1Dmg + variance);
|
|
});
|
|
});
|