Eliminate RootSeason field

This commit is contained in:
Tim Van Baak 2024-08-12 10:59:48 -07:00
parent 421e84b559
commit b887e01334
1 changed files with 5 additions and 10 deletions

View File

@ -32,7 +32,7 @@ public class World
/// <summary> /// <summary>
/// The first season of the game. /// The first season of the game.
/// </summary> /// </summary>
public Season RootSeason { get; } public Season RootSeason => GetSeason("a", 0);
/// <summary> /// <summary>
/// All units in the multiverse. /// All units in the multiverse.
@ -60,7 +60,6 @@ public class World
private World( private World(
Map map, Map map,
ReadOnlyCollection<Season> seasons, ReadOnlyCollection<Season> seasons,
Season rootSeason,
ReadOnlyCollection<Unit> units, ReadOnlyCollection<Unit> units,
ReadOnlyCollection<RetreatingUnit> retreatingUnits, ReadOnlyCollection<RetreatingUnit> retreatingUnits,
ReadOnlyDictionary<Season, OrderHistory> orderHistory, ReadOnlyDictionary<Season, OrderHistory> orderHistory,
@ -68,7 +67,6 @@ public class World
{ {
this.Map = map; this.Map = map;
this.Seasons = seasons; this.Seasons = seasons;
this.RootSeason = rootSeason;
this.Units = units; this.Units = units;
this.RetreatingUnits = retreatingUnits; this.RetreatingUnits = retreatingUnits;
this.OrderHistory = orderHistory; this.OrderHistory = orderHistory;
@ -88,7 +86,6 @@ public class World
: this( : this(
previous.Map, previous.Map,
seasons ?? previous.Seasons, seasons ?? previous.Seasons,
previous.RootSeason, // Can't change the root season
units ?? previous.Units, units ?? previous.Units,
retreatingUnits ?? previous.RetreatingUnits, retreatingUnits ?? previous.RetreatingUnits,
orderHistory ?? previous.OrderHistory, orderHistory ?? previous.OrderHistory,
@ -101,13 +98,11 @@ public class World
/// </summary> /// </summary>
public static World WithMap(Map map) public static World WithMap(Map map)
{ {
Season root = Season.MakeRoot();
return new World( return new World(
map, map,
new(new List<Season> { root }), new([Season.MakeRoot()]),
root, new([]),
new(new List<Unit>()), new([]),
new(new List<RetreatingUnit>()),
new(new Dictionary<Season, OrderHistory>()), new(new Dictionary<Season, OrderHistory>()),
new Options()); new Options());
} }
@ -123,7 +118,7 @@ public class World
IEnumerable<Unit>? units = null, IEnumerable<Unit>? units = null,
IEnumerable<RetreatingUnit>? retreats = null, IEnumerable<RetreatingUnit>? retreats = null,
IEnumerable<KeyValuePair<Season, OrderHistory>>? orders = null) IEnumerable<KeyValuePair<Season, OrderHistory>>? orders = null)
=> new World( => new(
previous: this, previous: this,
seasons: seasons == null seasons: seasons == null
? this.Seasons ? this.Seasons