mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-08 17:32:18 +02:00
abilities: make ability bars pop in to some success
This commit is contained in:
parent
5b8418c60d
commit
53a709822d
@ -1269,6 +1269,36 @@ export class IgnoreOpponentStatChangesAbAttr extends AbAttr {
|
||||
}
|
||||
}
|
||||
|
||||
export class IntimidateImmunityAbAttr extends AbAttr {
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
cancelled.value = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||
return getPokemonMessage(pokemon, `'s Attack was not lowered!`);
|
||||
}
|
||||
}
|
||||
|
||||
export class PostIntimidateStatChangeAbAttr extends AbAttr {
|
||||
private stats: BattleStat[];
|
||||
private levels: integer;
|
||||
private overwrites: boolean;
|
||||
|
||||
constructor(stats: BattleStat[], levels: integer, overwrites?: boolean) {
|
||||
super(true)
|
||||
this.stats = stats
|
||||
this.levels = levels
|
||||
this.overwrites = !!overwrites
|
||||
}
|
||||
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels));
|
||||
cancelled.value = this.overwrites;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class PostSummonAbAttr extends AbAttr {
|
||||
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
|
||||
return false;
|
||||
@ -1321,40 +1351,28 @@ export class PostSummonStatChangeAbAttr extends PostSummonAbAttr {
|
||||
: stats as BattleStat[];
|
||||
this.levels = levels;
|
||||
this.selfTarget = !!selfTarget;
|
||||
this.intimidate = intimidate
|
||||
this.intimidate = !!intimidate;
|
||||
}
|
||||
|
||||
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
|
||||
const statChangePhases: StatChangePhase[] = [];
|
||||
const intimidateImmune: Pokemon[] = []
|
||||
|
||||
if (this.selfTarget)
|
||||
statChangePhases.push(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels));
|
||||
else {
|
||||
for (let opponent of pokemon.getOpponents()) {
|
||||
const cancelled = new Utils.BooleanHolder(false)
|
||||
if (this.intimidate) {
|
||||
if (opponent.hasAbilityWithAttr(IntimidateImmunityAbAttr)) {
|
||||
cancelled.value = true;
|
||||
intimidateImmune.push(opponent);
|
||||
}
|
||||
applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled)
|
||||
}
|
||||
if (!cancelled.value)
|
||||
statChangePhases.push(new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels));
|
||||
if (this.selfTarget) {
|
||||
pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.levels));
|
||||
return true;
|
||||
}
|
||||
for (let opponent of pokemon.getOpponents()) {
|
||||
const cancelled = new Utils.BooleanHolder(false)
|
||||
if (this.intimidate) {
|
||||
applyAbAttrs(IntimidateImmunityAbAttr, opponent, cancelled);
|
||||
applyAbAttrs(PostIntimidateStatChangeAbAttr, opponent, cancelled);
|
||||
}
|
||||
if (!cancelled.value) {
|
||||
const statChangePhase = new StatChangePhase(pokemon.scene, opponent.getBattlerIndex(), false, this.stats, this.levels);
|
||||
if (!statChangePhase.getPokemon().summonData)
|
||||
pokemon.scene.pushPhase(statChangePhase); // TODO: This causes the ability bar to be shown at the wrong time
|
||||
else
|
||||
pokemon.scene.unshiftPhase(statChangePhase);
|
||||
}
|
||||
}
|
||||
|
||||
for (let statChangePhase of statChangePhases) {
|
||||
if (!this.selfTarget && !statChangePhase.getPokemon().summonData)
|
||||
pokemon.scene.pushPhase(statChangePhase); // TODO: This causes the ability bar to be shown at the wrong time
|
||||
else
|
||||
pokemon.scene.unshiftPhase(statChangePhase);
|
||||
}
|
||||
|
||||
for (let opponent of intimidateImmune)
|
||||
pokemon.scene.queueMessage(getPokemonMessage(opponent, ` can't be Intimidated!`));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1382,25 +1400,6 @@ export class PostSummonAllyHealAbAttr extends PostSummonAbAttr {
|
||||
}
|
||||
}
|
||||
|
||||
export class PostIntimidateStatChangeAbAttr extends AbAttr {
|
||||
private stats: BattleStat[];
|
||||
private levels: integer;
|
||||
private overwrites: boolean;
|
||||
|
||||
constructor(stats: BattleStat[], levels: integer, overwrites?: boolean) {
|
||||
super(true)
|
||||
this.stats = stats
|
||||
this.levels = levels
|
||||
this.overwrites = !!overwrites
|
||||
}
|
||||
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
pokemon.scene.pushPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, this.stats, this.levels));
|
||||
cancelled.value = this.overwrites;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class DownloadAbAttr extends PostSummonAbAttr {
|
||||
private enemyDef: integer;
|
||||
private enemySpDef: integer;
|
||||
@ -2289,9 +2288,16 @@ export class FlinchStatChangeAbAttr extends FlinchEffectAbAttr {
|
||||
|
||||
export class IncreasePpAbAttr extends AbAttr { }
|
||||
|
||||
export class IntimidateImmunityAbAttr extends AbAttr { }
|
||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
cancelled.value = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr { }
|
||||
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||
return getPokemonMessage(pokemon, `'s ${abilityName} prevents it from being switched out!`)
|
||||
}
|
||||
}
|
||||
|
||||
export class ReduceBerryUseThresholdAbAttr extends AbAttr {
|
||||
constructor() {
|
||||
|
@ -2887,8 +2887,13 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
if (!this.user && (target.isMax()))
|
||||
return resolve(false);
|
||||
|
||||
const cancelled = new Utils.BooleanHolder(false);
|
||||
if (!this.user)
|
||||
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, cancelled)
|
||||
|
||||
if ((!this.user && target.isMax()) || cancelled.value)
|
||||
return resolve(false);
|
||||
|
||||
// Check if the move category is not STATUS or if the switch out condition is not met
|
||||
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) {
|
||||
@ -2945,7 +2950,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
}
|
||||
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move);
|
||||
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move));
|
||||
}
|
||||
|
||||
getSwitchOutCondition(): MoveConditionFunc {
|
||||
@ -2953,9 +2958,6 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
const switchOutTarget = (this.user ? user : target);
|
||||
const player = switchOutTarget instanceof PlayerPokemon;
|
||||
|
||||
if (!this.user && target.hasAbilityWithAttr(ForceSwitchOutImmunityAbAttr))
|
||||
return false;
|
||||
|
||||
if (!player && !user.scene.currentBattle.battleType) {
|
||||
if (this.batonPass)
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user