Fix reintroducing stack overflow on enemy attack
parent
11ee81091b
commit
c98e5b8beb
|
@ -1978,15 +1978,15 @@ export default class BattleScene extends SceneBase {
|
||||||
|
|
||||||
applyShuffledModifiers(scene: BattleScene, modifierType: { new(...args: any[]): Modifier }, player: boolean = true, ...args: any[]): PersistentModifier[] {
|
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));
|
let modifiers = (player ? this.modifiers : this.enemyModifiers).filter(m => m instanceof modifierType && m.shouldApply(args));
|
||||||
if (modifiers.length > 1) {
|
scene.executeWithSeedOffset(() => {
|
||||||
scene.executeWithSeedOffset(() => {
|
const shuffleModifiers = mods => {
|
||||||
const shuffleModifiers = mods => {
|
if (mods.length < 1)
|
||||||
const rand = Math.floor(Utils.randSeedInt(mods.length));
|
return mods;
|
||||||
return [mods[rand], ...shuffleModifiers(mods.filter((_, i) => i !== rand))];
|
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);
|
modifiers = shuffleModifiers(modifiers);
|
||||||
}
|
}, scene.currentBattle.turn << 4, scene.waveSeed);
|
||||||
return this.applyModifiersInternal(modifiers, player, args);
|
return this.applyModifiersInternal(modifiers, player, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue