From b201cf0abcca00a8fa31900df8db24c7566a3f22 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 21 Mar 2024 01:05:46 -0400 Subject: [PATCH] Fix trainer-related crash when loading data --- src/system/game-data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 74fcdbff2..b95b09cac 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -576,8 +576,8 @@ export class GameData { scene.updateScoreText(); const battleType = sessionData.battleType || 0; - const trainerConfig = trainerConfigs[sessionData.trainer.trainerType]; - const battle = scene.newBattle(sessionData.waveIndex, battleType, sessionData.trainer, battleType === BattleType.TRAINER ? trainerConfig.doubleOnly || sessionData.trainer.variant === TrainerVariant.DOUBLE : sessionData.enemyParty.length > 1); + const trainerConfig = sessionData.trainer ? trainerConfigs[sessionData.trainer.trainerType] : null; + const battle = scene.newBattle(sessionData.waveIndex, battleType, sessionData.trainer, battleType === BattleType.TRAINER ? trainerConfig?.doubleOnly || sessionData.trainer?.variant === TrainerVariant.DOUBLE : sessionData.enemyParty.length > 1); battle.enemyLevels = sessionData.enemyParty.map(p => p.level); scene.newArena(sessionData.arena.biome, true);