Rename PastId back to Past

This commit is contained in:
Tim Van Baak 2024-08-12 14:52:50 -07:00
parent 5e5483367d
commit 400263ea0b
4 changed files with 14 additions and 14 deletions

View File

@ -114,7 +114,7 @@ public static class PathFinder
List<Season> adjacents = []; List<Season> adjacents = [];
// The immediate past and all immediate futures are adjacent. // The immediate past and all immediate futures are adjacent.
if (season.PastId != null) adjacents.Add(world.GetSeason(season.PastId)); if (season.Past != null) adjacents.Add(world.GetSeason(season.Past));
adjacents.AddRange(season.Futures); adjacents.AddRange(season.Futures);
// Find all adjacent timelines by finding all timelines that branched off of this season's // Find all adjacent timelines by finding all timelines that branched off of this season's
@ -123,8 +123,8 @@ public static class PathFinder
List<Season> adjacentTimelineRoots = []; List<Season> adjacentTimelineRoots = [];
Season? current; Season? current;
for (current = season; for (current = season;
current?.PastId != null && world.GetSeason(current.PastId).Timeline == current.Timeline; current?.Past != null && world.GetSeason(current.Past).Timeline == current.Timeline;
current = world.GetSeason(current.PastId)) current = world.GetSeason(current.Past))
{ {
adjacentTimelineRoots.AddRange( adjacentTimelineRoots.AddRange(
current.Futures.Where(s => s.Timeline != current.Timeline)); current.Futures.Where(s => s.Timeline != current.Timeline));
@ -135,7 +135,7 @@ public static class PathFinder
// then current is the branch timeline's root season (current.past.timeline != // then current is the branch timeline's root season (current.past.timeline !=
// current.timeline). There are co-branches if this season is in a branched timeline, since // current.timeline). There are co-branches if this season is in a branched timeline, since
// the first timeline by definition cannot have co-branches. // the first timeline by definition cannot have co-branches.
if (current?.PastId != null && world.GetSeason(current.PastId) is Season past) if (current?.Past != null && world.GetSeason(current.Past) is Season past)
{ {
IEnumerable<Season> cobranchRoots = past.Futures IEnumerable<Season> cobranchRoots = past.Futures
.Where(s => s.Timeline != current.Timeline && s.Timeline != past.Timeline); .Where(s => s.Timeline != current.Timeline && s.Timeline != past.Timeline);

View File

@ -15,7 +15,7 @@ public class Season
/// If this season is an alternate timeline root, the past is from the origin timeline. /// If this season is an alternate timeline root, the past is from the origin timeline.
/// The initial season does not have a past. /// The initial season does not have a past.
/// </summary> /// </summary>
public string? PastId { get; } public string? Past { get; }
/// <summary> /// <summary>
/// The current turn, beginning at 0. Each season (spring and fall) is one turn. /// The current turn, beginning at 0. Each season (spring and fall) is one turn.
@ -47,7 +47,7 @@ public class Season
private Season(Season? past, int turn, string timeline, TimelineFactory factory) private Season(Season? past, int turn, string timeline, TimelineFactory factory)
{ {
this.PastId = past?.ToString(); this.Past = past?.ToString();
this.Turn = turn; this.Turn = turn;
this.Timeline = timeline; this.Timeline = timeline;
this.Timelines = factory; this.Timelines = factory;

View File

@ -245,10 +245,10 @@ public class World
/// </summary> /// </summary>
public Season GetTimelineRoot(Season season) public Season GetTimelineRoot(Season season)
{ {
if (season.PastId is null) { if (season.Past is null) {
return season; return season;
} }
Season past = SeasonLookup[season.PastId]; Season past = SeasonLookup[season.Past];
return season.Timeline == past.Timeline return season.Timeline == past.Timeline
? GetTimelineRoot(past) ? GetTimelineRoot(past)
: season; : season;
@ -270,9 +270,9 @@ public class World
// if they both branched off of the same point. // if they both branched off of the same point.
Season rootOne = GetTimelineRoot(one); Season rootOne = GetTimelineRoot(one);
Season rootTwo = GetTimelineRoot(two); Season rootTwo = GetTimelineRoot(two);
bool oneForked = rootOne.PastId != null && GetSeason(rootOne.PastId).Timeline == two.Timeline; bool oneForked = rootOne.Past != null && GetSeason(rootOne.Past).Timeline == two.Timeline;
bool twoForked = rootTwo.PastId != null && GetSeason(rootTwo.PastId).Timeline == one.Timeline; bool twoForked = rootTwo.Past != null && GetSeason(rootTwo.Past).Timeline == one.Timeline;
bool bothForked = rootOne.PastId == rootTwo.PastId; bool bothForked = rootOne.Past == rootTwo.Past;
return oneForked || twoForked || bothForked; return oneForked || twoForked || bothForked;
} }

View File

@ -171,7 +171,7 @@ public class MovementAdjudicatorTest
// Confirm the future was created // Confirm the future was created
Assert.That(updated.Seasons.Count, Is.EqualTo(2)); Assert.That(updated.Seasons.Count, Is.EqualTo(2));
Season future = updated.Seasons.Single(s => s != updated.RootSeason); Season future = updated.Seasons.Single(s => s != updated.RootSeason);
Assert.That(future.PastId, Is.EqualTo(updated.RootSeason.ToString())); Assert.That(future.Past, Is.EqualTo(updated.RootSeason.ToString()));
Assert.That(future.Futures, Is.Empty); Assert.That(future.Futures, Is.Empty);
Assert.That(future.Timeline, Is.EqualTo(updated.RootSeason.Timeline)); Assert.That(future.Timeline, Is.EqualTo(updated.RootSeason.Timeline));
Assert.That(future.Turn, Is.EqualTo(Season.FIRST_TURN + 1)); Assert.That(future.Turn, Is.EqualTo(Season.FIRST_TURN + 1));
@ -200,7 +200,7 @@ public class MovementAdjudicatorTest
// Confirm the future was created // Confirm the future was created
Season s2 = updated.GetSeason("a", 1); Season s2 = updated.GetSeason("a", 1);
Assert.That(s2.PastId, Is.EqualTo(s1.ToString())); Assert.That(s2.Past, Is.EqualTo(s1.ToString()));
Assert.That(s2.Futures, Is.Empty); Assert.That(s2.Futures, Is.Empty);
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline)); Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));
Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1)); Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1));
@ -250,7 +250,7 @@ public class MovementAdjudicatorTest
// Confirm the future was created // Confirm the future was created
Season s2 = updated.GetSeason(s1.Timeline, s1.Turn + 1); Season s2 = updated.GetSeason(s1.Timeline, s1.Turn + 1);
Assert.That(s2.PastId, Is.EqualTo(s1.ToString())); Assert.That(s2.Past, Is.EqualTo(s1.ToString()));
Assert.That(s2.Futures, Is.Empty); Assert.That(s2.Futures, Is.Empty);
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline)); Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));
Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1)); Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1));