Cleaned up shields down tests; added more tests

This commit is contained in:
Bertie690 2025-08-04 17:24:48 -04:00
parent 800b8c9905
commit 330c7f169c

View File

@ -2,14 +2,17 @@ import { Status } from "#data/status-effect";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { QuietFormChangePhase } from "#phases/quiet-form-change-phase";
import { TurnEndPhase } from "#phases/turn-end-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Shields Down", () => {
const redMeteorForm = 0;
const redCoreForm = 7;
const orangeCoreForm = 8;
describe("Abilities - SHIELDS DOWN", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -25,159 +28,159 @@ describe("Abilities - SHIELDS DOWN", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const moveToUse = MoveId.SPLASH;
game.override game.override
.battleStyle("single") .battleStyle("single")
.ability(AbilityId.SHIELDS_DOWN) .ability(AbilityId.SHIELDS_DOWN)
.moveset([moveToUse]) .enemySpecies(SpeciesId.PSYDUCK)
.enemyMoveset([MoveId.TACKLE]); .enemyMoveset(MoveId.SPLASH);
}); });
test("check if fainted pokemon switched to base form on arena reset", async () => { it.each([0, 1, 2, 3, 4, 5, 6])(
const meteorForm = 0, "should change from Meteor Form to Core Form on entry/turn end based on HP - form index %i",
coreForm = 7; async meteorIndex => {
game.override.startingWave(4).starterForms({ game.override.starterForms({
[SpeciesId.MINIOR]: coreForm, // Start in meteor form
}); [SpeciesId.MINIOR]: meteorIndex,
});
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]);
const minior = game.scene.getPlayerParty()[1];
expect(minior.formIndex).toBe(meteorIndex);
minior.hp *= 0.49;
// Switch to minior - should change to Core due to being <50% HP
game.doSwitchPokemon(1);
await game.toNextTurn();
expect(minior.formIndex).toBe(meteorIndex + 7);
// Use roost to regain 50% HP; should transform back into Meteor Form at turn end
game.move.use(MoveId.ROOST);
await game.toNextTurn();
expect(minior.formIndex).toBe(meteorIndex);
},
);
it("check if fainted pokemon switched to base form on arena reset", async () => {
game.override.startingWave(4).starterForms({
[SpeciesId.MINIOR]: redCoreForm,
});
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]); await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]);
const minior = game.scene.getPlayerParty().find(p => p.species.speciesId === SpeciesId.MINIOR)!; const minior = game.scene.getPlayerParty()[1];
expect(minior).not.toBe(undefined); expect(minior.formIndex).toBe(redCoreForm);
expect(minior.formIndex).toBe(coreForm);
minior.hp = 0; minior.hp = 0;
minior.status = new Status(StatusEffect.FAINT); minior.status = new Status(StatusEffect.FAINT);
expect(minior.isFainted()).toBe(true); expect(minior.isFainted()).toBe(true);
game.move.select(MoveId.SPLASH); game.move.use(MoveId.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.toEndOfTurn();
game.doSelectModifier(); game.doSelectModifier();
await game.phaseInterceptor.to(QuietFormChangePhase); await game.phaseInterceptor.to("QuietFormChangePhase");
expect(minior.formIndex).toBe(meteorForm); expect(minior.formIndex).toBe(redMeteorForm);
}); });
test("should ignore non-volatile status moves", async () => { // TODO: Move to mold breaker test file
game.override.enemyMoveset([MoveId.SPORE]); it("should ignore Mold Breaker", async () => {
await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.move.select(MoveId.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerPokemon()!.status).toBe(undefined);
});
test("should still ignore non-volatile status moves used by a pokemon with mold breaker", async () => {
game.override.enemyAbility(AbilityId.MOLD_BREAKER).enemyMoveset([MoveId.SPORE]); game.override.enemyAbility(AbilityId.MOLD_BREAKER).enemyMoveset([MoveId.SPORE]);
await game.classicMode.startBattle([SpeciesId.MINIOR]); await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.move.select(MoveId.SPLASH); game.move.use(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.SPORE); await game.move.forceEnemyMove(MoveId.SPORE);
await game.phaseInterceptor.to(TurnEndPhase); await game.toEndOfTurn();
expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); expect(game.field.getPlayerPokemon()).toHaveStatusEffect(StatusEffect.NONE);
}); });
test("should ignore non-volatile secondary status effects", async () => { it("should ignore non-volatile status effects & Yawn in Meteor Form", async () => {
game.override.enemyMoveset([MoveId.NUZZLE]);
await game.classicMode.startBattle([SpeciesId.MINIOR]); await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.move.select(MoveId.SPLASH); game.move.use(MoveId.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.move.forceEnemyMove(MoveId.NUZZLE);
await game.toNextTurn();
expect(game.scene.getPlayerPokemon()!.status).toBe(undefined);
}); const minior = game.field.getPlayerPokemon();
expect(minior).toHaveStatusEffect(StatusEffect.NONE);
test("should ignore status moves even through mold breaker", async () => {
game.override.enemyMoveset([MoveId.SPORE]).enemyAbility(AbilityId.MOLD_BREAKER); game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.YAWN);
await game.classicMode.startBattle([SpeciesId.MINIOR]); await game.toEndOfTurn();
game.move.select(MoveId.SPLASH); expect(game.field.getEnemyPokemon()).toHaveUsedMove({ move: MoveId.YAWN, result: MoveResult.FAIL });
});
await game.phaseInterceptor.to(TurnEndPhase);
it("should not ignore non-volatile status effects & Yawn in Core Form", async () => {
expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); game.override.starterForms({
}); // Note: we specifically check orange core due to a bug where only Red Core Minior was immune to status
[SpeciesId.MINIOR]: orangeCoreForm,
// toxic spikes currently does not poison flying types when gravity is in effect });
test.todo("should become poisoned by toxic spikes when grounded", async () => { await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.override
.enemyMoveset([MoveId.GRAVITY, MoveId.TOXIC_SPIKES, MoveId.SPLASH]) game.move.use(MoveId.SPLASH);
.moveset([MoveId.GRAVITY, MoveId.SPLASH]); await game.move.forceEnemyMove(MoveId.NUZZLE);
await game.toEndOfTurn();
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]);
const minior = game.field.getPlayerPokemon();
// turn 1 expect(minior).toHaveStatusEffect(StatusEffect.PARALYSIS);
game.move.select(MoveId.GRAVITY);
await game.move.selectEnemyMove(MoveId.TOXIC_SPIKES); minior.status = null;
game.move.use(MoveId.SPLASH);
await game.move.forceEnemyMove(MoveId.YAWN);
await game.toEndOfTurn();
expect(game.field.getEnemyPokemon()).toHaveUsedMove({ move: MoveId.YAWN, result: MoveResult.SUCCESS });
});
// TODO: Gravity does not make a Pokemon be considered as "grounded" for hazards
it.todo("should be poisoned by toxic spikes when Gravity is active before changing forms", async () => {
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]);
// Change minior to core form in a state where it would revert on switch
const minior = game.scene.getPlayerParty()[1];
minior.formIndex = redCoreForm;
game.move.use(MoveId.GRAVITY);
await game.move.forceEnemyMove(MoveId.TOXIC_SPIKES);
await game.toNextTurn(); await game.toNextTurn();
// turn 2
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
await game.move.selectEnemyMove(MoveId.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(SpeciesId.MINIOR); expect(minior.species.speciesId).toBe(SpeciesId.MINIOR);
expect(game.scene.getPlayerPokemon()!.species.formIndex).toBe(0); expect(minior.formIndex).toBe(0);
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON); expect(minior.isGrounded()).toBe(true);
expect(minior).toHaveStatusEffect(StatusEffect.POISON);
}); });
test("should ignore yawn", async () => { it("should not ignore volatile status effects", async () => {
game.override.enemyMoveset([MoveId.YAWN]);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MINIOR]);
game.move.select(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.YAWN);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.DROWSY)).toBe(undefined);
});
test("should not ignore volatile status effects", async () => {
game.override.enemyMoveset([MoveId.CONFUSE_RAY]); game.override.enemyMoveset([MoveId.CONFUSE_RAY]);
await game.classicMode.startBattle([SpeciesId.MINIOR]); await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.move.select(MoveId.SPLASH); game.move.use(MoveId.SPLASH);
await game.move.selectEnemyMove(MoveId.CONFUSE_RAY); await game.move.forceEnemyMove(MoveId.CONFUSE_RAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.toEndOfTurn();
expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.CONFUSED)).not.toBe(undefined); expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.CONFUSED)).not.toBe(undefined);
}); });
// the `NoTransformAbilityAbAttr` attribute is not checked anywhere, so this test cannot pass. // TODO: The `NoTransformAbilityAbAttr` attribute is not checked anywhere, so this test cannot pass.
test.todo("ditto should not be immune to status after transforming", async () => { // TODO: Move this to a transform test
game.override.enemySpecies(SpeciesId.DITTO).enemyAbility(AbilityId.IMPOSTER).moveset([MoveId.SPLASH, MoveId.SPORE]); it.todo("should not activate when transformed", async () => {
game.override.enemyAbility(AbilityId.IMPOSTER);
await game.classicMode.startBattle([SpeciesId.MINIOR]); await game.classicMode.startBattle([SpeciesId.MINIOR]);
game.move.select(MoveId.SPORE); game.move.use(MoveId.SPORE);
await game.move.selectEnemyMove(MoveId.SPLASH); await game.toEndOfTurn();
await game.phaseInterceptor.to(TurnEndPhase); expect(game.field.getEnemyPokemon()).toHaveStatusEffect(StatusEffect.SLEEP);
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP);
});
test("should not prevent minior from receiving the fainted status effect in trainer battles", async () => {
game.override
.enemyMoveset([MoveId.TACKLE])
.moveset([MoveId.THUNDERBOLT])
.startingLevel(100)
.startingWave(5)
.enemySpecies(SpeciesId.MINIOR);
await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
const minior = game.scene.getEnemyPokemon()!;
game.move.select(MoveId.THUNDERBOLT);
await game.toNextTurn();
expect(minior.isFainted()).toBe(true);
expect(minior.status?.effect).toBe(StatusEffect.FAINT);
}); });
}); });