Add Timelines.All shortcut

This commit is contained in:
Tim Van Baak 2024-08-25 03:36:31 +00:00
parent 868138b988
commit 973f8ea0d7
2 changed files with 10 additions and 4 deletions

View File

@ -66,11 +66,17 @@ public class Timelines(int next, Dictionary<string, Season?> pasts)
public int Next { get; private set; } = next; public int Next { get; private set; } = next;
/// <summary> /// <summary>
/// Map of season designations to their parent seasons. /// Map of season designations to their parent seasons. Every season has an entry, so
/// The set of keys here is the set of all seasons in the multiverse. /// the set of keys is the set of existing seasons.
/// </summary> /// </summary>
public Dictionary<string, Season?> Pasts { get; } = pasts; public Dictionary<string, Season?> Pasts { get; } = pasts;
/// <summary>
/// All seasons in the multiverse.
/// </summary>
[JsonIgnore]
public IEnumerable<Season> Seasons => Pasts.Keys.Select(key => new Season(key));
/// <summary> /// <summary>
/// Create a new multiverse with an initial season. /// Create a new multiverse with an initial season.
/// </summary> /// </summary>

View File

@ -33,11 +33,11 @@ public class TimeTravelTest
// Confirm that there are now four seasons: three in the main timeline and one in a fork. // Confirm that there are now four seasons: three in the main timeline and one in a fork.
Assert.That( Assert.That(
world.Timelines.Pasts.Keys.Select(key => new Season(key)).Where(s => s.Timeline == s0.Timeline).Count(), world.Timelines.Seasons.Where(s => s.Timeline == s0.Timeline).Count(),
Is.EqualTo(3), Is.EqualTo(3),
"Failed to advance main timeline after last unit left"); "Failed to advance main timeline after last unit left");
Assert.That( Assert.That(
world.Timelines.Pasts.Keys.Select(key => new Season(key)).Where(s => s.Timeline != s0.Timeline).Count(), world.Timelines.Seasons.Where(s => s.Timeline != s0.Timeline).Count(),
Is.EqualTo(1), Is.EqualTo(1),
"Failed to fork timeline when unit moved in"); "Failed to fork timeline when unit moved in");