[Bug] Palafin should not swap to Hero form when switching due to faint (#3532)
* Palafin should not swap to Hero form when switching due to faint Also add more tests for Zero to Hero * Use `.isFainted()` instead of checking HP
This commit is contained in:
parent
5000a91348
commit
2b0b9fcb70
|
@ -5296,7 +5296,7 @@ export function initAbilities() {
|
||||||
.attr(NoTransformAbilityAbAttr)
|
.attr(NoTransformAbilityAbAttr)
|
||||||
.attr(NoFusionAbilityAbAttr)
|
.attr(NoFusionAbilityAbAttr)
|
||||||
.attr(PostBattleInitFormChangeAbAttr, () => 0)
|
.attr(PostBattleInitFormChangeAbAttr, () => 0)
|
||||||
.attr(PreSwitchOutFormChangeAbAttr, () => 1)
|
.attr(PreSwitchOutFormChangeAbAttr, (pokemon) => !pokemon.isFainted() ? 1 : pokemon.formIndex)
|
||||||
.bypassFaint(),
|
.bypassFaint(),
|
||||||
new Ability(Abilities.COMMANDER, 9)
|
new Ability(Abilities.COMMANDER, 9)
|
||||||
.attr(UncopiableAbilityAbAttr)
|
.attr(UncopiableAbilityAbAttr)
|
||||||
|
|
|
@ -6,13 +6,16 @@ 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 { getMovePosition } from "#test/utils/gameManagerUtils";
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
import { SPLASH_ONLY } from "../utils/testUtils";
|
||||||
|
|
||||||
const TIMEOUT = 20 * 1000;
|
const TIMEOUT = 20 * 1000;
|
||||||
|
|
||||||
describe("Abilities - ZERO TO HERO", () => {
|
describe("Abilities - ZERO TO HERO", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
const baseForm = 0;
|
||||||
|
const heroForm = 1;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
|
@ -26,41 +29,83 @@ describe("Abilities - ZERO TO HERO", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
const moveToUse = Moves.SPLASH;
|
game.override
|
||||||
game.override.battleType("single");
|
.battleType("single")
|
||||||
game.override.ability(Abilities.ZERO_TO_HERO);
|
.moveset(SPLASH_ONLY)
|
||||||
game.override.moveset([moveToUse]);
|
.enemyMoveset(SPLASH_ONLY)
|
||||||
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
|
.enemyAbility(Abilities.BALL_FETCH);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
it("should swap to base form on arena reset", async () => {
|
||||||
"check if fainted pokemon switches to base form on arena reset",
|
game.override.startingWave(4);
|
||||||
async () => {
|
game.override.starterForms({
|
||||||
const baseForm = 0,
|
[Species.PALAFIN]: heroForm,
|
||||||
heroForm = 1;
|
});
|
||||||
game.override.startingWave(4);
|
|
||||||
game.override.starterForms({
|
|
||||||
[Species.PALAFIN]: heroForm,
|
|
||||||
});
|
|
||||||
|
|
||||||
await game.startBattle([Species.MAGIKARP, Species.PALAFIN]);
|
await game.startBattle([Species.FEEBAS, Species.PALAFIN, Species.PALAFIN]);
|
||||||
|
|
||||||
const palafin = game.scene.getParty().find((p) => p.species.speciesId === Species.PALAFIN)!;
|
const palafin1 = game.scene.getParty()[1];
|
||||||
expect(palafin).not.toBe(undefined);
|
const palafin2 = game.scene.getParty()[2];
|
||||||
expect(palafin.formIndex).toBe(heroForm);
|
expect(palafin1.formIndex).toBe(heroForm);
|
||||||
|
expect(palafin2.formIndex).toBe(heroForm);
|
||||||
|
palafin2.hp = 0;
|
||||||
|
palafin2.status = new Status(StatusEffect.FAINT);
|
||||||
|
expect(palafin2.isFainted()).toBe(true);
|
||||||
|
|
||||||
palafin.hp = 0;
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
palafin.status = new Status(StatusEffect.FAINT);
|
await game.doKillOpponents();
|
||||||
expect(palafin.isFainted()).toBe(true);
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
game.doSelectModifier();
|
||||||
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||||
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||||
|
|
||||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
expect(palafin1.formIndex).toBe(baseForm);
|
||||||
await game.doKillOpponents();
|
expect(palafin2.formIndex).toBe(baseForm);
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
}, TIMEOUT);
|
||||||
game.doSelectModifier();
|
|
||||||
await game.phaseInterceptor.to(QuietFormChangePhase);
|
|
||||||
|
|
||||||
expect(palafin.formIndex).toBe(baseForm);
|
it("should swap to Hero form when switching out during a battle", async () => {
|
||||||
},
|
await game.startBattle([Species.PALAFIN, Species.FEEBAS]);
|
||||||
TIMEOUT
|
|
||||||
);
|
const palafin = game.scene.getPlayerPokemon()!;
|
||||||
|
expect(palafin.formIndex).toBe(baseForm);
|
||||||
|
|
||||||
|
game.doSwitchPokemon(1);
|
||||||
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
||||||
|
expect(palafin.formIndex).toBe(heroForm);
|
||||||
|
}, TIMEOUT);
|
||||||
|
|
||||||
|
it("should not swap to Hero form if switching due to faint", async () => {
|
||||||
|
await game.startBattle([Species.PALAFIN, Species.FEEBAS]);
|
||||||
|
|
||||||
|
const palafin = game.scene.getPlayerPokemon()!;
|
||||||
|
expect(palafin.formIndex).toBe(baseForm);
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
await game.killPokemon(palafin);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(palafin.formIndex).toBe(baseForm);
|
||||||
|
}, TIMEOUT);
|
||||||
|
|
||||||
|
it("should stay hero form if fainted and then revived", async () => {
|
||||||
|
game.override.starterForms({
|
||||||
|
[Species.PALAFIN]: heroForm,
|
||||||
|
});
|
||||||
|
|
||||||
|
await game.startBattle([Species.PALAFIN, Species.FEEBAS]);
|
||||||
|
|
||||||
|
const palafin = game.scene.getPlayerPokemon()!;
|
||||||
|
expect(palafin.formIndex).toBe(heroForm);
|
||||||
|
|
||||||
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||||
|
await game.killPokemon(palafin);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.doRevivePokemon(1);
|
||||||
|
game.doSwitchPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(palafin.formIndex).toBe(heroForm);
|
||||||
|
}, TIMEOUT);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue