Skip to content

Commit

Permalink
Change NoOnGainActivationAttr to a field in PostSummonAbAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
emdeann committed Feb 17, 2025
1 parent 93963aa commit e45a03c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,21 @@ export class PostIntimidateStatStageChangeAbAttr extends AbAttr {
* @see {@linkcode applyPostSummon()}
*/
export class PostSummonAbAttr extends AbAttr {
/** Should the ability activate when gained in battle? This will almost always be true */
private activateOnGain: boolean;

constructor(showAbility: boolean = true, activateOnGain: boolean = true) {
super(showAbility);
this.activateOnGain = activateOnGain;
}

/**
* @returns Whether the ability should activate when gained in battle
*/
shouldActivateOnGain(): boolean {
return this.activateOnGain;
}

/**
* Applies ability post summon (after switching in)
* @param pokemon {@linkcode Pokemon} with this ability
Expand Down Expand Up @@ -2439,7 +2454,7 @@ export class PostSummonCopyAllyStatsAbAttr extends PostSummonAbAttr {
*/
export class PostSummonTransformAbAttr extends PostSummonAbAttr {
constructor() {
super(true);
super(true, false);
}

async applyPostSummon(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): Promise<boolean> {
Expand Down Expand Up @@ -4522,15 +4537,6 @@ export class NoFusionAbilityAbAttr extends AbAttr {
}
}

/**
* Attach to a post-summon ability if it shouldn't be activated when it is obtained or activated during the battle
*/
export class NoOnGainActivationAttr extends AbAttr {
constructor() {
super(false);
}
}

export class IgnoreTypeImmunityAbAttr extends AbAttr {
private defenderType: Type;
private allowedMoveTypes: Type[];
Expand Down Expand Up @@ -4878,7 +4884,7 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
) {
for (const passive of [ false, true ]) {
if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id || gainedMidTurn))
|| (gainedMidTurn && pokemon.getAbility().hasAttr(NoOnGainActivationAttr))) {
|| (gainedMidTurn && pokemon.getAbility().getAttrs(PostSummonAbAttr).some(a => !a.shouldActivateOnGain()))) {
continue;
}

Expand Down

0 comments on commit e45a03c

Please sign in to comment.