mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-09 19:41:37 +00: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>
130 lines
4.5 KiB
TypeScript
130 lines
4.5 KiB
TypeScript
import { BattlerIndex } from "#app/battle";
|
|
import { Abilities } from "#app/enums/abilities";
|
|
import { Species } from "#app/enums/species";
|
|
import * as Utils from "#app/utils";
|
|
import { Moves } from "#enums/moves";
|
|
import GameManager from "#test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
describe("Multi-target damage reduction", () => {
|
|
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()
|
|
.battleType("double")
|
|
.enemyLevel(100)
|
|
.startingLevel(100)
|
|
.enemySpecies(Species.POLIWAG)
|
|
.enemyMoveset(Moves.SPLASH)
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
.moveset([ Moves.TACKLE, Moves.DAZZLING_GLEAM, Moves.EARTHQUAKE, Moves.SPLASH ])
|
|
.ability(Abilities.BALL_FETCH);
|
|
});
|
|
|
|
it("should reduce d.gleam damage when multiple enemies but not tackle", async () => {
|
|
await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
|
|
|
|
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
|
|
|
|
game.move.select(Moves.DAZZLING_GLEAM);
|
|
game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY);
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const gleam1 = enemy1.getMaxHp() - enemy1.hp;
|
|
enemy1.hp = enemy1.getMaxHp();
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const tackle1 = enemy1.getMaxHp() - enemy1.hp;
|
|
enemy1.hp = enemy1.getMaxHp();
|
|
|
|
await game.killPokemon(enemy2);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.DAZZLING_GLEAM);
|
|
game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY);
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const gleam2 = enemy1.getMaxHp() - enemy1.hp;
|
|
enemy1.hp = enemy1.getMaxHp();
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
const tackle2 = enemy1.getMaxHp() - enemy1.hp;
|
|
|
|
// Single target moves don't get reduced
|
|
expect(tackle1).toBe(tackle2);
|
|
// Moves that target all enemies get reduced if there's more than one enemy
|
|
expect(gleam1).toBeLessThanOrEqual(Utils.toDmgValue(gleam2 * 0.75) + 1);
|
|
expect(gleam1).toBeGreaterThanOrEqual(Utils.toDmgValue(gleam2 * 0.75) - 1);
|
|
});
|
|
|
|
it("should reduce earthquake when more than one pokemon other than user is not fainted", async () => {
|
|
await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
|
|
|
|
const player2 = game.scene.getPlayerParty()[1];
|
|
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
game.move.select(Moves.SPLASH, 1);
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const damagePlayer2Turn1 = player2.getMaxHp() - player2.hp;
|
|
const damageEnemy1Turn1 = enemy1.getMaxHp() - enemy1.hp;
|
|
|
|
player2.hp = player2.getMaxHp();
|
|
enemy1.hp = enemy1.getMaxHp();
|
|
|
|
await game.killPokemon(enemy2);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
game.move.select(Moves.SPLASH, 1);
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const damagePlayer2Turn2 = player2.getMaxHp() - player2.hp;
|
|
const damageEnemy1Turn2 = enemy1.getMaxHp() - enemy1.hp;
|
|
|
|
enemy1.hp = enemy1.getMaxHp();
|
|
|
|
// Turn 1: 3 targets, turn 2: 2 targets
|
|
// Both should have damage reduction
|
|
expect(damageEnemy1Turn1).toBe(damageEnemy1Turn2);
|
|
expect(damagePlayer2Turn1).toBe(damagePlayer2Turn2);
|
|
|
|
await game.killPokemon(player2);
|
|
await game.toNextTurn();
|
|
|
|
game.move.select(Moves.EARTHQUAKE);
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
const damageEnemy1Turn3 = enemy1.getMaxHp() - enemy1.hp;
|
|
// Turn 3: 1 target, should be no damage reduction
|
|
expect(damageEnemy1Turn1).toBeLessThanOrEqual(Utils.toDmgValue(damageEnemy1Turn3 * 0.75) + 1);
|
|
expect(damageEnemy1Turn1).toBeGreaterThanOrEqual(Utils.toDmgValue(damageEnemy1Turn3 * 0.75) - 1);
|
|
});
|
|
});
|