5dplomacy/MultiversalDiplomacy/Model/ModelExtensions.cs

30 lines
940 B
C#
Raw Normal View History

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}";
}
public static World ContinueOrFork(this World world, Season season, out Season future)
{
future = world.ContinueOrFork(season);
2024-08-15 05:00:22 +00:00
return world.Update(seasons: world.Seasons.Values.Append(future));
}
}