Use array as parameter for FieldPreventMovesAbAttr

This commit is contained in:
Zach Day 2024-06-17 16:30:36 -04:00
parent 2deffeb024
commit 60724a84e4

View File

@ -3725,16 +3725,16 @@ export class BlockRedirectAbAttr extends AbAttr { }
* @param args [1] {@linkcode Pokemon} The user of the attack * @param args [1] {@linkcode Pokemon} The user of the attack
*/ */
export class FieldPreventMovesAbAttr extends AbAttr { export class FieldPreventMovesAbAttr extends AbAttr {
public moveCondition: (Moves) => boolean; public preventedMoves: Moves[];
constructor(moveCondition: (Moves) => boolean) { constructor(moves: Moves[]) {
super(); super();
this.moveCondition = moveCondition; this.preventedMoves = moves;
} }
/** @param args See {@linkcode FieldPreventMovesAbAttr}. */ /** @param args See {@linkcode FieldPreventMovesAbAttr}. */
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (this.moveCondition((args[0] as Move).id)) { if (this.preventedMoves.includes((args[0] as Move).id)) {
cancelled.value = true; cancelled.value = true;
return true; return true;
} }
@ -4358,7 +4358,7 @@ export function initAbilities() {
.attr(BlockOneHitKOAbAttr) .attr(BlockOneHitKOAbAttr)
.ignorable(), .ignorable(),
new Ability(Abilities.DAMP, 3) new Ability(Abilities.DAMP, 3)
.attr(FieldPreventMovesAbAttr, (move) => [Moves.EXPLOSION, Moves.SELF_DESTRUCT, Moves.MIND_BLOWN, Moves.MISTY_EXPLOSION].includes(move)) .attr(FieldPreventMovesAbAttr, [Moves.EXPLOSION, Moves.SELF_DESTRUCT, Moves.MIND_BLOWN, Moves.MISTY_EXPLOSION])
.attr(PreventPostFaintContactDamageAbAttr) .attr(PreventPostFaintContactDamageAbAttr)
.ignorable(), .ignorable(),
new Ability(Abilities.LIMBER, 3) new Ability(Abilities.LIMBER, 3)