Add OrderSet model

This commit is contained in:
Jaculabilis 2022-12-29 10:21:37 -08:00
parent 0f201610d2
commit 73fc94e5c7
2 changed files with 44 additions and 2 deletions

View File

@ -0,0 +1,28 @@
namespace MultiversalDiplomacy.Model;
/// <summary>
/// A list of unit orders submitted by a power.
/// </summary>
public class OrderSet
{
/// <summary>
/// The raw text of the submitted orders, including the name of the submitting power.
/// </summary>
public string Text { get; }
/// <summary>
/// Whether the order set has already been adjudicated.
/// </summary>
public bool Adjudicated { get; }
/// <summary>
/// UTC timestamp at which the order set was submitted
/// </summary>
public DateTime SubmittedAt { get; }
public OrderSet(string text)
{
Text = text;
SubmittedAt = DateTime.UtcNow;
}
}

View File

@ -44,6 +44,11 @@ public class World
/// </summary> /// </summary>
public ReadOnlyDictionary<Season, OrderHistory> OrderHistory { get; } public ReadOnlyDictionary<Season, OrderHistory> OrderHistory { get; }
/// <summary>
/// Submitted order sets.
/// </summary>
public ReadOnlyCollection<OrderSet> OrderSets { get; }
/// <summary> /// <summary>
/// Immutable game options. /// Immutable game options.
/// </summary> /// </summary>
@ -60,6 +65,7 @@ public class World
ReadOnlyCollection<Unit> units, ReadOnlyCollection<Unit> units,
ReadOnlyCollection<RetreatingUnit> retreatingUnits, ReadOnlyCollection<RetreatingUnit> retreatingUnits,
ReadOnlyDictionary<Season, OrderHistory> orderHistory, ReadOnlyDictionary<Season, OrderHistory> orderHistory,
ReadOnlyCollection<OrderSet> orderSets,
Options options) Options options)
{ {
this.Provinces = provinces; this.Provinces = provinces;
@ -69,6 +75,7 @@ public class World
this.Units = units; this.Units = units;
this.RetreatingUnits = retreatingUnits; this.RetreatingUnits = retreatingUnits;
this.OrderHistory = orderHistory; this.OrderHistory = orderHistory;
this.OrderSets = orderSets;
this.Options = options; this.Options = options;
} }
@ -83,6 +90,7 @@ public class World
ReadOnlyCollection<Unit>? units = null, ReadOnlyCollection<Unit>? units = null,
ReadOnlyCollection<RetreatingUnit>? retreatingUnits = null, ReadOnlyCollection<RetreatingUnit>? retreatingUnits = null,
ReadOnlyDictionary<Season, OrderHistory>? orderHistory = null, ReadOnlyDictionary<Season, OrderHistory>? orderHistory = null,
ReadOnlyCollection<OrderSet>? orderSets = null,
Options? options = null) Options? options = null)
: this( : this(
provinces ?? previous.Provinces, provinces ?? previous.Provinces,
@ -92,6 +100,7 @@ public class World
units ?? previous.Units, units ?? previous.Units,
retreatingUnits ?? previous.RetreatingUnits, retreatingUnits ?? previous.RetreatingUnits,
orderHistory ?? previous.OrderHistory, orderHistory ?? previous.OrderHistory,
orderSets ?? previous.OrderSets,
options ?? previous.Options) options ?? previous.Options)
{ {
} }
@ -110,6 +119,7 @@ public class World
new(new List<Unit>()), new(new List<Unit>()),
new(new List<RetreatingUnit>()), new(new List<RetreatingUnit>()),
new(new Dictionary<Season, OrderHistory>()), new(new Dictionary<Season, OrderHistory>()),
new(new List<OrderSet>()),
new Options()); new Options());
} }
@ -123,7 +133,8 @@ public class World
IEnumerable<Season>? seasons = null, IEnumerable<Season>? seasons = null,
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,
IEnumerable<OrderSet>? orderSets = null)
=> new World( => new World(
previous: this, previous: this,
seasons: seasons == null seasons: seasons == null
@ -137,7 +148,10 @@ public class World
: new(retreats.ToList()), : new(retreats.ToList()),
orderHistory: orders == null orderHistory: orders == null
? this.OrderHistory ? this.OrderHistory
: new(orders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))); : new(orders.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)),
orderSets: orderSets == null
? this.OrderSets
: new(orderSets.ToList()));
/// <summary> /// <summary>
/// Create a new world with new units created from unit specs. Units specs are in the format /// Create a new world with new units created from unit specs. Units specs are in the format