2024-09-02 10:39:42 +08:00
|
|
|
|
import { BattlerIndex } from "#app/battle";
|
|
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
|
import { Stat } from "#app/enums/stat";
|
|
|
|
|
import { WeatherType } from "#app/enums/weather-type";
|
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-02 10:39:42 +08:00
|
|
|
|
import Phaser from "phaser";
|
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
|
|
describe("Abilities - Flower Gift", () => {
|
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
|
let game: GameManager;
|
|
|
|
|
const OVERCAST_FORM = 0;
|
|
|
|
|
const SUNSHINE_FORM = 1;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests reverting to normal form when Cloud Nine/Air Lock is active on the field
|
|
|
|
|
* @param {GameManager} game The game manager instance
|
|
|
|
|
* @param {Abilities} ability The ability that is active on the field
|
|
|
|
|
*/
|
|
|
|
|
const testRevertFormAgainstAbility = async (game: GameManager, ability: Abilities) => {
|
|
|
|
|
game.override.starterForms({ [Species.CASTFORM]: SUNSHINE_FORM }).enemyAbility(ability);
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CASTFORM ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
|
|
expect(game.scene.getPlayerPokemon()?.formIndex).toBe(OVERCAST_FORM);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
|
game.override
|
2024-10-04 13:08:31 +08:00
|
|
|
|
.moveset([ Moves.SPLASH, Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.SKILL_SWAP ])
|
2024-09-02 10:39:42 +08:00
|
|
|
|
.enemySpecies(Species.MAGIKARP)
|
2024-09-09 09:55:11 -07:00
|
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-09-02 10:39:42 +08:00
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// TODO: Uncomment expect statements when the ability is implemented - currently does not increase stats of allies
|
2024-09-02 22:12:34 -04:00
|
|
|
|
it("increases the ATK and SPDEF stat stages of the Pokémon with this Ability and its allies by 1.5× during Harsh Sunlight", async () => {
|
2024-09-02 10:39:42 +08:00
|
|
|
|
game.override.battleType("double");
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CHERRIM, Species.MAGIKARP ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
const [ cherrim ] = game.scene.getPlayerField();
|
2024-09-02 22:12:34 -04:00
|
|
|
|
const cherrimAtkStat = cherrim.getEffectiveStat(Stat.ATK);
|
|
|
|
|
const cherrimSpDefStat = cherrim.getEffectiveStat(Stat.SPDEF);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
|
// const magikarpAtkStat = magikarp.getEffectiveStat(Stat.ATK);;
|
|
|
|
|
// const magikarpSpDefStat = magikarp.getEffectiveStat(Stat.SPDEF);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
game.move.select(Moves.SUNNY_DAY, 0);
|
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
|
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
2024-09-02 22:12:34 -04:00
|
|
|
|
expect(cherrim.getEffectiveStat(Stat.ATK)).toBe(Math.floor(cherrimAtkStat * 1.5));
|
|
|
|
|
expect(cherrim.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(cherrimSpDefStat * 1.5));
|
|
|
|
|
// expect(magikarp.getEffectiveStat(Stat.ATK)).toBe(Math.floor(magikarpAtkStat * 1.5));
|
|
|
|
|
// expect(magikarp.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(magikarpSpDefStat * 1.5));
|
2024-09-02 10:39:42 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("changes the Pokemon's form during Harsh Sunlight", async () => {
|
|
|
|
|
game.override.weather(WeatherType.HARSH_SUN);
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CHERRIM ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
const cherrim = game.scene.getPlayerPokemon()!;
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("reverts to Overcast Form if a Pokémon on the field has Air Lock", async () => {
|
|
|
|
|
await testRevertFormAgainstAbility(game, Abilities.AIR_LOCK);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("reverts to Overcast Form if a Pokémon on the field has Cloud Nine", async () => {
|
|
|
|
|
await testRevertFormAgainstAbility(game, Abilities.CLOUD_NINE);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("reverts to Overcast Form when the Pokémon loses Flower Gift, changes form under Harsh Sunlight/Sunny when it regains it", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
|
game.override.enemyMoveset([ Moves.SKILL_SWAP ]).weather(WeatherType.HARSH_SUN);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CHERRIM ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
const cherrim = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
|
|
game.move.select(Moves.SKILL_SWAP);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("TurnStartPhase");
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
|
expect(cherrim.formIndex).toBe(OVERCAST_FORM);
|
|
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("reverts to Overcast Form when the Flower Gift is suppressed, changes form under Harsh Sunlight/Sunny when it regains it", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
|
game.override.enemyMoveset([ Moves.GASTRO_ACID ]).weather(WeatherType.HARSH_SUN);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CHERRIM, Species.MAGIKARP ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
|
|
|
|
|
const cherrim = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
|
|
|
|
|
|
|
|
|
expect(cherrim.summonData.abilitySuppressed).toBe(true);
|
|
|
|
|
expect(cherrim.formIndex).toBe(OVERCAST_FORM);
|
|
|
|
|
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
|
await game.phaseInterceptor.to("MovePhase");
|
|
|
|
|
|
|
|
|
|
expect(cherrim.summonData.abilitySuppressed).toBe(false);
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should be in Overcast Form after the user is switched out", async () => {
|
|
|
|
|
game.override.weather(WeatherType.SUNNY);
|
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
|
await game.classicMode.startBattle([ Species.CASTFORM, Species.MAGIKARP ]);
|
2024-09-02 10:39:42 +08:00
|
|
|
|
const cherrim = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
|
|
expect(cherrim.formIndex).toBe(SUNSHINE_FORM);
|
|
|
|
|
|
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
|
|
expect(cherrim.formIndex).toBe(OVERCAST_FORM);
|
|
|
|
|
});
|
|
|
|
|
});
|