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:
parent
6347b52d4a
commit
46c28a087c
23
MultiversalDiplomacy/Model/ModelExtensions.cs
Normal file
23
MultiversalDiplomacy/Model/ModelExtensions.cs
Normal 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}";
|
||||
}
|
||||
}
|
@ -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()}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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()}";
|
||||
}
|
||||
}
|
||||
|
@ -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()}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -14,6 +14,6 @@ public class SupportHoldOrder : SupportOrder
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.Unit} supports {this.Target}";
|
||||
return $"{this.Unit} S {this.Target}";
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user