Skip to content

Commit

Permalink
Fix protect having a chance to fail twice in a row
Browse files Browse the repository at this point in the history
Account for other types of protecting moves
  • Loading branch information
LaukkaE authored and Flashfyre committed Apr 10, 2024
1 parent 151b751 commit 3a2f364
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down

0 comments on commit 3a2f364

Please sign in to comment.