Tests: END-1 Core drain/regen/lose-edge + persistence v4 (330/330 EditMode)
CoreSystemsTests (new): a breaching Husk drains + is consumed; idles at 0; regen fires once per interval in Calm only; no regen mid-Siege; caps at Max. CyclePhaseSystemTests: the soft-loss overrun edge ends the siege, drains the ledger, despawns husks, withholds the goal charge, and resolves once. StorageMathTests: DrainFraction floors per row, drops zeroed rows, clamps. SavePersistenceTests: CoreCurrent round-trips at v4; a pre-END-1 save with no CoreCurrent defaults to 0 (-> born full); the v3->v4 version pin updated. TuningConfig golden pin extended with the 3 Core defaults. See DR-034. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -108,7 +108,7 @@ namespace ProjectM.Tests
|
||||
{
|
||||
var data = new SaveData { Structures = new[] { new StructureSave { Type = 1, CellX = 1, CellZ = 2, HP = 37f } } };
|
||||
var back = JsonUtility.FromJson<SaveData>(JsonUtility.ToJson(data));
|
||||
Assert.AreEqual(3, back.Version, "EB-1: new saves write v3.");
|
||||
Assert.AreEqual(SaveData.CurrentVersion, back.Version, "new saves write the current version (v4 since END-1).");
|
||||
Assert.AreEqual(1, back.Structures.Length);
|
||||
Assert.AreEqual(37f, back.Structures[0].HP, 1e-4f, "the wounded HP round-trips through JSON.");
|
||||
}
|
||||
@@ -142,5 +142,26 @@ namespace ProjectM.Tests
|
||||
Assert.AreEqual(37f, p.HP, 1e-4f, "the wounded HP survives the save->staging copy.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CoreCurrent_RoundTrips_And_Writes_Current_Version()
|
||||
{
|
||||
var data = new SaveData { GoalCharge = 1, GoalTarget = 10, CoreCurrent = 63 };
|
||||
var back = JsonUtility.FromJson<SaveData>(JsonUtility.ToJson(data));
|
||||
Assert.AreEqual(SaveData.CurrentVersion, back.Version, "END-1: new saves write v4.");
|
||||
Assert.AreEqual(63, back.CoreCurrent, "the wounded Core integrity round-trips through JSON.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pre_END1_Save_Missing_CoreCurrent_Defaults_To_Zero()
|
||||
{
|
||||
// A pre-END-1 save JSON lacks the CoreCurrent field -> JsonUtility defaults it to 0, which the
|
||||
// born-correct spawn maps to the baked Max (the Core comes back full). Additive: no field, no break.
|
||||
var back = JsonUtility.FromJson<SaveData>("{\"Version\":3,\"GoalCharge\":2,\"GoalTarget\":10}");
|
||||
Assert.AreEqual(0, back.CoreCurrent, "missing CoreCurrent -> 0 -> restored full at baked Max.");
|
||||
Assert.GreaterOrEqual(back.Version, SaveData.MinLoadableVersion, "v3 stays within the additive load floor.");
|
||||
Assert.LessOrEqual(back.Version, SaveData.CurrentVersion);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user