Update ability.ts
Set code back to full copy of normal immunity classes. Extending from the normal classes caused ability triggers to happen twice due to how the system is setup.pull/754/head
parent
64c05c358f
commit
e4ac88ede9
|
@ -1731,10 +1731,30 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends from {@link ProtectStatAbAttr} to allow abilities to mark that they can protect allies from stat changes.
|
* Attrbiute class to allow abilities to mark that they can protect allies from stat reductions.
|
||||||
* Requires the Affected Pokemon to then check if ally has any ability with this attribute and apply the effect.
|
|
||||||
*/
|
*/
|
||||||
export class AllyProtectStatAbAttr extends ProtectStatAbAttr { }
|
export class AllyProtectStatAbAttr extends PreStatChangeAbAttr {
|
||||||
|
private protectedStat: BattleStat;
|
||||||
|
|
||||||
|
constructor(protectedStat?: BattleStat) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.protectedStat = protectedStat;
|
||||||
|
}
|
||||||
|
|
||||||
|
applyPreStatChange(pokemon: Pokemon, passive: boolean, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
if (this.protectedStat === undefined || stat === this.protectedStat) {
|
||||||
|
cancelled.value = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||||
|
return getPokemonMessage(pokemon, `'s ${abilityName}\nprevents lowering its ${this.protectedStat !== undefined ? getBattleStatName(this.protectedStat) : 'stats'}!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PreSetStatusAbAttr extends AbAttr {
|
export class PreSetStatusAbAttr extends AbAttr {
|
||||||
applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise<boolean> {
|
applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise<boolean> {
|
||||||
|
@ -1766,10 +1786,30 @@ export class StatusEffectImmunityAbAttr extends PreSetStatusAbAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends from {@link StatusEffectImmunityAbAttr} to allow abilities to mark that they can protect allies from status effects.
|
* Attrbiute class to allow abilities to mark that they can protect allies from status effects.
|
||||||
* Requires the Affected Pokemon to then check if ally has any ability with this attribute and apply the effect.
|
|
||||||
*/
|
*/
|
||||||
export class AllyStatusEffectImmunityAbAttr extends StatusEffectImmunityAbAttr { }
|
export class AllyStatusEffectImmunityAbAttr extends PreSetStatusAbAttr {
|
||||||
|
private immuneEffects: StatusEffect[];
|
||||||
|
|
||||||
|
constructor(...immuneEffects: StatusEffect[]) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.immuneEffects = immuneEffects;
|
||||||
|
}
|
||||||
|
|
||||||
|
applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
if (!this.immuneEffects.length || this.immuneEffects.indexOf(effect) > -1) {
|
||||||
|
cancelled.value = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||||
|
return getPokemonMessage(pokemon, `'s ${abilityName}\nprevents ${this.immuneEffects.length ? getStatusEffectDescriptor(args[0] as StatusEffect) : 'status problems'}!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PreApplyBattlerTagAbAttr extends AbAttr {
|
export class PreApplyBattlerTagAbAttr extends AbAttr {
|
||||||
applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise<boolean> {
|
applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise<boolean> {
|
||||||
|
@ -1801,10 +1841,30 @@ export class BattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends from {@link BattlerTagImmunityAbAttr} to allow abilities to mark that they can protect allies from battler tags.
|
* Attrbiute class to allow abilities to mark that they can protect allies from battler tags
|
||||||
* Requires the Affected Pokemon to then check if ally has any ability with this attribute and apply the effect.
|
|
||||||
*/
|
*/
|
||||||
export class AllyBattlerTagImmunityAbAttr extends BattlerTagImmunityAbAttr { }
|
export class AllyBattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr {
|
||||||
|
private immuneTagType: BattlerTagType;
|
||||||
|
|
||||||
|
constructor(immuneTagType: BattlerTagType) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.immuneTagType = immuneTagType;
|
||||||
|
}
|
||||||
|
|
||||||
|
applyPreApplyBattlerTag(pokemon: Pokemon, passive: boolean, tag: BattlerTag, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
if (tag.tagType === this.immuneTagType) {
|
||||||
|
cancelled.value = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||||
|
return getPokemonMessage(pokemon, `'s ${abilityName}\nprevents ${(args[0] as BattlerTag).getDescriptor()}!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class BlockCritAbAttr extends AbAttr {
|
export class BlockCritAbAttr extends AbAttr {
|
||||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
|
Loading…
Reference in New Issue