Add tsdoc comments for ability getters (#764)
* Add tsdoc comments for ability getters * Add links to the docspull/628/merge
parent
fe6aefd910
commit
db6008d15c
|
@ -796,6 +796,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return !!this.getTypes(true, forDefend).find(t => t === type);
|
return !!this.getTypes(true, forDefend).find(t => t === type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the non-passive ability of the pokemon. This accounts for fusions and ability changing effects.
|
||||||
|
* This should rarely be called, most of the time {@link hasAbility} or {@link hasAbilityWithAttr} are better used as
|
||||||
|
* those check both the passive and non-passive abilities and account for ability suppression.
|
||||||
|
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||||
|
* @param {boolean} ignoreOverride If true, ignore ability changing effects
|
||||||
|
* @returns {Ability} The non-passive ability of the pokemon
|
||||||
|
*/
|
||||||
getAbility(ignoreOverride?: boolean): Ability {
|
getAbility(ignoreOverride?: boolean): Ability {
|
||||||
if (!ignoreOverride && this.summonData?.ability)
|
if (!ignoreOverride && this.summonData?.ability)
|
||||||
return allAbilities[this.summonData.ability];
|
return allAbilities[this.summonData.ability];
|
||||||
|
@ -811,6 +819,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return allAbilities[abilityId];
|
return allAbilities[abilityId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the passive ability of the pokemon. This should rarely be called, most of the time
|
||||||
|
* {@link hasAbility} or {@link hasAbilityWithAttr} are better used as those check both the passive and
|
||||||
|
* non-passive abilities and account for ability suppression.
|
||||||
|
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||||
|
* @returns {Ability} The passive ability of the pokemon
|
||||||
|
*/
|
||||||
getPassiveAbility(): Ability {
|
getPassiveAbility(): Ability {
|
||||||
if (Overrides.PASSIVE_ABILITY_OVERRIDE && this.isPlayer())
|
if (Overrides.PASSIVE_ABILITY_OVERRIDE && this.isPlayer())
|
||||||
return allAbilities[Overrides.PASSIVE_ABILITY_OVERRIDE];
|
return allAbilities[Overrides.PASSIVE_ABILITY_OVERRIDE];
|
||||||
|
@ -838,6 +853,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return this.passive || this.isBoss();
|
return this.passive || this.isBoss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether an ability of a pokemon can be currently applied. This should rarely be
|
||||||
|
* directly called, as {@link hasAbility} and {@link hasAbilityWithAttr} already call this.
|
||||||
|
* @see {@link hasAbility} {@link hasAbilityWithAttr} Intended ways to check abilities in most cases
|
||||||
|
* @param {boolean} passive If true, check if passive can be applied instead of non-passive
|
||||||
|
* @returns {Ability} The passive ability of the pokemon
|
||||||
|
*/
|
||||||
canApplyAbility(passive: boolean = false): boolean {
|
canApplyAbility(passive: boolean = false): boolean {
|
||||||
if (passive && !this.hasPassive())
|
if (passive && !this.hasPassive())
|
||||||
return false;
|
return false;
|
||||||
|
@ -862,6 +884,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return (this.hp || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this));
|
return (this.hp || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a pokemon has the specified ability and it's in effect. Accounts for all the various
|
||||||
|
* effects which can affect whether an ability will be present or in effect, and both passive and
|
||||||
|
* non-passive. This is the primary way to check whether a pokemon has a particular ability.
|
||||||
|
* @param {Abilities} ability The ability to check for
|
||||||
|
* @param {boolean} canApply If false, it doesn't check whether the abiltiy is currently active
|
||||||
|
* @param {boolean} ignoreOverride If true, it ignores ability changing effects
|
||||||
|
* @returns {boolean} Whether the ability is present and active
|
||||||
|
*/
|
||||||
hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||||
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).id === ability)
|
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).id === ability)
|
||||||
return true;
|
return true;
|
||||||
|
@ -870,6 +901,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a pokemon has an ability with the specified attribute and it's in effect.
|
||||||
|
* Accounts for all the various effects which can affect whether an ability will be present or
|
||||||
|
* in effect, and both passive and non-passive. This is one of the two primary ways to check
|
||||||
|
* whether a pokemon has a particular ability.
|
||||||
|
* @param {AbAttr} attrType The ability attribute to check for
|
||||||
|
* @param {boolean} canApply If false, it doesn't check whether the abiltiy is currently active
|
||||||
|
* @param {boolean} ignoreOverride If true, it ignores ability changing effects
|
||||||
|
* @returns {boolean} Whether an ability with that attribute is present and active
|
||||||
|
*/
|
||||||
hasAbilityWithAttr(attrType: { new(...args: any[]): AbAttr }, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
hasAbilityWithAttr(attrType: { new(...args: any[]): AbAttr }, canApply: boolean = true, ignoreOverride?: boolean): boolean {
|
||||||
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType))
|
if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType))
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue