Remove GetSeason(string)

This commit is contained in:
Tim Van Baak 2024-08-14 22:03:56 -07:00
parent 868022d34f
commit f2d3d5a583
6 changed files with 14 additions and 20 deletions

View File

@ -114,7 +114,7 @@ public static class PathFinder
List<Season> adjacents = [];
// The immediate past and all immediate futures are adjacent.
if (season.Past != null) adjacents.Add(world.GetSeason(season.Past));
if (season.Past != null) adjacents.Add(world.Seasons[season.Past]);
adjacents.AddRange(world.GetFutures(season));
// 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 = [];
Season? current;
for (current = season;
current?.Past != null && world.GetSeason(current.Past).Timeline == current.Timeline;
current = world.GetSeason(current.Past))
current?.Past != null && world.Seasons[current.Past].Timeline == current.Timeline;
current = world.Seasons[current.Past])
{
adjacentTimelineRoots.AddRange(
world.GetFutures(current).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 !=
// current.timeline). There are co-branches if this season is in a branched timeline, since
// the first timeline by definition cannot have co-branches.
if (current?.Past != null && world.GetSeason(current.Past) is Season past)
if (current?.Past != null && world.Seasons[current.Past] is Season past)
{
IEnumerable<Season> cobranchRoots = world
.GetFutures(past)

View File

@ -48,7 +48,7 @@ public class World
/// The first season of the game.
/// </summary>
[JsonIgnore]
public Season RootSeason => GetSeason("a0");
public Season RootSeason => Seasons["a0"];
/// <summary>
/// All units in the multiverse.
@ -256,13 +256,7 @@ public class World
/// Get a season by coordinate. Throws if the season is not found.
/// </summary>
public Season GetSeason(string timeline, int turn)
=> GetSeason($"{timeline}{turn}");
/// <summary>
/// Get a season by designation.
/// </summary>
public Season GetSeason(string designation)
=> Seasons[designation];
=> Seasons[$"{timeline}{turn}"];
/// <summary>
/// Get all seasons that are immediate futures of a season.
@ -311,8 +305,8 @@ public class World
// if they both branched off of the same point.
Season rootOne = GetTimelineRoot(one);
Season rootTwo = GetTimelineRoot(two);
bool oneForked = rootOne.Past != null && GetSeason(rootOne.Past).Timeline == two.Timeline;
bool twoForked = rootTwo.Past != null && GetSeason(rootTwo.Past).Timeline == one.Timeline;
bool oneForked = rootOne.Past != null && Seasons[rootOne.Past].Timeline == two.Timeline;
bool twoForked = rootTwo.Past != null && Seasons[rootTwo.Past].Timeline == one.Timeline;
bool bothForked = rootOne.Past == rootTwo.Past;
return oneForked || twoForked || bothForked;
}

View File

@ -42,7 +42,7 @@ public class TimeTravelTest
"Failed to fork timeline when unit moved in");
// Confirm that there is a unit in Tyr b1 originating from Mun a1
Season fork = world.GetSeason("b1");
Season fork = world.Seasons["b1"];
Unit originalUnit = world.GetUnitAt("Mun", s0);
Unit aMun0 = world.GetUnitAt("Mun", s1);
Unit aTyr = world.GetUnitAt("Tyr", fork);
@ -91,7 +91,7 @@ public class TimeTravelTest
// Confirm that an alternate future is created.
World world = setup.UpdateWorld();
Season fork = world.GetSeason("b1");
Season fork = world.Seasons["b1"];
Unit tyr1 = world.GetUnitAt("Tyr", fork);
Assert.That(
tyr1.Past,

View File

@ -199,7 +199,7 @@ public class MovementAdjudicatorTest
World updated = setup.UpdateWorld();
// Confirm the future was created
Season s2 = updated.GetSeason("a1");
Season s2 = updated.Seasons["a1"];
Assert.That(s2.Past, Is.EqualTo(s1.ToString()));
Assert.That(updated.GetFutures(s2), Is.Empty);
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));

View File

@ -10,7 +10,7 @@ public class SeasonTests
public void TimelineForking()
{
World world = World.WithMap(Map.Test);
Season a0 = world.GetSeason("a0");
Season a0 = world.Seasons["a0"];
world = world
.ContinueOrFork(a0, out Season a1)
.ContinueOrFork(a1, out Season a2)

View File

@ -86,7 +86,7 @@ public class SerializationTest
setup = new(reserialized, MovementPhaseAdjudicator.Instance);
setup[("a", 1)]
["Germany"]
.Army("Mun").Supports.Army("Mun", season: reserialized.GetSeason("a0")).MoveTo("Tyr").GetReference(out var mun1)
.Army("Mun").Supports.Army("Mun", season: reserialized.Seasons["a0"]).MoveTo("Tyr").GetReference(out var mun1)
["Austria"]
.Army("Tyr").Holds();
@ -102,7 +102,7 @@ public class SerializationTest
// Confirm that an alternate future is created.
World world = setup.UpdateWorld();
Season fork = world.GetSeason("b1");
Season fork = world.Seasons["b1"];
Unit tyr1 = world.GetUnitAt("Tyr", fork);
Assert.That(
tyr1.Past,