From a1a3de162bbaa20f1e2eb01f44ea9d3b50cde6ec Mon Sep 17 00:00:00 2001 From: Unlocked <10186337+TheUnlocked@users.noreply.github.com> Date: Thu, 26 Aug 2021 22:08:19 -0400 Subject: [PATCH] Fix enemy shuffling --- DarkestDungeonRandomizer.csproj | 2 +- Randomizers/EnemyShuffler.cs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DarkestDungeonRandomizer.csproj b/DarkestDungeonRandomizer.csproj index ffc51f3..dd58b30 100644 --- a/DarkestDungeonRandomizer.csproj +++ b/DarkestDungeonRandomizer.csproj @@ -5,7 +5,7 @@ netcoreapp5.0 preview - 0.8 + 0.9 diff --git a/Randomizers/EnemyShuffler.cs b/Randomizers/EnemyShuffler.cs index 9526738..fc3f879 100644 --- a/Randomizers/EnemyShuffler.cs +++ b/Randomizers/EnemyShuffler.cs @@ -40,7 +40,6 @@ public void Randomize() foreach (var level in levels) { - Darkest[] shuffledDungeonFiles = null!; var dungeonFiles = dungeons.Select(dungeon => Darkest.LoadFromFile(model.GetGameDataPath(Path.Combine("dungeons", dungeon, $"{dungeon}.{level}.mash.darkest")))); if (model.RandomizeMonsters) { @@ -48,14 +47,14 @@ public void Randomize() var hallEnemyReplacements = ShuffleMap(hallEnemies); var roomEnemyReplacements = ShuffleMap(roomEnemies); var stallEnemyReplacements = ShuffleMap(stallEnemies); - shuffledDungeonFiles = ReplaceEnemies(dungeonFiles, hallEnemyReplacements, roomEnemyReplacements, stallEnemyReplacements).ToArray(); + dungeonFiles = ReplaceEnemies(dungeonFiles, hallEnemyReplacements, roomEnemyReplacements, stallEnemyReplacements); } if (model.RandomizeBosses) { // Exclude shrieker! - var bossLayouts = GetAllBossLayouts(dungeonFiles).ToArray(); + var bossLayouts = GetAllBossLayouts(dungeonFiles); var shuffledBossLayouts = bossLayouts.Shuffle(random); - shuffledDungeonFiles = ReplaceBosses(dungeonFiles, shuffledBossLayouts).ToArray(); + dungeonFiles = ReplaceBosses(dungeonFiles, shuffledBossLayouts); JObject questTypeFile = JObject.Parse(File.ReadAllText(model.GetGameDataPath(Path.Combine("campaign", "quest", "quest.types.json")))); var bossLayoutConversion = bossLayouts.Zip(shuffledBossLayouts, (original, shuffled) => (original, shuffled)); @@ -77,7 +76,7 @@ public void Randomize() File.WriteAllText(Path.Combine(questDir.FullName, "quest.types.json"), questTypeFile.ToString()); } - _ = dungeons.Zip(shuffledDungeonFiles, (dungeon, darkest) => + _ = dungeons.Zip(dungeonFiles, (dungeon, darkest) => { darkest.WriteToFile(Path.Combine(model.ModDirectory.FullName, "dungeons", dungeon, $"{dungeon}.{level}.mash.darkest")); return 0;