2022-02-18 19:24:00 +00:00
|
|
|
namespace MultiversalDiplomacy.Model;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a state of the map produced by a set of move orders on a previous season.
|
|
|
|
/// </summary>
|
|
|
|
public class Season
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The first turn number.
|
|
|
|
/// </summary>
|
|
|
|
public const int FIRST_TURN = 0;
|
|
|
|
|
2024-08-12 20:56:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The designation of the season immediately preceding this season.
|
|
|
|
/// If this season is an alternate timeline root, the past is from the origin timeline.
|
|
|
|
/// The initial season does not have a past.
|
|
|
|
/// </summary>
|
|
|
|
public string? PastId { get; }
|
|
|
|
|
2022-02-18 19:24:00 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The current turn, beginning at 0. Each season (spring and fall) is one turn.
|
|
|
|
/// Phases that only occur after the fall phase occur when Turn % 2 == 1.
|
|
|
|
/// The current year is (Turn / 2) + 1901.
|
|
|
|
/// </summary>
|
|
|
|
public int Turn { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The timeline to which this season belongs.
|
|
|
|
/// </summary>
|
2024-08-12 16:28:56 +00:00
|
|
|
public string Timeline { get; }
|
2022-02-18 19:24:00 +00:00
|
|
|
|
2022-03-30 00:16:00 +00:00
|
|
|
/// <summary>
|
2024-08-12 16:28:56 +00:00
|
|
|
/// The season's spatial location as a timeline-turn tuple.
|
2022-03-30 00:16:00 +00:00
|
|
|
/// </summary>
|
2024-08-12 16:28:56 +00:00
|
|
|
public (string Timeline, int Turn) Coord => (this.Timeline, this.Turn);
|
2022-03-30 00:16:00 +00:00
|
|
|
|
2022-02-18 19:24:00 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The shared timeline number generator.
|
|
|
|
/// </summary>
|
|
|
|
private TimelineFactory Timelines { get; }
|
|
|
|
|
2022-03-13 04:29:00 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Future seasons created directly from this season.
|
|
|
|
/// </summary>
|
|
|
|
public IEnumerable<Season> Futures => this.FutureList;
|
|
|
|
private List<Season> FutureList { get; }
|
|
|
|
|
2024-08-12 16:28:56 +00:00
|
|
|
private Season(Season? past, int turn, string timeline, TimelineFactory factory)
|
2022-02-18 19:24:00 +00:00
|
|
|
{
|
2024-08-12 20:56:06 +00:00
|
|
|
this.PastId = past?.ToString();
|
2022-02-18 19:24:00 +00:00
|
|
|
this.Turn = turn;
|
|
|
|
this.Timeline = timeline;
|
|
|
|
this.Timelines = factory;
|
2024-08-12 16:28:56 +00:00
|
|
|
this.FutureList = [];
|
2022-03-13 04:29:00 +00:00
|
|
|
|
2024-08-12 16:28:56 +00:00
|
|
|
past?.FutureList.Add(this);
|
2022-02-18 19:24:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-16 00:36:47 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
2024-08-12 20:56:06 +00:00
|
|
|
return $"{this.Timeline}{this.Turn}";
|
2022-03-16 00:36:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-18 19:24:00 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Create a root season at the beginning of time.
|
|
|
|
/// </summary>
|
|
|
|
public static Season MakeRoot()
|
|
|
|
{
|
|
|
|
TimelineFactory factory = new TimelineFactory();
|
|
|
|
return new Season(
|
|
|
|
past: null,
|
|
|
|
turn: FIRST_TURN,
|
2024-08-12 16:28:56 +00:00
|
|
|
timeline: factory.NextTimeline(),
|
2022-02-18 19:24:00 +00:00
|
|
|
factory: factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a season immediately after this one in the same timeline.
|
|
|
|
/// </summary>
|
|
|
|
public Season MakeNext()
|
2024-08-12 16:28:56 +00:00
|
|
|
=> new(this, Turn + 1, Timeline, Timelines);
|
2022-02-18 19:24:00 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a season immediately after this one in a new timeline.
|
|
|
|
/// </summary>
|
|
|
|
public Season MakeFork()
|
2024-08-12 16:28:56 +00:00
|
|
|
=> new(this, Turn + 1, Timelines.NextTimeline(), Timelines);
|
2022-02-18 19:24:00 +00:00
|
|
|
}
|