From 72c76c4d39732ce5d90b1e8d3685d028fa4cfaf6 Mon Sep 17 00:00:00 2001 From: Felix Staud Date: Fri, 12 Jul 2024 13:10:53 -0700 Subject: [PATCH] add `Pokemon.isAllowed()` to check if pokemon is allowed even if it's fainted --- src/field/pokemon.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index e32b5303dc7..279ffeccc42 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -276,7 +276,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { isAllowedInBattle(): boolean { const challengeAllowed = new Utils.BooleanHolder(true); applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); - return !this.isFainted() && challengeAllowed.value; + return !this.isFainted() && this.isAllowed(); + } + + /** + * Check if this pokemon is allowed (no challenge exclusion) + * This is frequently a better alternative to {@link isFainted} + * @returns {boolean} True if pokemon is allowed in battle + */ + isAllowed(): boolean { + const challengeAllowed = new Utils.BooleanHolder(true); + applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); + return challengeAllowed.value; } isActive(onField?: boolean): boolean {