mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 16:32:16 +02:00
Add tests to damage_calculation
This commit is contained in:
parent
f2f225cfc1
commit
eaca82cf55
@ -1,5 +1,4 @@
|
||||
import { DamagePhase } from "#app/phases/damage-phase.js";
|
||||
import { toDmgValue } from "#app/utils";
|
||||
import { allMoves } from "#app/data/move";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
@ -9,7 +8,7 @@ import { SPLASH_ONLY } from "#test/utils/testUtils";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Round Down and Minimun 1 test in Damage Calculation", () => {
|
||||
describe("Battle Mechanics - Damage Calculation", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
@ -25,24 +24,75 @@ describe("Round Down and Minimun 1 test in Damage Calculation", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override.battleType("single");
|
||||
game.override.startingLevel(10);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.enemySpecies(Species.SNORLAX)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(SPLASH_ONLY)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100)
|
||||
.disableCrits();
|
||||
});
|
||||
|
||||
it("Attacks deal 1 damage at minimum", async () => {
|
||||
game.override
|
||||
.startingLevel(1)
|
||||
.enemySpecies(Species.AGGRON)
|
||||
.moveset([Moves.TACKLE]);
|
||||
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
|
||||
const aggron = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.TACKLE);
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
|
||||
// Lvl 1 0 Atk Magikarp Tackle vs. 0 HP / 0 Def Aggron: 1-1 (0.3 - 0.3%) -- possibly the worst move ever
|
||||
expect(aggron.hp).toBe(aggron.getMaxHp() - 1);
|
||||
});
|
||||
|
||||
it("Fixed-damage moves ignore damage multipliers", async () => {
|
||||
game.override
|
||||
.enemySpecies(Species.DRAGONITE)
|
||||
.enemyAbility(Abilities.MULTISCALE)
|
||||
.moveset([Moves.DRAGON_RAGE]);
|
||||
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
|
||||
const magikarp = game.scene.getPlayerPokemon()!;
|
||||
const dragonite = game.scene.getEnemyPokemon()!;
|
||||
|
||||
expect(dragonite.getAttackDamage(magikarp, allMoves[Moves.DRAGON_RAGE]).damage).toBe(40);
|
||||
});
|
||||
|
||||
it("One-hit KO moves ignore damage multipliers", async () => {
|
||||
game.override
|
||||
.enemySpecies(Species.AGGRON)
|
||||
.enemyAbility(Abilities.MULTISCALE)
|
||||
.moveset([Moves.FISSURE]);
|
||||
|
||||
await game.classicMode.startBattle([Species.MAGIKARP]);
|
||||
|
||||
const magikarp = game.scene.getPlayerPokemon()!;
|
||||
const aggron = game.scene.getEnemyPokemon()!;
|
||||
|
||||
expect(aggron.getAttackDamage(magikarp, allMoves[Moves.FISSURE]).damage).toBe(aggron.hp);
|
||||
});
|
||||
|
||||
it("When the user fails to use Jump Kick with Wonder Guard ability, the damage should be 1.", async () => {
|
||||
game.override.enemySpecies(Species.GASTLY);
|
||||
game.override.enemyMoveset(SPLASH_ONLY);
|
||||
game.override.starterSpecies(Species.SHEDINJA);
|
||||
game.override.moveset([Moves.JUMP_KICK]);
|
||||
game.override.ability(Abilities.WONDER_GUARD);
|
||||
game.override
|
||||
.enemySpecies(Species.GASTLY)
|
||||
.moveset([Moves.JUMP_KICK])
|
||||
.ability(Abilities.WONDER_GUARD);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([Species.SHEDINJA]);
|
||||
|
||||
const shedinja = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(Moves.JUMP_KICK);
|
||||
|
||||
await game.phaseInterceptor.to(DamagePhase);
|
||||
await game.phaseInterceptor.to("DamagePhase");
|
||||
|
||||
expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1);
|
||||
});
|
||||
@ -50,21 +100,19 @@ describe("Round Down and Minimun 1 test in Damage Calculation", () => {
|
||||
|
||||
it("Charizard with odd HP survives Stealth Rock damage twice", async () => {
|
||||
game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0);
|
||||
game.override.seed("Charizard Stealth Rock test");
|
||||
game.override.enemySpecies(Species.CHARIZARD);
|
||||
game.override.enemyAbility(Abilities.BLAZE);
|
||||
game.override.starterSpecies(Species.PIKACHU);
|
||||
game.override.enemyLevel(100);
|
||||
game.override
|
||||
.seed("Charizard Stealth Rock test")
|
||||
.enemySpecies(Species.CHARIZARD)
|
||||
.enemyAbility(Abilities.BLAZE);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([Species.PIKACHU]);
|
||||
|
||||
const charizard = game.scene.getEnemyPokemon()!;
|
||||
|
||||
const maxHp = charizard.getMaxHp();
|
||||
const damage_prediction = toDmgValue(charizard.getMaxHp() / 2);
|
||||
const currentHp = charizard.hp;
|
||||
const expectedHP = maxHp - damage_prediction;
|
||||
|
||||
expect(currentHp).toBe(expectedHP);
|
||||
if (charizard.getMaxHp() % 2 === 1) {
|
||||
expect(charizard.hp).toBeGreaterThan(charizard.getMaxHp() / 2);
|
||||
} else {
|
||||
expect(charizard.hp).toBe(charizard.getMaxHp() / 2);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user