move: handle some aspects of custom fail text a bit better
This commit is contained in:
parent
4aad37a758
commit
f7f235cdec
|
@ -2356,7 +2356,7 @@ export class IncreasePpAbAttr extends AbAttr { }
|
|||
|
||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` can't be switched out!`))
|
||||
cancelled.value = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,10 +327,12 @@ export default class Move implements Localizable {
|
|||
}
|
||||
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
let failedText = null;
|
||||
for (let attr of this.attrs)
|
||||
failedText = attr.getFailedText(user, target, move, cancelled);
|
||||
return failedText;
|
||||
for (let attr of this.attrs) {
|
||||
let failedText = attr.getFailedText(user, target, move, cancelled);
|
||||
if (failedText !== null)
|
||||
return failedText;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
|
@ -3035,8 +3037,9 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||
}
|
||||
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, cancelled);
|
||||
return null;
|
||||
const blockedByAbility = new Utils.BooleanHolder(false);
|
||||
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, blockedByAbility);
|
||||
return blockedByAbility.value ? getPokemonMessage(target, ` can't be switched out!`) : null;
|
||||
}
|
||||
|
||||
getSwitchOutCondition(): MoveConditionFunc {
|
||||
|
|
|
@ -2278,7 +2278,7 @@ export class MovePhase extends BattlePhase {
|
|||
|
||||
// Assume conditions affecting targets only apply to moves with a single target
|
||||
let success = this.move.getMove().applyConditions(this.pokemon, targets[0], this.move.getMove());
|
||||
let cancelled = new Utils.BooleanHolder(true);
|
||||
let cancelled = new Utils.BooleanHolder(false);
|
||||
let failedText = this.move.getMove().getFailedText(this.pokemon, targets[0], this.move.getMove(), cancelled);
|
||||
if (success && this.scene.arena.isMoveWeatherCancelled(this.move.getMove()))
|
||||
success = false;
|
||||
|
|
Loading…
Reference in New Issue