2024-09-04 10:58:35 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-04 10:58:35 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
2024-08-06 23:29:51 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-09-04 10:58:35 -07:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-08-06 23:29:51 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
describe("Moves - Baton Pass", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
game.override
|
|
|
|
.battleType("single")
|
2024-09-04 10:58:35 -07:00
|
|
|
.enemySpecies(Species.MAGIKARP)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
2024-10-04 13:08:31 +08:00
|
|
|
.moveset([ Moves.BATON_PASS, Moves.NASTY_PLOT, Moves.SPLASH ])
|
2024-09-04 10:58:35 -07:00
|
|
|
.ability(Abilities.BALL_FETCH)
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-08-06 23:29:51 -07:00
|
|
|
.disableCrits();
|
|
|
|
});
|
|
|
|
|
2024-10-23 08:24:50 -07:00
|
|
|
it("transfers all stat stages when player uses it", async () => {
|
2024-08-06 23:29:51 -07:00
|
|
|
// arrange
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]);
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// round 1 - buff
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.NASTY_PLOT);
|
2024-08-06 23:29:51 -07:00
|
|
|
await game.toNextTurn();
|
2024-09-02 22:12:34 -04:00
|
|
|
|
|
|
|
let playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
|
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toEqual(2);
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// round 2 - baton pass
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BATON_PASS);
|
2024-08-06 23:29:51 -07:00
|
|
|
game.doSelectPartyPokemon(1);
|
2024-09-04 10:58:35 -07:00
|
|
|
await game.phaseInterceptor.to("TurnEndPhase");
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// assert
|
2024-09-02 22:12:34 -04:00
|
|
|
playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(playerPokemon.species.speciesId).toEqual(Species.SHUCKLE);
|
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toEqual(2);
|
2024-08-06 23:29:51 -07:00
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("passes stat stage buffs when AI uses it", async () => {
|
2024-08-06 23:29:51 -07:00
|
|
|
// arrange
|
|
|
|
game.override
|
|
|
|
.startingWave(5)
|
2024-10-04 13:08:31 +08:00
|
|
|
.enemyMoveset(new Array(4).fill([ Moves.NASTY_PLOT ]));
|
|
|
|
await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]);
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// round 1 - ai buffs
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-08-06 23:29:51 -07:00
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
// round 2 - baton pass
|
2024-08-07 09:23:12 -07:00
|
|
|
game.scene.getEnemyPokemon()!.hp = 100;
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.BATON_PASS ]);
|
2024-09-09 09:55:11 -07:00
|
|
|
// Force moveset to update mid-battle
|
|
|
|
// TODO: replace with enemy ai control function when it's added
|
|
|
|
game.scene.getEnemyParty()[0].getMoveset();
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-09-04 10:58:35 -07:00
|
|
|
await game.phaseInterceptor.to("PostSummonPhase", false);
|
2024-08-06 23:29:51 -07:00
|
|
|
|
|
|
|
// assert
|
|
|
|
// check buffs are still there
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPATK)).toEqual(2);
|
2024-08-06 23:29:51 -07:00
|
|
|
// confirm that a switch actually happened. can't use species because I
|
|
|
|
// can't find a way to override trainer parties with more than 1 pokemon species
|
2024-08-07 09:23:12 -07:00
|
|
|
expect(game.scene.getEnemyPokemon()!.hp).not.toEqual(100);
|
2024-08-06 23:29:51 -07:00
|
|
|
expect(game.phaseInterceptor.log.slice(-4)).toEqual([
|
|
|
|
"MoveEffectPhase",
|
|
|
|
"SwitchSummonPhase",
|
|
|
|
"SummonPhase",
|
|
|
|
"PostSummonPhase"
|
|
|
|
]);
|
|
|
|
}, 20000);
|
2024-09-04 10:58:35 -07:00
|
|
|
|
2024-10-23 08:24:50 -07:00
|
|
|
it("doesn't transfer effects that aren't transferrable", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.SALT_CURE ]);
|
|
|
|
await game.classicMode.startBattle([ Species.PIKACHU, Species.FEEBAS ]);
|
2024-09-04 10:58:35 -07:00
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
const [ player1, player2 ] = game.scene.getPlayerParty();
|
2024-09-04 10:58:35 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.BATON_PASS);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-04 10:58:35 -07:00
|
|
|
await game.phaseInterceptor.to("MoveEndPhase");
|
|
|
|
expect(player1.findTag((t) => t.tagType === BattlerTagType.SALT_CURED)).toBeTruthy();
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
expect(player2.findTag((t) => t.tagType === BattlerTagType.SALT_CURED)).toBeUndefined();
|
|
|
|
}, 20000);
|
2024-10-23 08:24:50 -07:00
|
|
|
|
|
|
|
it("doesn't allow binding effects from the user to persist", async () => {
|
|
|
|
game.override.moveset([ Moves.FIRE_SPIN, Moves.BATON_PASS ]);
|
|
|
|
|
|
|
|
await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]);
|
|
|
|
|
|
|
|
const enemy = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.FIRE_SPIN);
|
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
|
|
|
await game.move.forceHit();
|
|
|
|
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
expect(enemy.getTag(BattlerTagType.FIRE_SPIN)).toBeDefined();
|
|
|
|
|
|
|
|
game.move.select(Moves.BATON_PASS);
|
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
|
|
|
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
expect(enemy.getTag(BattlerTagType.FIRE_SPIN)).toBeUndefined();
|
|
|
|
});
|
2024-08-06 23:29:51 -07:00
|
|
|
});
|