Organize simulation systems and balancing profiles
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
namespace ReactorMaintenance.Simulation.Tests;
|
||||
using ReactorMaintenance.Simulation.Difficulties;
|
||||
using ReactorMaintenance.Simulation.Effects;
|
||||
using ReactorMaintenance.Simulation.Hazards;
|
||||
|
||||
namespace ReactorMaintenance.Simulation.Tests;
|
||||
|
||||
public sealed class SimulationEngineTests
|
||||
{
|
||||
@@ -9,9 +13,9 @@ public sealed class SimulationEngineTests
|
||||
.SetCell(new(2, 2), new() {
|
||||
Kind = ECellKind.Generator,
|
||||
Pipe = EPipeMedium.Fuel,
|
||||
LeakRate = Balancing.FuelVaporFireThreshold,
|
||||
Pressure = Balancing.PressurizedFuelLeakPressureThreshold + Balancing.NeighborDistance,
|
||||
Integrity = Balancing.DefaultEditedPipeIntegrity,
|
||||
LeakRate = Balancing.Current.FuelVaporFireThreshold,
|
||||
Pressure = Balancing.Current.PressurizedFuelLeakPressureThreshold + Balancing.Current.NeighborDistance,
|
||||
Integrity = Balancing.Current.DefaultEditedPipeIntegrity,
|
||||
Powered = true
|
||||
});
|
||||
|
||||
@@ -26,13 +30,13 @@ public sealed class SimulationEngineTests
|
||||
var level = LevelState.Create("Wet cable", 6, 6)
|
||||
.SetCell(new(3, 3), new() {
|
||||
Pipe = EPipeMedium.Coolant,
|
||||
LeakRate = Balancing.ElectrifiedCoolantPoolingThreshold,
|
||||
LeakRate = Balancing.Current.ElectrifiedCoolantPoolingThreshold,
|
||||
Powered = true
|
||||
});
|
||||
|
||||
var next = m_Engine.AdvanceTurn(level);
|
||||
|
||||
Assert.True(next.GetCell(new(3, 3)).Hazards.ElectricalCharge >= Balancing.ElectricalChargeIncrease);
|
||||
Assert.True(next.GetCell(new(3, 3)).Hazards.ElectricalCharge >= Balancing.Current.ElectricalChargeIncrease);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -42,7 +46,7 @@ public sealed class SimulationEngineTests
|
||||
.SetCell(new(2, 2), new() {
|
||||
Hazards = new() {
|
||||
Fire = true,
|
||||
Smoke = Balancing.SmokeSpreadThreshold
|
||||
Smoke = Balancing.Current.SmokeSpreadThreshold
|
||||
}
|
||||
});
|
||||
|
||||
@@ -99,8 +103,28 @@ public sealed class SimulationEngineTests
|
||||
|
||||
var forecasts = engine.Forecast(level);
|
||||
|
||||
Assert.Equal(Balancing.MaxForecastStepCount, forecasts.Count);
|
||||
Assert.Equal(Balancing.MaxForecastStepCount, forecasts.Max(forecast => forecast.Turns));
|
||||
Assert.Equal(Balancing.Current.MaxForecastStepCount, forecasts.Count);
|
||||
Assert.Equal(Balancing.Current.MaxForecastStepCount, forecasts.Max(forecast => forecast.Turns));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForecastUsesCurrentBalancingProfile()
|
||||
{
|
||||
var previous = Balancing.Current;
|
||||
try
|
||||
{
|
||||
Balancing.Current = new TestBalancing();
|
||||
var engine = new SimulationEngine([], [], [new StepCountingHazard()]);
|
||||
var level = LevelState.Create("Stable", 6, 6);
|
||||
|
||||
var forecasts = engine.Forecast(level);
|
||||
|
||||
Assert.Equal(Balancing.Current.MaxForecastStepCount, forecasts.Count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Balancing.Current = previous;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -109,7 +133,7 @@ public sealed class SimulationEngineTests
|
||||
var level = LevelState.Create("Meltdown", 6, 6)
|
||||
.SetCell(new(2, 2), new() {
|
||||
Kind = ECellKind.Reactor,
|
||||
Hazards = new() { Heat = Balancing.MeltdownCoreHeatThreshold - Balancing.ReactorHeatIncrease }
|
||||
Hazards = new() { Heat = Balancing.Current.MeltdownCoreHeatThreshold - Balancing.Current.ReactorHeatIncrease }
|
||||
});
|
||||
|
||||
var forecasts = m_Engine.Forecast(level);
|
||||
@@ -122,7 +146,7 @@ public sealed class SimulationEngineTests
|
||||
{
|
||||
var level = LevelState.Create("Lost", 6, 6) with {
|
||||
Global = new() {
|
||||
CoreHeat = Balancing.MeltdownCoreHeatThreshold,
|
||||
CoreHeat = Balancing.Current.MeltdownCoreHeatThreshold,
|
||||
Lost = true,
|
||||
Status = "CORE MELTDOWN"
|
||||
}
|
||||
@@ -139,9 +163,9 @@ public sealed class SimulationEngineTests
|
||||
var level = LevelState.Create("Collapse", 6, 6)
|
||||
.SetCell(new(2, 2), new() {
|
||||
Kind = ECellKind.Generator,
|
||||
Hazards = new() { Stability = Balancing.CriticalCellStabilityThreshold }
|
||||
Hazards = new() { Stability = Balancing.Current.CriticalCellStabilityThreshold }
|
||||
}) with {
|
||||
Global = new() { FacilityStability = Balancing.FireStabilityDamage }
|
||||
Global = new() { FacilityStability = Balancing.Current.FireStabilityDamage }
|
||||
};
|
||||
|
||||
var forecasts = m_Engine.Forecast(level);
|
||||
@@ -200,6 +224,11 @@ public sealed class SimulationEngineTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class TestBalancing : NormalBalancing
|
||||
{
|
||||
public override int MaxForecastStepCount => 2;
|
||||
}
|
||||
|
||||
private sealed class TestCellEffect : ISimulationEffect
|
||||
{
|
||||
public CellState Apply(CellState cell)
|
||||
|
||||
Reference in New Issue
Block a user