Fix protect having a chance to fail twice in a row

Account for other types of protecting moves
This commit is contained in:
LaukkaE 2024-04-10 21:14:03 +03:00 committed by Samuel H
parent 151b751300
commit 3a2f364b41
1 changed files with 7 additions and 2 deletions

View File

@ -2296,10 +2296,15 @@ export class ProtectAttr extends AddBattlerTagAttr {
let timesUsed = 0; let timesUsed = 0;
const moveHistory = user.getLastXMoves(); const moveHistory = user.getLastXMoves();
let turnMove: TurnMove; 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++; timesUsed++;
}
if (timesUsed) if (timesUsed)
return !user.randSeedInt(Math.pow(2, timesUsed)); return !user.randSeedInt(Math.pow(3, timesUsed));
return true; return true;
}); });
} }