From 973f8ea0d7ca0dafb7603241ca09d6253a9607d0 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sun, 25 Aug 2024 03:36:31 +0000 Subject: [PATCH] Add Timelines.All shortcut --- MultiversalDiplomacy/Model/Timelines.cs | 10 ++++++++-- MultiversalDiplomacyTests/MDATC_A.cs | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MultiversalDiplomacy/Model/Timelines.cs b/MultiversalDiplomacy/Model/Timelines.cs index bead274..5562f75 100644 --- a/MultiversalDiplomacy/Model/Timelines.cs +++ b/MultiversalDiplomacy/Model/Timelines.cs @@ -66,11 +66,17 @@ public class Timelines(int next, Dictionary pasts) public int Next { get; private set; } = next; /// - /// 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. /// public Dictionary Pasts { get; } = pasts; + /// + /// All seasons in the multiverse. + /// + [JsonIgnore] + public IEnumerable Seasons => Pasts.Keys.Select(key => new Season(key)); + /// /// Create a new multiverse with an initial season. /// diff --git a/MultiversalDiplomacyTests/MDATC_A.cs b/MultiversalDiplomacyTests/MDATC_A.cs index 4cba62a..bb8be0b 100644 --- a/MultiversalDiplomacyTests/MDATC_A.cs +++ b/MultiversalDiplomacyTests/MDATC_A.cs @@ -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");