Skip to content

Commit

Permalink
Fix enemy shuffling
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnlocked committed Aug 27, 2021
1 parent ce38576 commit a1a3de1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DarkestDungeonRandomizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>netcoreapp5.0</TargetFramework>
<LangVersion>preview</LangVersion>

<Version>0.8</Version>
<Version>0.9</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions Randomizers/EnemyShuffler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ 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)
{
var (hallEnemies, roomEnemies, stallEnemies) = GetAllEnemies(dungeonFiles);
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));
Expand All @@ -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;
Expand Down

0 comments on commit a1a3de1

Please sign in to comment.