diff --git a/MultiversalDiplomacy/Model/ModelExtensions.cs b/MultiversalDiplomacy/Model/ModelExtensions.cs new file mode 100644 index 0000000..7d53187 --- /dev/null +++ b/MultiversalDiplomacy/Model/ModelExtensions.cs @@ -0,0 +1,23 @@ +namespace MultiversalDiplomacy.Model; + +public static class ModelExtensions +{ + /// + /// Short representation of a . + /// + public static string ToShort(this UnitType unitType) + => unitType switch + { + UnitType.Army => "A", + UnitType.Fleet => "F", + _ => throw new NotSupportedException($"Unknown unit type {unitType}"), + }; + + /// + /// Short representation of a multiversal location. + /// + public static string ToShort(this (Province province, Season season) coord) + { + return $"{coord.season.Timeline}-{coord.province.Abbreviations[0]}@{coord.season.Turn}"; + } +} \ No newline at end of file diff --git a/MultiversalDiplomacy/Model/Unit.cs b/MultiversalDiplomacy/Model/Unit.cs index c0ff9be..aebeb3f 100644 --- a/MultiversalDiplomacy/Model/Unit.cs +++ b/MultiversalDiplomacy/Model/Unit.cs @@ -51,7 +51,7 @@ public class Unit public override string ToString() { - return $"{this.Power} {this.Type} {this.Province} {this.Season}"; + return $"{this.Power.Name[0]} {this.Type.ToShort()} {(this.Province, this.Season).ToShort()}"; } /// diff --git a/MultiversalDiplomacy/Orders/ConvoyOrder.cs b/MultiversalDiplomacy/Orders/ConvoyOrder.cs index 6ee4d48..56e92d8 100644 --- a/MultiversalDiplomacy/Orders/ConvoyOrder.cs +++ b/MultiversalDiplomacy/Orders/ConvoyOrder.cs @@ -37,6 +37,6 @@ public class ConvoyOrder : UnitOrder public override string ToString() { - return $"{this.Unit} convoys {this.Target} -> {this.Province} {this.Season}"; + return $"{this.Unit} C {this.Target} -> {(this.Province, this.Season).ToShort()}"; } } diff --git a/MultiversalDiplomacy/Orders/MoveOrder.cs b/MultiversalDiplomacy/Orders/MoveOrder.cs index a6c1258..fbad4ea 100644 --- a/MultiversalDiplomacy/Orders/MoveOrder.cs +++ b/MultiversalDiplomacy/Orders/MoveOrder.cs @@ -36,7 +36,7 @@ public class MoveOrder : UnitOrder public override string ToString() { - return $"{this.Unit} -> {this.Province} {this.Season}"; + return $"{this.Unit} -> {(this.Province, this.Season).ToShort()}"; } /// diff --git a/MultiversalDiplomacy/Orders/SupportHoldOrder.cs b/MultiversalDiplomacy/Orders/SupportHoldOrder.cs index cdabe9e..c8e85cd 100644 --- a/MultiversalDiplomacy/Orders/SupportHoldOrder.cs +++ b/MultiversalDiplomacy/Orders/SupportHoldOrder.cs @@ -14,6 +14,6 @@ public class SupportHoldOrder : SupportOrder public override string ToString() { - return $"{this.Unit} supports {this.Target}"; + return $"{this.Unit} S {this.Target}"; } } \ No newline at end of file diff --git a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs index 0947174..db7a2fb 100644 --- a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs +++ b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs @@ -36,7 +36,7 @@ public class SupportMoveOrder : SupportOrder public override string ToString() { - return $"{this.Unit} supports {this.Target} -> {this.Province} {this.Season}"; + return $"{this.Unit} S {this.Target} -> {(this.Province, this.Season).ToShort()}"; } public bool IsSupportFor(MoveOrder move)