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