mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[P1 Bug] Fix infinite recursion from abilities disabled by Sheer Force (#4631)
This commit is contained in:
parent
f180b6070e
commit
ca3cc3c9c6
@ -1417,10 +1417,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* @returns {boolean} Whether the ability is present and active
|
||||
*/
|
||||
hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).id === ability) {
|
||||
if (this.getAbility(ignoreOverride).id === ability && (!canApply || this.canApplyAbility())) {
|
||||
return true;
|
||||
}
|
||||
if (this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().id === ability) {
|
||||
if (this.getPassiveAbility().id === ability && this.hasPassive() && (!canApply || this.canApplyAbility(true))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -9,6 +9,7 @@ import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { allMoves } from "#app/data/move";
|
||||
|
||||
|
||||
describe("Abilities - Sheer Force", () => {
|
||||
@ -174,5 +175,31 @@ describe("Abilities - Sheer Force", () => {
|
||||
|
||||
}, 20000);
|
||||
|
||||
it("Two Pokemon with abilities disabled by Sheer Force hitting each other should not cause a crash", async () => {
|
||||
const moveToUse = Moves.CRUNCH;
|
||||
game.override.enemyAbility(Abilities.COLOR_CHANGE)
|
||||
.ability(Abilities.COLOR_CHANGE)
|
||||
.moveset(moveToUse)
|
||||
.enemyMoveset(moveToUse);
|
||||
|
||||
await game.classicMode.startBattle([
|
||||
Species.PIDGEOT
|
||||
]);
|
||||
|
||||
const pidgeot = game.scene.getParty()[0];
|
||||
const onix = game.scene.getEnemyParty()[0];
|
||||
|
||||
pidgeot.stats[Stat.DEF] = 10000;
|
||||
onix.stats[Stat.DEF] = 10000;
|
||||
|
||||
game.move.select(moveToUse);
|
||||
await game.toNextTurn();
|
||||
|
||||
// Check that both Pokemon's Color Change activated
|
||||
const expectedTypes = [ allMoves[moveToUse].type ];
|
||||
expect(pidgeot.getTypes()).toStrictEqual(expectedTypes);
|
||||
expect(onix.getTypes()).toStrictEqual(expectedTypes);
|
||||
});
|
||||
|
||||
//TODO King's Rock Interaction Unit Test
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user