2024-08-22 06:49:33 -07:00
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-08-22 14:39:11 +09:00
|
|
|
import { toDmgValue } from "#app/utils";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-08-22 06:49:33 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2024-08-27 00:14:59 +08:00
|
|
|
import { Abilities } from "#app/enums/abilities";
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-08-03 12:20:19 -07:00
|
|
|
// RATIO : HP Cost of Move
|
|
|
|
const RATIO = 2;
|
|
|
|
// PREDAMAGE : Amount of extra HP lost
|
|
|
|
const PREDAMAGE = 15;
|
|
|
|
|
|
|
|
describe("Moves - BELLY DRUM", () => {
|
|
|
|
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-08-27 00:14:59 +08:00
|
|
|
game.override
|
|
|
|
.starterSpecies(Species.MAGIKARP)
|
|
|
|
.enemySpecies(Species.SNORLAX)
|
|
|
|
.startingLevel(100)
|
|
|
|
.enemyLevel(100)
|
2024-10-04 13:08:31 +08:00
|
|
|
.moveset([ Moves.BELLY_DRUM ])
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-08-27 00:14:59 +08:00
|
|
|
.enemyAbility(Abilities.BALL_FETCH);
|
2024-08-03 12:20:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Belly_Drum_(move)
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
test("raises the user's ATK stat stage to its max, at the cost of 1/2 of its maximum HP",
|
|
|
|
async() => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP ]);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-22 14:39:11 +09:00
|
|
|
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BELLY_DRUM);
|
2024-08-03 12:20:19 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-03 12:20:19 -07:00
|
|
|
);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
test("will still take effect if an uninvolved stat stage is at max",
|
|
|
|
async() => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP ]);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-22 14:39:11 +09:00
|
|
|
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
// Here - Stat.ATK -> -3 and Stat.SPATK -> 6
|
|
|
|
leadPokemon.setStatStage(Stat.ATK, -3);
|
|
|
|
leadPokemon.setStatStage(Stat.SPATK, 6);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BELLY_DRUM);
|
2024-08-03 12:20:19 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6);
|
|
|
|
expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-03 12:20:19 -07:00
|
|
|
);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
test("fails if the pokemon's ATK stat stage is at its maximum",
|
|
|
|
async() => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP ]);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
leadPokemon.setStatStage(Stat.ATK, 6);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BELLY_DRUM);
|
2024-08-03 12:20:19 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-03 12:20:19 -07:00
|
|
|
);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
test("fails if the user's health is less than 1/2",
|
|
|
|
async() => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP ]);
|
2024-08-03 12:20:19 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-22 14:39:11 +09:00
|
|
|
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
|
2024-08-03 12:20:19 -07:00
|
|
|
leadPokemon.hp = hpLost - PREDAMAGE;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BELLY_DRUM);
|
2024-08-03 12:20:19 -07:00
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-03 12:20:19 -07:00
|
|
|
);
|
|
|
|
});
|