Shorten string representations

The new format for representing timeline, province, and season is T-PRO@S. Hopefully this is easier to read than the PRO T:S format.
This commit is contained in:
Jaculabilis 2022-11-04 00:32:39 +00:00
parent 6347b52d4a
commit 46c28a087c
6 changed files with 28 additions and 5 deletions

View File

@ -0,0 +1,23 @@
namespace MultiversalDiplomacy.Model;
public static class ModelExtensions
{
/// <summary>
/// Short representation of a <see cref="UnitType"/>.
/// </summary>
public static string ToShort(this UnitType unitType)
=> unitType switch
{
UnitType.Army => "A",
UnitType.Fleet => "F",
_ => throw new NotSupportedException($"Unknown unit type {unitType}"),
};
/// <summary>
/// Short representation of a multiversal location.
/// </summary>
public static string ToShort(this (Province province, Season season) coord)
{
return $"{coord.season.Timeline}-{coord.province.Abbreviations[0]}@{coord.season.Turn}";
}
}

View File

@ -51,7 +51,7 @@ public class Unit
public override string ToString() 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()}";
} }
/// <summary> /// <summary>

View File

@ -37,6 +37,6 @@ public class ConvoyOrder : UnitOrder
public override string ToString() 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()}";
} }
} }

View File

@ -36,7 +36,7 @@ public class MoveOrder : UnitOrder
public override string ToString() public override string ToString()
{ {
return $"{this.Unit} -> {this.Province} {this.Season}"; return $"{this.Unit} -> {(this.Province, this.Season).ToShort()}";
} }
/// <summary> /// <summary>

View File

@ -14,6 +14,6 @@ public class SupportHoldOrder : SupportOrder
public override string ToString() public override string ToString()
{ {
return $"{this.Unit} supports {this.Target}"; return $"{this.Unit} S {this.Target}";
} }
} }

View File

@ -36,7 +36,7 @@ public class SupportMoveOrder : SupportOrder
public override string ToString() 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) public bool IsSupportFor(MoveOrder move)