mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 15:22:19 +02:00
Add base damage test
This commit is contained in:
parent
17b7615d76
commit
2c636c0a35
@ -5,7 +5,7 @@ import { Moves } from "#enums/moves";
|
|||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import GameManager from "#test/utils/gameManager";
|
import GameManager from "#test/utils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
describe("Battle Mechanics - Damage Calculation", () => {
|
describe("Battle Mechanics - Damage Calculation", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -34,6 +34,20 @@ describe("Battle Mechanics - Damage Calculation", () => {
|
|||||||
.moveset([Moves.TACKLE, Moves.DRAGON_RAGE, Moves.FISSURE, Moves.JUMP_KICK]);
|
.moveset([Moves.TACKLE, Moves.DRAGON_RAGE, Moves.FISSURE, Moves.JUMP_KICK]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Tackle deals expected base damage", async () => {
|
||||||
|
await game.classicMode.startBattle([Species.CHARIZARD]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
vi.spyOn(playerPokemon, "getEffectiveStat").mockReturnValue(80);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
vi.spyOn(enemyPokemon, "getEffectiveStat").mockReturnValue(90);
|
||||||
|
|
||||||
|
// expected base damage = [(2*level/5 + 2) * power * playerATK / enemyDEF / 50] + 2
|
||||||
|
// = 31.8666...
|
||||||
|
expect(enemyPokemon.getAttackDamage(playerPokemon, allMoves[Moves.TACKLE]).damage).toBeCloseTo(31);
|
||||||
|
});
|
||||||
|
|
||||||
it("Attacks deal 1 damage at minimum", async () => {
|
it("Attacks deal 1 damage at minimum", async () => {
|
||||||
game.override
|
game.override
|
||||||
.startingLevel(1)
|
.startingLevel(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user