mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 23:42:18 +02:00
Protect rng now resets on new waves and fixed to look at all turns in the same wave.
This commit is contained in:
parent
a0484bbde1
commit
00ab9eb225
@ -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;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user