Protect rng now resets on new waves and fixed to look at all turns in the same wave.

This commit is contained in:
Jimmybald1 2025-05-24 09:58:18 +02:00
parent a0484bbde1
commit 00ab9eb225

View File

@ -5780,20 +5780,35 @@ export class ProtectAttr extends AddBattlerTagAttr {
getCondition(): MoveConditionFunc {
return ((user, target, move): boolean => {
// Protect rng resets on new waves, it always succeeds.
if (user.tempSummonData.waveTurnCount === 1) {
return true;
}
let timesUsed = 0;
const moveHistory = user.getLastXMoves();
const moveHistory = user.getLastXMoves(-1);
let turnMove: TurnMove | undefined;
while (moveHistory.length) {
turnMove = moveHistory.shift();
if (!allMoves[turnMove?.move ?? Moves.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) {
break;
}
timesUsed++;
// Break after first move used this wave.
// If no move was used on turn 1, then it would have broken in the attr check already.
if (turnMove?.turn === 1) {
break;
}
}
if (timesUsed) {
return !user.randBattleSeedInt(Math.pow(3, timesUsed));
}
return true;
});
}