add properties for IsLive and IsLegacy

This commit is contained in:
Florian Stinglmayr 2022-11-28 13:32:54 +01:00
parent d2aadf9882
commit bb74d72b13
2 changed files with 20 additions and 0 deletions

View File

@ -26,6 +26,22 @@ public class FileHeaderEntry : Entry {
/// </summary> /// </summary>
public string? Build { get; set; } public string? Build { get; set; }
/// <summary>
/// Returns true if the version is legacy (3.X)
/// <summary>
public bool IsLegacy {
get {
return GameVersion.StartsWith("3.");
}
}
/// <summary>
/// Returns true if the version is live (4.x)
/// </summary>
public bool IsLive {
get { return !IsLegacy; }
}
protected override void Initialise() { protected override void Initialise() {
Part = JSON.Value<ulong?>("part") ?? 1; Part = JSON.Value<ulong?>("part") ?? 1;
Language = JSON.Value<string?>("language") ?? string.Empty; Language = JSON.Value<string?>("language") ?? string.Empty;

View File

@ -21,6 +21,8 @@ public class FileHeaderTest {
Assert.AreEqual(header.Language, "English/UK"); Assert.AreEqual(header.Language, "English/UK");
Assert.AreEqual(header.Odyssey, true); Assert.AreEqual(header.Odyssey, true);
Assert.AreEqual(header.GameVersion, "4.0.0.1450"); Assert.AreEqual(header.GameVersion, "4.0.0.1450");
Assert.AreEqual(header.IsLegacy, false);
Assert.AreEqual(header.IsLive, true);
// Someone at FDev messed up string building there. // Someone at FDev messed up string building there.
Assert.AreEqual(header.Build, "r286858/r0 "); Assert.AreEqual(header.Build, "r286858/r0 ");
} }
@ -44,6 +46,8 @@ public class FileHeaderTest {
Assert.AreEqual(header.Language, """English\UK"""); Assert.AreEqual(header.Language, """English\UK""");
Assert.AreEqual(header.Odyssey, false); Assert.AreEqual(header.Odyssey, false);
Assert.AreEqual(header.GameVersion, "3.5.3.400 EDH"); Assert.AreEqual(header.GameVersion, "3.5.3.400 EDH");
Assert.AreEqual(header.IsLegacy, true);
Assert.AreEqual(header.IsLive, false);
// ~73k commits in two years. Not bad. // ~73k commits in two years. Not bad.
Assert.AreEqual(header.Build, "r213094/r0 "); Assert.AreEqual(header.Build, "r213094/r0 ");
} }