Use a simpler override where available

This commit is contained in:
Tim Van Baak 2024-08-12 14:57:16 -07:00
parent 400263ea0b
commit 752a898123
3 changed files with 5 additions and 11 deletions

View File

@ -37,7 +37,7 @@ public class World
/// <summary>
/// The first season of the game.
/// </summary>
public Season RootSeason => GetSeason("a", 0);
public Season RootSeason => GetSeason("a0");
/// <summary>
/// All units in the multiverse.
@ -227,13 +227,7 @@ public class World
/// Get a season by coordinate. Throws if the season is not found.
/// </summary>
public Season GetSeason(string timeline, int turn)
{
Season? foundSeason = this.Seasons.SingleOrDefault(
s => s!.Turn == turn && s.Timeline == timeline,
null)
?? throw new KeyNotFoundException($"Season {timeline}@{turn} not found");
return foundSeason;
}
=> GetSeason($"{timeline}{turn}");
public Season GetSeason(string designation)
=> SeasonLookup[designation];

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("b", 1);
Season fork = world.GetSeason("b1");
Unit originalUnit = world.GetUnitAt("Mun", s0.Coord);
Unit aMun0 = world.GetUnitAt("Mun", s1.Coord);
Unit aTyr = world.GetUnitAt("Tyr", fork.Coord);
@ -91,7 +91,7 @@ public class TimeTravelTest
// Confirm that an alternate future is created.
World world = setup.UpdateWorld();
Season fork = world.GetSeason("b", 1);
Season fork = world.GetSeason("b1");
Unit tyr1 = world.GetUnitAt("Tyr", fork.Coord);
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("a", 1);
Season s2 = updated.GetSeason("a1");
Assert.That(s2.Past, Is.EqualTo(s1.ToString()));
Assert.That(s2.Futures, Is.Empty);
Assert.That(s2.Timeline, Is.EqualTo(s1.Timeline));