2024-08-06 07:06:25 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2024-08-03 12:20:19 -07:00
|
|
|
import Phaser from "phaser";
|
2024-08-06 07:06:25 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-08-03 12:20:19 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import { BattleStat } from "#app/data/battle-stat";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { SPLASH_ONLY } from "#test/utils/testUtils";
|
2024-08-22 14:39:11 +09:00
|
|
|
import { toDmgValue } from "#app/utils";
|
2024-08-03 12:20:19 -07:00
|
|
|
|
|
|
|
const TIMEOUT = 20 * 1000;
|
2024-08-06 07:06:25 -07:00
|
|
|
/** HP Cost of Move */
|
2024-08-03 12:20:19 -07:00
|
|
|
const RATIO = 2;
|
2024-08-06 07:06:25 -07:00
|
|
|
/** Amount of extra HP lost */
|
2024-08-03 12:20:19 -07:00
|
|
|
const PREDAMAGE = 15;
|
|
|
|
|
|
|
|
describe("Moves - FILLET AWAY", () => {
|
|
|
|
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-06 07:06:25 -07:00
|
|
|
game.override.starterSpecies(Species.MAGIKARP);
|
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
|
|
|
game.override.startingLevel(100);
|
|
|
|
game.override.enemyLevel(100);
|
2024-08-03 12:20:19 -07:00
|
|
|
game.override.moveset([Moves.FILLET_AWAY]);
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.enemyMoveset(SPLASH_ONLY);
|
2024-08-03 12:20:19 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
//Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/fillet_away_(move)
|
|
|
|
|
|
|
|
test("Fillet Away raises the user's Attack, Special Attack, and Speed by two stages each, at the cost of 1/2 of its maximum HP",
|
|
|
|
async() => {
|
|
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
|
|
|
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
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY));
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.ATK]).toBe(2);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(2);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(2);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test("Fillet Away will still take effect if one or more of the involved stats are not at max",
|
|
|
|
async() => {
|
|
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
|
|
|
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
|
|
|
|
|
|
|
//Here - BattleStat.SPD -> 0 and BattleStat.SPATK -> 3
|
|
|
|
leadPokemon.summonData.battleStats[BattleStat.ATK] = 6;
|
|
|
|
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 3;
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY));
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.ATK]).toBe(6);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(5);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(2);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test("Fillet Away fails if all stats involved are at max",
|
|
|
|
async() => {
|
|
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-03 12:20:19 -07:00
|
|
|
|
|
|
|
leadPokemon.summonData.battleStats[BattleStat.ATK] = 6;
|
|
|
|
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6;
|
|
|
|
leadPokemon.summonData.battleStats[BattleStat.SPD] = 6;
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY));
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.ATK]).toBe(6);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(6);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(6);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test("Fillet Away fails if the user's health is less than 1/2",
|
|
|
|
async() => {
|
|
|
|
await game.startBattle([Species.MAGIKARP]);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY));
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.ATK]).toBe(0);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(0);
|
|
|
|
expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(0);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
});
|