mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-06 18:09:10 +00:00
[Bug] Fix canApplyAbility check but for real this time (#5418)
* Move canApplyAbility check * Fix suppressed abilities not activated properly * Move canApplyAbility to applySingleAbAttrs --------- Co-authored-by: damocleas <damocleas25@gmail.com>
This commit is contained in:
parent
92ee9d06ca
commit
b9a853ed2e
@ -5152,6 +5152,10 @@ function applySingleAbAttrs<TAttr extends AbAttr>(
|
||||
showAbilityInstant: boolean = false,
|
||||
messages: string[] = []
|
||||
) {
|
||||
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility();
|
||||
if (gainedMidTurn && ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain())) {
|
||||
return;
|
||||
@ -5445,12 +5449,10 @@ function applyAbAttrsInternal<TAttr extends AbAttr>(
|
||||
gainedMidTurn: boolean = false
|
||||
) {
|
||||
for (const passive of [ false, true ]) {
|
||||
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) {
|
||||
continue;
|
||||
if (pokemon) {
|
||||
applySingleAbAttrs(pokemon, passive, attrType, applyFunc, args, gainedMidTurn, simulated, showAbilityInstant, messages);
|
||||
globalScene.clearPhaseQueueSplice();
|
||||
}
|
||||
|
||||
applySingleAbAttrs(pokemon, passive, attrType, applyFunc, args, gainedMidTurn, simulated, showAbilityInstant, messages);
|
||||
globalScene.clearPhaseQueueSplice();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1230,10 +1230,12 @@ export class FairyLockTag extends ArenaTag {
|
||||
*/
|
||||
export class SuppressAbilitiesTag extends ArenaTag {
|
||||
private sourceCount: number;
|
||||
private beingRemoved: boolean;
|
||||
|
||||
constructor(sourceId: number) {
|
||||
super(ArenaTagType.NEUTRALIZING_GAS, 0, undefined, sourceId);
|
||||
this.sourceCount = 1;
|
||||
this.beingRemoved = false;
|
||||
}
|
||||
|
||||
public override onAdd(arena: Arena): void {
|
||||
@ -1267,6 +1269,7 @@ export class SuppressAbilitiesTag extends ArenaTag {
|
||||
}
|
||||
|
||||
public override onRemove(arena: Arena, quiet: boolean = false) {
|
||||
this.beingRemoved = true;
|
||||
if (!quiet) {
|
||||
globalScene.queueMessage(i18next.t("arenaTag:neutralizingGasOnRemove"));
|
||||
}
|
||||
@ -1282,6 +1285,10 @@ export class SuppressAbilitiesTag extends ArenaTag {
|
||||
public shouldApplyToSelf(): boolean {
|
||||
return this.sourceCount > 1;
|
||||
}
|
||||
|
||||
public isBeingRemoved() {
|
||||
return this.beingRemoved;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
|
||||
|
@ -1501,8 +1501,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* Suppresses an ability and calls its onlose attributes
|
||||
*/
|
||||
public suppressAbility() {
|
||||
this.summonData.abilitySuppressed = true;
|
||||
[ true, false ].forEach((passive) => applyOnLoseAbAttrs(this, passive));
|
||||
this.summonData.abilitySuppressed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1563,7 +1563,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return false;
|
||||
}
|
||||
const suppressAbilitiesTag = arena.getTag(ArenaTagType.NEUTRALIZING_GAS) as SuppressAbilitiesTag;
|
||||
if (this.isOnField() && suppressAbilitiesTag) {
|
||||
if (this.isOnField() && suppressAbilitiesTag && !suppressAbilitiesTag.isBeingRemoved()) {
|
||||
const thisAbilitySuppressing = ability.hasAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr);
|
||||
const hasSuppressingAbility = this.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false);
|
||||
// Neutralizing gas is up - suppress abilities unless they are unsuppressable or this pokemon is responsible for the gas
|
||||
|
Loading…
x
Reference in New Issue
Block a user