Compare commits

...

5 Commits

Author SHA1 Message Date
Bertie690
ba6ab4c781
Merge c51c5a2b34 into 5bfcb1d379 2025-08-04 19:44:11 -04:00
Amani H.
5bfcb1d379
[Bug] Release Fainted Pokémon in Switch Menu (#6215)
* [Bug] Release Fainted Pokémon in Switch Menu

* Add Kev's Suggestions
2025-08-04 15:55:36 -07:00
Acelynn Zhang
40443d2afa
[Bug] Fix override move animations not loading for enemy Pokemon
https://github.com/pagefaultgames/pokerogue/pull/6214
2025-08-04 14:33:01 -07:00
Bertie690
c51c5a2b34 hopefullt fixed tests 2025-08-03 23:13:25 -04:00
Bertie690
36969cabc9 Added arena trap tests and such 2025-08-03 19:51:04 -04:00
3 changed files with 71 additions and 48 deletions

View File

@ -1821,8 +1821,6 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
* @returns An array of {@linkcode PokemonMove}, as described above.
*/
getMoveset(ignoreOverride = false): PokemonMove[] {
const ret = !ignoreOverride && this.summonData.moveset ? this.summonData.moveset : this.moveset;
// Overrides moveset based on arrays specified in overrides.ts
let overrideArray: MoveId | Array<MoveId> = this.isPlayer()
? Overrides.MOVESET_OVERRIDE
@ -1838,7 +1836,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
});
}
return ret;
return !ignoreOverride && this.summonData.moveset ? this.summonData.moveset : this.moveset;
}
/**

View File

@ -827,6 +827,11 @@ export class PartyUiHandler extends MessageUiHandler {
globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeItemTrigger, false, true);
}
// This is processed before the filter result since releasing does not depend on status.
if (option === PartyOption.RELEASE) {
return this.processReleaseOption(pokemon);
}
// If the pokemon is filtered out for this option, we cannot continue
const filterResult = this.getFilterResult(option, pokemon);
if (filterResult) {
@ -850,10 +855,6 @@ export class PartyUiHandler extends MessageUiHandler {
// PartyUiMode.POST_BATTLE_SWITCH (SEND_OUT)
// These are the options that need a callback
if (option === PartyOption.RELEASE) {
return this.processReleaseOption(pokemon);
}
if (this.partyUiMode === PartyUiMode.SPLICE) {
if (option === PartyOption.SPLICE) {
(this.selectCallback as PartyModifierSpliceSelectCallback)(this.transferCursor, this.cursor);

View File

@ -1,10 +1,15 @@
import { getPokemonNameWithAffix } from "#app/messages";
import { allAbilities } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { Button } from "#enums/buttons";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode";
import { GameManager } from "#test/test-utils/game-manager";
import type { CommandUiHandler } from "#ui/command-ui-handler";
import i18next from "i18next";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Arena Trap", () => {
let phaserGame: Phaser.Game;
@ -23,68 +28,87 @@ describe("Abilities - Arena Trap", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset(MoveId.SPLASH)
.ability(AbilityId.ARENA_TRAP)
.enemyAbility(AbilityId.ARENA_TRAP)
.enemySpecies(SpeciesId.RALTS)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.TELEPORT);
.enemyMoveset(MoveId.SPLASH);
});
// TODO: Enable test when Issue #935 is addressed
it.todo("should not allow grounded Pokémon to flee", async () => {
// NB: Since switching moves bypass trapping, the only way fleeing can occur in PKR is from the player
// TODO: Implement once forced flee helper exists
it.todo("should interrupt player flee attempt and display message, unless user has Run Away", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.DUGTRIO, SpeciesId.GOTHITELLE]);
await game.classicMode.startBattle();
const enemy = game.field.getEnemyPokemon();
const enemy = game.scene.getEnemyPokemon();
// flee stuff goes here
game.move.select(MoveId.SPLASH);
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
// no switch out command should be queued due to arena trap
expect(game.scene.currentBattle.turnCommands[0]).toBeNull();
// back out and cancel the flee to avoid timeout
(game.scene.ui.getHandler() as CommandUiHandler).processInput(Button.CANCEL);
game.move.use(MoveId.SPLASH);
});
await game.toNextTurn();
expect(game.textInterceptor.logs).toContain(
i18next.t("abilityTriggers:arenaTrap", {
pokemonNameWithAffix: getPokemonNameWithAffix(enemy),
abilityName: allAbilities[AbilityId.ARENA_TRAP].name,
}),
);
});
expect(enemy).toBe(game.scene.getEnemyPokemon());
it("should interrupt player switch attempt and display message", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.DUGTRIO, SpeciesId.GOTHITELLE]);
const enemy = game.field.getEnemyPokemon();
game.doSwitchPokemon(1);
game.onNextPrompt("CommandPhase", UiMode.PARTY, () => {
// no switch out command should be queued due to arena trap
expect(game.scene.currentBattle.turnCommands[0]).toBeNull();
// back out and cancel the switch to avoid timeout
(game.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION);
(game.scene.ui.getHandler() as CommandUiHandler).processInput(Button.CANCEL);
game.move.use(MoveId.SPLASH);
});
await game.toNextTurn();
expect(game.textInterceptor.logs).toContain(
i18next.t("abilityTriggers:arenaTrap", {
pokemonNameWithAffix: getPokemonNameWithAffix(enemy),
abilityName: allAbilities[AbilityId.ARENA_TRAP].name,
}),
);
});
it("should guarantee double battle with any one LURE", async () => {
game.override.startingModifier([{ name: "LURE" }]).startingWave(2);
await game.classicMode.startBattle([SpeciesId.DUGTRIO]);
await game.classicMode.startBattle();
expect(game.scene.getEnemyField().length).toBe(2);
expect(game.scene.getEnemyField()).toHaveLength(2);
});
/**
* This checks if the Player Pokemon is able to switch out/run away after the Enemy Pokemon with {@linkcode AbilityId.ARENA_TRAP}
* is forcefully moved out of the field from moves such as Roar {@linkcode MoveId.ROAR}
*
* Note: It should be able to switch out/run away
*/
it("should lift if pokemon with this ability leaves the field", async () => {
game.override
.battleStyle("double")
.enemyMoveset(MoveId.SPLASH)
.moveset([MoveId.ROAR, MoveId.SPLASH])
.ability(AbilityId.BALL_FETCH);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.SUDOWOODO, SpeciesId.LUNATONE]);
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
const [enemy1, enemy2] = game.scene.getEnemyField();
const [player1, player2] = game.scene.getPlayerField();
const player = game.field.getPlayerPokemon();
const enemy = game.field.getEnemyPokemon();
vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[AbilityId.ARENA_TRAP]);
expect(player.isTrapped()).toBe(true);
expect(enemy.isOnField()).toBe(true);
game.move.select(MoveId.ROAR);
game.move.select(MoveId.SPLASH, 1);
game.move.use(MoveId.ROAR);
await game.toEndOfTurn();
// This runs the fist command phase where the moves are selected
await game.toNextTurn();
// During the next command phase the player pokemons should not be trapped anymore
game.move.select(MoveId.SPLASH);
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
expect(player1.isTrapped()).toBe(false);
expect(player2.isTrapped()).toBe(false);
expect(enemy1.isOnField()).toBe(false);
expect(enemy2.isOnField()).toBe(true);
expect(player.isTrapped()).toBe(false);
expect(enemy.isOnField()).toBe(false);
});
});