Skip to content

Commit

Permalink
Fix RE 1 generation
Browse files Browse the repository at this point in the history
  • Loading branch information
IntelOrca committed Jan 12, 2023
1 parent 85754d2 commit fa64483
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 14 additions & 0 deletions IntelOrca.Biohazard.Tests/TestRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class TestRE1Rando : TestBaseRandomizer
public class TestRE2Rando : TestBaseRandomizer
{
public override byte Game => 2;

[Fact]
public void RandomizeEnemyPlacements()
{
RandomizeEnemyPlacementsInner();
}
}

public abstract class TestBaseRandomizer
Expand All @@ -28,6 +34,13 @@ public void RandomizeDoors()
Randomize(config);
}

protected void RandomizeEnemyPlacementsInner()
{
var config = GetBaseConfig();
config.RandomEnemyPlacement = true;
Randomize(config);
}

[Fact]
public void RandomizeItems_Shuffle()
{
Expand Down Expand Up @@ -97,6 +110,7 @@ private RandoConfig GetBaseConfig()
config.ShuffleItems = false;

config.RandomEnemies = true;
config.RandomEnemyPlacement = false;
config.EnemyDifficulty = 2;

config.IncludeNPCRE1 = true;
Expand Down
13 changes: 8 additions & 5 deletions IntelOrca.Biohazard/EnemyRandomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ public EnemyRandomiser(BioVersion version, RandoLogger logger, RandoConfig confi

private void ReadEnemyPlacements()
{
var json = _dataManager.GetText(_version, "enemy.json");
_enemyPositions = JsonSerializer.Deserialize<EnemyPosition[]>(json, new JsonSerializerOptions()
if (_config.RandomEnemyPlacement)
{
ReadCommentHandling = JsonCommentHandling.Skip,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
})!;
var json = _dataManager.GetText(_version, "enemy.json");
_enemyPositions = JsonSerializer.Deserialize<EnemyPosition[]>(json, new JsonSerializerOptions()
{
ReadCommentHandling = JsonCommentHandling.Skip,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
})!;
}
}

private byte GetNextKillId()
Expand Down

0 comments on commit fa64483

Please sign in to comment.