Remove GetSeason(string)
This commit is contained in:
parent
868022d34f
commit
f2d3d5a583
|
@ -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.Past != null) adjacents.Add(world.GetSeason(season.Past));
|
if (season.Past != null) adjacents.Add(world.Seasons[season.Past]);
|
||||||
adjacents.AddRange(world.GetFutures(season));
|
adjacents.AddRange(world.GetFutures(season));
|
||||||
|
|
||||||
// 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?.Past != null && world.GetSeason(current.Past).Timeline == current.Timeline;
|
current?.Past != null && world.Seasons[current.Past].Timeline == current.Timeline;
|
||||||
current = world.GetSeason(current.Past))
|
current = world.Seasons[current.Past])
|
||||||
{
|
{
|
||||||
adjacentTimelineRoots.AddRange(
|
adjacentTimelineRoots.AddRange(
|
||||||
world.GetFutures(current).Where(s => s.Timeline != current.Timeline));
|
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 !=
|
// 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?.Past != null && world.GetSeason(current.Past) is Season past)
|
if (current?.Past != null && world.Seasons[current.Past] is Season past)
|
||||||
{
|
{
|
||||||
IEnumerable<Season> cobranchRoots = world
|
IEnumerable<Season> cobranchRoots = world
|
||||||
.GetFutures(past)
|
.GetFutures(past)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class World
|
||||||
/// The first season of the game.
|
/// The first season of the game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Season RootSeason => GetSeason("a0");
|
public Season RootSeason => Seasons["a0"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All units in the multiverse.
|
/// All units in the multiverse.
|
||||||
|
@ -256,13 +256,7 @@ public class World
|
||||||
/// Get a season by coordinate. Throws if the season is not found.
|
/// Get a season by coordinate. Throws if the season is not found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Season GetSeason(string timeline, int turn)
|
public Season GetSeason(string timeline, int turn)
|
||||||
=> GetSeason($"{timeline}{turn}");
|
=> Seasons[$"{timeline}{turn}"];
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get a season by designation.
|
|
||||||
/// </summary>
|
|
||||||
public Season GetSeason(string designation)
|
|
||||||
=> Seasons[designation];
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all seasons that are immediate futures of a season.
|
/// 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.
|
// 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.Past != null && GetSeason(rootOne.Past).Timeline == two.Timeline;
|
bool oneForked = rootOne.Past != null && Seasons[rootOne.Past].Timeline == two.Timeline;
|
||||||
bool twoForked = rootTwo.Past != null && GetSeason(rootTwo.Past).Timeline == one.Timeline;
|
bool twoForked = rootTwo.Past != null && Seasons[rootTwo.Past].Timeline == one.Timeline;
|
||||||
bool bothForked = rootOne.Past == rootTwo.Past;
|
bool bothForked = rootOne.Past == rootTwo.Past;
|
||||||
return oneForked || twoForked || bothForked;
|
return oneForked || twoForked || bothForked;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class TimeTravelTest
|
||||||
"Failed to fork timeline when unit moved in");
|
"Failed to fork timeline when unit moved in");
|
||||||
|
|
||||||
// Confirm that there is a unit in Tyr b1 originating from Mun a1
|
// 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 originalUnit = world.GetUnitAt("Mun", s0);
|
||||||
Unit aMun0 = world.GetUnitAt("Mun", s1);
|
Unit aMun0 = world.GetUnitAt("Mun", s1);
|
||||||
Unit aTyr = world.GetUnitAt("Tyr", fork);
|
Unit aTyr = world.GetUnitAt("Tyr", fork);
|
||||||
|
@ -91,7 +91,7 @@ public class TimeTravelTest
|
||||||
|
|
||||||
// Confirm that an alternate future is created.
|
// Confirm that an alternate future is created.
|
||||||
World world = setup.UpdateWorld();
|
World world = setup.UpdateWorld();
|
||||||
Season fork = world.GetSeason("b1");
|
Season fork = world.Seasons["b1"];
|
||||||
Unit tyr1 = world.GetUnitAt("Tyr", fork);
|
Unit tyr1 = world.GetUnitAt("Tyr", fork);
|
||||||
Assert.That(
|
Assert.That(
|
||||||
tyr1.Past,
|
tyr1.Past,
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class MovementAdjudicatorTest
|
||||||
World updated = setup.UpdateWorld();
|
World updated = setup.UpdateWorld();
|
||||||
|
|
||||||
// Confirm the future was created
|
// 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(s2.Past, Is.EqualTo(s1.ToString()));
|
||||||
Assert.That(updated.GetFutures(s2), Is.Empty);
|
Assert.That(updated.GetFutures(s2), Is.Empty);
|
||||||
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));
|
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class SeasonTests
|
||||||
public void TimelineForking()
|
public void TimelineForking()
|
||||||
{
|
{
|
||||||
World world = World.WithMap(Map.Test);
|
World world = World.WithMap(Map.Test);
|
||||||
Season a0 = world.GetSeason("a0");
|
Season a0 = world.Seasons["a0"];
|
||||||
world = world
|
world = world
|
||||||
.ContinueOrFork(a0, out Season a1)
|
.ContinueOrFork(a0, out Season a1)
|
||||||
.ContinueOrFork(a1, out Season a2)
|
.ContinueOrFork(a1, out Season a2)
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class SerializationTest
|
||||||
setup = new(reserialized, MovementPhaseAdjudicator.Instance);
|
setup = new(reserialized, MovementPhaseAdjudicator.Instance);
|
||||||
setup[("a", 1)]
|
setup[("a", 1)]
|
||||||
["Germany"]
|
["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"]
|
["Austria"]
|
||||||
.Army("Tyr").Holds();
|
.Army("Tyr").Holds();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class SerializationTest
|
||||||
|
|
||||||
// Confirm that an alternate future is created.
|
// Confirm that an alternate future is created.
|
||||||
World world = setup.UpdateWorld();
|
World world = setup.UpdateWorld();
|
||||||
Season fork = world.GetSeason("b1");
|
Season fork = world.Seasons["b1"];
|
||||||
Unit tyr1 = world.GetUnitAt("Tyr", fork);
|
Unit tyr1 = world.GetUnitAt("Tyr", fork);
|
||||||
Assert.That(
|
Assert.That(
|
||||||
tyr1.Past,
|
tyr1.Past,
|
||||||
|
|
Loading…
Reference in New Issue