diff --git a/MultiversalDiplomacy/Model/Season.cs b/MultiversalDiplomacy/Model/Season.cs
index 84a3597..4100517 100644
--- a/MultiversalDiplomacy/Model/Season.cs
+++ b/MultiversalDiplomacy/Model/Season.cs
@@ -5,10 +5,10 @@ namespace MultiversalDiplomacy.Model;
///
/// Represents a state of the map produced by a set of move orders on a previous season.
///
-public class Season
+public class Season(string? past, int turn, string timeline)
{
///
- /// The first turn number.
+ /// The first turn number. This is defined to reduce confusion about whether the first turn is 0 or 1.
///
public const int FIRST_TURN = 0;
@@ -17,19 +17,19 @@ public class Season
/// If this season is an alternate timeline root, the past is from the origin timeline.
/// The initial season does not have a past.
///
- public string? Past { get; }
+ public string? Past { get; } = past;
///
/// The current turn, beginning at 0. Each season (spring and fall) is one turn.
/// Phases that only occur after the fall phase occur when Turn % 2 == 1.
/// The current year is (Turn / 2) + 1901.
///
- public int Turn { get; }
+ public int Turn { get; } = turn;
///
/// The timeline to which this season belongs.
///
- public string Timeline { get; }
+ public string Timeline { get; } = timeline;
///
/// The multiversal designation of this season.
@@ -37,18 +37,5 @@ public class Season
[JsonIgnore]
public string Designation => $"{this.Timeline}{this.Turn}";
- ///
- /// The season's multiversal location as a timeline-turn tuple for convenience.
- ///
- [JsonIgnore]
- public (string Timeline, int Turn) Coord => (this.Timeline, this.Turn);
-
- public Season(string? past, int turn, string timeline)
- {
- this.Past = past;
- this.Turn = turn;
- this.Timeline = timeline;
- }
-
public override string ToString() => Designation;
}
diff --git a/MultiversalDiplomacy/Model/World.cs b/MultiversalDiplomacy/Model/World.cs
index 7013a59..5138529 100644
--- a/MultiversalDiplomacy/Model/World.cs
+++ b/MultiversalDiplomacy/Model/World.cs
@@ -296,11 +296,10 @@ public class World
///
/// Returns a unit in a province. Throws if there are duplicate units.
///
- public Unit GetUnitAt(string provinceName, (string timeline, int turn)? seasonCoord = null)
+ public Unit GetUnitAt(string provinceName, Season? season = null)
{
Province province = Map.GetProvince(provinceName);
- seasonCoord ??= (this.RootSeason.Timeline, this.RootSeason.Turn);
- Season season = GetSeason(seasonCoord.Value.timeline, seasonCoord.Value.turn);
+ season ??= RootSeason;
Unit? foundUnit = this.Units.SingleOrDefault(
u => u!.Province == province && u.Season == season,
null)
diff --git a/MultiversalDiplomacyTests/MDATC_A.cs b/MultiversalDiplomacyTests/MDATC_A.cs
index b2b7961..59887e3 100644
--- a/MultiversalDiplomacyTests/MDATC_A.cs
+++ b/MultiversalDiplomacyTests/MDATC_A.cs
@@ -43,14 +43,14 @@ public class TimeTravelTest
// Confirm that there is a unit in Tyr b1 originating from Mun a1
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);
+ Unit originalUnit = world.GetUnitAt("Mun", s0);
+ Unit aMun0 = world.GetUnitAt("Mun", s1);
+ Unit aTyr = world.GetUnitAt("Tyr", fork);
Assert.That(aTyr.Past, Is.EqualTo(mun1.Order.Unit));
Assert.That(aTyr.Past?.Past, Is.EqualTo(mun0.Order.Unit));
// Confirm that there is a unit in Mun b1 originating from Mun a0
- Unit aMun1 = world.GetUnitAt("Mun", fork.Coord);
+ Unit aMun1 = world.GetUnitAt("Mun", fork);
Assert.That(aMun1.Past, Is.EqualTo(originalUnit));
}
@@ -92,7 +92,7 @@ public class TimeTravelTest
// Confirm that an alternate future is created.
World world = setup.UpdateWorld();
Season fork = world.GetSeason("b1");
- Unit tyr1 = world.GetUnitAt("Tyr", fork.Coord);
+ Unit tyr1 = world.GetUnitAt("Tyr", fork);
Assert.That(
tyr1.Past,
Is.EqualTo(mun0.Order.Unit),
diff --git a/MultiversalDiplomacyTests/MovementAdjudicatorTest.cs b/MultiversalDiplomacyTests/MovementAdjudicatorTest.cs
index 0ff1ea7..100e624 100644
--- a/MultiversalDiplomacyTests/MovementAdjudicatorTest.cs
+++ b/MultiversalDiplomacyTests/MovementAdjudicatorTest.cs
@@ -206,7 +206,7 @@ public class MovementAdjudicatorTest
Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1));
// Confirm the unit was created in the future
- Unit u2 = updated.GetUnitAt("Mun", s2.Coord);
+ Unit u2 = updated.GetUnitAt("Mun", s2);
Assert.That(updated.Units.Count, Is.EqualTo(2));
Assert.That(u2, Is.Not.EqualTo(mun1.Order.Unit));
Assert.That(u2.Past, Is.EqualTo(mun1.Order.Unit));
@@ -228,7 +228,7 @@ public class MovementAdjudicatorTest
// Update the world again
updated = setup.UpdateWorld();
Season s3 = updated.GetSeason(s2.Timeline, s2.Turn + 1);
- Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
+ Unit u3 = updated.GetUnitAt("Mun", s3);
Assert.That(u3.Past, Is.EqualTo(mun2.Order.Unit));
}
@@ -256,7 +256,7 @@ public class MovementAdjudicatorTest
Assert.That(s2.Turn, Is.EqualTo(s1.Turn + 1));
// Confirm the unit was created in the future
- Unit u2 = updated.GetUnitAt("Tyr", s2.Coord);
+ Unit u2 = updated.GetUnitAt("Tyr", s2);
Assert.That(updated.Units.Count, Is.EqualTo(2));
Assert.That(u2, Is.Not.EqualTo(mun1.Order.Unit));
Assert.That(u2.Past, Is.EqualTo(mun1.Order.Unit));
@@ -278,7 +278,7 @@ public class MovementAdjudicatorTest
// Update the world again
updated = setup.UpdateWorld();
Season s3 = updated.GetSeason(s2.Timeline, s2.Turn + 1);
- Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
+ Unit u3 = updated.GetUnitAt("Mun", s3);
Assert.That(u3.Past, Is.EqualTo(u2));
}
}
diff --git a/MultiversalDiplomacyTests/SerializationTest.cs b/MultiversalDiplomacyTests/SerializationTest.cs
index aff12e0..c1f41b1 100644
--- a/MultiversalDiplomacyTests/SerializationTest.cs
+++ b/MultiversalDiplomacyTests/SerializationTest.cs
@@ -84,7 +84,7 @@ public class SerializationTest
// Confirm that an alternate future is created.
World world = setup.UpdateWorld();
Season fork = world.GetSeason("b1");
- Unit tyr1 = world.GetUnitAt("Tyr", fork.Coord);
+ Unit tyr1 = world.GetUnitAt("Tyr", fork);
Assert.That(
tyr1.Past,
Is.EqualTo(mun0.Order.Unit),