add Pokemon.isAllowed()

to check if pokemon is allowed even if it's fainted
This commit is contained in:
Felix Staud 2024-07-12 13:10:53 -07:00
parent d8fce8b245
commit 72c76c4d39

View File

@ -276,7 +276,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
isAllowedInBattle(): boolean { isAllowedInBattle(): boolean {
const challengeAllowed = new Utils.BooleanHolder(true); const challengeAllowed = new Utils.BooleanHolder(true);
applyChallenges(this.scene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); 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 { isActive(onField?: boolean): boolean {