Fix reintroducing stack overflow on enemy attack

pull/256/head
Flashfyre 2024-04-23 09:52:02 -04:00
parent 11ee81091b
commit c98e5b8beb
1 changed files with 9 additions and 9 deletions

View File

@ -1978,15 +1978,15 @@ export default class BattleScene extends SceneBase {
applyShuffledModifiers(scene: BattleScene, modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): PersistentModifier[] {
let modifiers = (player ? this.modifiers : this.enemyModifiers).filter(m => m instanceof modifierType && m.shouldApply(args));
if (modifiers.length > 1) {
scene.executeWithSeedOffset(() => {
const shuffleModifiers = mods => {
const rand = Math.floor(Utils.randSeedInt(mods.length));
return [mods[rand], ...shuffleModifiers(mods.filter((_, i) => i !== rand))];
};
modifiers = shuffleModifiers(modifiers);
}, scene.currentBattle.turn << 4, scene.waveSeed);
}
scene.executeWithSeedOffset(() => {
const shuffleModifiers = mods => {
if (mods.length < 1)
return mods;
const rand = Math.floor(Utils.randSeedInt(mods.length));
return [mods[rand], ...shuffleModifiers(mods.filter((_, i) => i !== rand))];
};
modifiers = shuffleModifiers(modifiers);
}, scene.currentBattle.turn << 4, scene.waveSeed);
return this.applyModifiersInternal(modifiers, player, args);
}