From 2d1fabdc0329b6b309e0dd5291d752d9d06f6d21 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 1 Jan 2024 12:32:03 -0500 Subject: [PATCH] Ignore erroring modifiers when loading session --- src/system/modifier-data.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/system/modifier-data.ts b/src/system/modifier-data.ts index 88623018470..0f83c79be45 100644 --- a/src/system/modifier-data.ts +++ b/src/system/modifier-data.ts @@ -32,18 +32,23 @@ export default class ModifierData { if (!typeFunc) return null; - let type = typeFunc(); - type.id = this.typeId; - type.generatorId = this.typeGeneratorId; + try { + let type = typeFunc(); + type.id = this.typeId; + type.generatorId = this.typeGeneratorId; - if (type instanceof ModifierTypeGenerator) - type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyField(), this.typePregenArgs); + if (type instanceof ModifierTypeGenerator) + type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyField(), this.typePregenArgs); - const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier; + const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier; - if (ret.stackCount > ret.getMaxStackCount(scene)) - ret.stackCount = ret.getMaxStackCount(scene); + if (ret.stackCount > ret.getMaxStackCount(scene)) + ret.stackCount = ret.getMaxStackCount(scene); - return ret; + return ret; + } catch (err) { + console.error(err); + return null; + } } } \ No newline at end of file