mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +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 {
|
getCondition(): MoveConditionFunc {
|
||||||
return ((user, target, move): boolean => {
|
return ((user, target, move): boolean => {
|
||||||
|
// Protect rng resets on new waves, it always succeeds.
|
||||||
|
if (user.tempSummonData.waveTurnCount === 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let timesUsed = 0;
|
let timesUsed = 0;
|
||||||
const moveHistory = user.getLastXMoves();
|
const moveHistory = user.getLastXMoves(-1);
|
||||||
let turnMove: TurnMove | undefined;
|
let turnMove: TurnMove | undefined;
|
||||||
|
|
||||||
while (moveHistory.length) {
|
while (moveHistory.length) {
|
||||||
turnMove = moveHistory.shift();
|
turnMove = moveHistory.shift();
|
||||||
|
|
||||||
if (!allMoves[turnMove?.move ?? Moves.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) {
|
if (!allMoves[turnMove?.move ?? Moves.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
timesUsed++;
|
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) {
|
if (timesUsed) {
|
||||||
return !user.randBattleSeedInt(Math.pow(3, timesUsed));
|
return !user.randBattleSeedInt(Math.pow(3, timesUsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user