From 3a2f364b41caaa16fdc793caec548b41ca10d44f Mon Sep 17 00:00:00 2001 From: LaukkaE Date: Wed, 10 Apr 2024 21:14:03 +0300 Subject: [PATCH] Fix protect having a chance to fail twice in a row Account for other types of protecting moves --- src/data/move.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 57b01e64c..e93a401cb 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2296,10 +2296,15 @@ export class ProtectAttr extends AddBattlerTagAttr { let timesUsed = 0; const moveHistory = user.getLastXMoves(); let turnMove: TurnMove; - while (moveHistory.length && allMoves[(turnMove = moveHistory.shift()).move].getAttrs(ProtectAttr).find(pa => (pa as ProtectAttr).tagType === this.tagType)) + + while (moveHistory.length) { + turnMove = moveHistory.shift(); + if(!allMoves[turnMove.move].getAttrs(ProtectAttr).length || turnMove.result !== MoveResult.SUCCESS) + break; timesUsed++; + } if (timesUsed) - return !user.randSeedInt(Math.pow(2, timesUsed)); + return !user.randSeedInt(Math.pow(3, timesUsed)); return true; }); }