From da2b69280eb5adb0443c8a840d694f48a7ac9547 Mon Sep 17 00:00:00 2001 From: xsn34kzx Date: Thu, 7 Aug 2025 00:53:33 -0400 Subject: [PATCH] Prevent `RandomMoveAttr` from Using Banned Moves --- src/data/moves/move.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 6d2c72c5fde..067bd05c2ae 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -124,7 +124,7 @@ export abstract class Move implements Localizable { /** * Check if the move is of the given subclass without requiring `instanceof`. * - * ⚠️ Does _not_ work for {@linkcode ChargingAttackMove} and {@linkcode ChargingSelfStatusMove} subclasses. For those, + * ! Does _not_ work for {@linkcode ChargingAttackMove} and {@linkcode ChargingSelfStatusMove} subclasses. For those, * use {@linkcode isChargingMove} instead. * * @param moveKind - The string name of the move to check against @@ -6906,13 +6906,19 @@ export class RandomMoveAttr extends CallMoveAttr { * @param move Move being used * @param args Unused */ - override apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + override apply(user: Pokemon, target: Pokemon, _move: Move, args: any[]): boolean { + // TODO: Move this into the constructor to avoid constructing this every call const moveIds = getEnumValues(MoveId).map(m => !this.invalidMoves.has(m) && !allMoves[m].name.endsWith(" (N)") ? m : MoveId.NONE); let moveId: MoveId = MoveId.NONE; + const moveStatus = new BooleanHolder(true); do { moveId = this.getMoveOverride() ?? moveIds[user.randBattleSeedInt(moveIds.length)]; + moveStatus.value = moveId !== MoveId.NONE; + if (user.isPlayer()) { + applyChallenges(ChallengeType.POKEMON_MOVE, moveId, moveStatus); + } } - while (moveId === MoveId.NONE); + while (!moveStatus.value); return super.apply(user, target, allMoves[moveId], args); } }