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;
/// <summary>
/// Map of season designations to their parent seasons.
/// The set of keys here is the set of all seasons in the multiverse.
/// Map of season designations to their parent seasons. Every season has an entry, so
/// the set of keys is the set of existing seasons.
/// </summary>
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>
/// Create a new multiverse with an initial season.
/// </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.
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),
"Failed to advance main timeline after last unit left");
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),
"Failed to fork timeline when unit moved in");