diff --git a/MultiversalDiplomacy/Model/Map.cs b/MultiversalDiplomacy/Model/Map.cs index cdd4a91..0597dc4 100644 --- a/MultiversalDiplomacy/Model/Map.cs +++ b/MultiversalDiplomacy/Model/Map.cs @@ -88,12 +88,12 @@ public class Map /// public Power GetPower(string powerName) => Powers.SingleOrDefault(p => p!.Name == powerName || p.Name.StartsWith(powerName), null) - ?? throw new KeyNotFoundException($"Power {powerName} not found"); + ?? throw new KeyNotFoundException($"Power {powerName} not found (powers: {string.Join(", ", Powers)})"); public static Map FromType(MapType type) => type switch { MapType.Test => Test, - MapType.Classical => Test, + MapType.Classical => Classical, _ => throw new NotImplementedException($"Unknown variant {type}"), }; diff --git a/MultiversalDiplomacy/Model/Unit.cs b/MultiversalDiplomacy/Model/Unit.cs index e1bda17..07ccd17 100644 --- a/MultiversalDiplomacy/Model/Unit.cs +++ b/MultiversalDiplomacy/Model/Unit.cs @@ -1,3 +1,5 @@ +using System.Text.Json.Serialization; + namespace MultiversalDiplomacy.Model; /// @@ -33,9 +35,10 @@ public class Unit /// /// A unique designation for this unit. /// + [JsonIgnore] public string Designation => $"{Type.ToShort()} {Season.Timeline}-{Location}@{Season.Turn}"; - private Unit(string? past, string location, Season season, Power power, UnitType type) + public Unit(string? past, string location, Season season, Power power, UnitType type) { this.Past = past; this.Location = location; diff --git a/MultiversalDiplomacyTests/SerializationTest.cs b/MultiversalDiplomacyTests/SerializationTest.cs index 9bc1095..8a34f3d 100644 --- a/MultiversalDiplomacyTests/SerializationTest.cs +++ b/MultiversalDiplomacyTests/SerializationTest.cs @@ -64,11 +64,9 @@ public class SerializationTest Assert.That(tyr0, Is.NotDislodged); setup.UpdateWorld(); - // Serialize the world + // Serialize and deserialize the world string serialized = JsonSerializer.Serialize(setup.World, Options); - - // Deserialize the world - Console.WriteLine(serialized); + // Console.WriteLine(serialized); World reserialized = JsonSerializer.Deserialize(serialized, Options) ?? throw new AssertionException("Failed to reserialize world");