mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-23 07:49:36 +02:00
[P1 Bug] Fix softlock when a phazing attack activates a reviver seed
This commit is contained in:
parent
2ac688de4b
commit
4bd58f9756
@ -5457,7 +5457,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
private selfSwitch: boolean = false,
|
private selfSwitch: boolean = false,
|
||||||
private switchType: SwitchType = SwitchType.SWITCH
|
private switchType: SwitchType = SwitchType.SWITCH
|
||||||
) {
|
) {
|
||||||
super(false, MoveEffectTrigger.POST_APPLY, false, true);
|
super(selfSwitch, MoveEffectTrigger.POST_APPLY, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
isBatonPass() {
|
isBatonPass() {
|
||||||
@ -5465,6 +5465,10 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
|
if (!super.apply(user, target, move, args)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the move category is not STATUS or if the switch out condition is not met
|
// Check if the move category is not STATUS or if the switch out condition is not met
|
||||||
if (!this.getSwitchOutCondition()(user, target, move)) {
|
if (!this.getSwitchOutCondition()(user, target, move)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -139,4 +139,55 @@ describe("Moves - Dragon Tail", () => {
|
|||||||
|
|
||||||
expect(enemy.isFullHp()).toBe(false);
|
expect(enemy.isFullHp()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should force a switch upon fainting an opponent normally", async () => {
|
||||||
|
game.override.startingWave(5)
|
||||||
|
.startingLevel(1000); // To make sure Dragon Tail KO's the opponent
|
||||||
|
await game.classicMode.startBattle([ Species.DRATINI ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.DRAGON_TAIL);
|
||||||
|
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
// Make sure the enemy switched to a healthy Pokemon
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
expect(enemy).toBeDefined();
|
||||||
|
expect(enemy.isFullHp).toBeTruthy();
|
||||||
|
|
||||||
|
// Make sure the enemy has a fainted Pokemon in their party
|
||||||
|
const faintedEnemy = game.scene.getEnemyParty().find(p => !p.isAllowedInBattle());
|
||||||
|
expect(faintedEnemy).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not cause a softlock when activating an opponent trainer's reviver seed", async () => {
|
||||||
|
game.override.startingWave(5)
|
||||||
|
.enemyHeldItems([{ name: "REVIVER_SEED" }])
|
||||||
|
.startingLevel(1000); // To make sure Dragon Tail KO's the opponent
|
||||||
|
await game.classicMode.startBattle([ Species.DRATINI ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.DRAGON_TAIL);
|
||||||
|
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
// Make sure the enemy field is not empty and has a revived Pokemon
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
expect(enemy).toBeDefined();
|
||||||
|
expect(enemy.hp).toBe(Math.floor(enemy.getMaxHp() / 2));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not cause a softlock when activating a player's reviver seed", async () => {
|
||||||
|
game.override.startingHeldItems([{ name: "REVIVER_SEED" }])
|
||||||
|
.enemyMoveset(Moves.DRAGON_TAIL)
|
||||||
|
.enemyLevel(1000); // To make sure Dragon Tail KO's the player
|
||||||
|
await game.classicMode.startBattle([ Species.DRATINI, Species.BULBASAUR ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
// Make sure the player's field is not empty and has a revived Pokemon
|
||||||
|
const dratini = game.scene.getPlayerPokemon()!;
|
||||||
|
expect(dratini).toBeDefined();
|
||||||
|
expect(dratini.hp).toBe(Math.floor(dratini.getMaxHp() / 2));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -96,4 +96,19 @@ describe("Moves - U-turn", () => {
|
|||||||
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true); // proxy for asserting ability activated
|
||||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
|
it("still forces a switch if u-turn KO's the opponent", async () => {
|
||||||
|
game.override.startingLevel(1000); // Ensure that U-Turn KO's the opponent
|
||||||
|
await game.classicMode.startBattle([
|
||||||
|
Species.RAICHU,
|
||||||
|
Species.SHUCKLE
|
||||||
|
]);
|
||||||
|
|
||||||
|
game.move.select(Moves.U_TURN);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||||
|
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user