From 771d390409cdd72d0b08e0144bf1ca1bba65a704 Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Thu, 29 Dec 2022 10:21:37 -0800 Subject: [PATCH] Add OrderSet model --- MultiversalDiplomacy/Model/OrderSet.cs | 28 ++++++++++++++++++++++++++ MultiversalDiplomacy/Model/World.cs | 18 +++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 MultiversalDiplomacy/Model/OrderSet.cs diff --git a/MultiversalDiplomacy/Model/OrderSet.cs b/MultiversalDiplomacy/Model/OrderSet.cs new file mode 100644 index 0000000..961caa9 --- /dev/null +++ b/MultiversalDiplomacy/Model/OrderSet.cs @@ -0,0 +1,28 @@ +namespace MultiversalDiplomacy.Model; + +/// +/// A list of unit orders submitted by a power. +/// +public class OrderSet +{ + /// + /// The raw text of the submitted orders, including the name of the submitting power. + /// + public string Text { get; } + + /// + /// Whether the order set has already been adjudicated. + /// + public bool Adjudicated { get; } + + /// + /// UTC timestamp at which the order set was submitted + /// + public DateTime SubmittedAt { get; } + + public OrderSet(string text) + { + Text = text; + SubmittedAt = DateTime.UtcNow; + } +} \ No newline at end of file diff --git a/MultiversalDiplomacy/Model/World.cs b/MultiversalDiplomacy/Model/World.cs index 799933e..0d683b2 100644 --- a/MultiversalDiplomacy/Model/World.cs +++ b/MultiversalDiplomacy/Model/World.cs @@ -44,6 +44,11 @@ public class World /// public ReadOnlyDictionary OrderHistory { get; } + /// + /// Submitted order sets. + /// + public ReadOnlyCollection OrderSets { get; } + /// /// Immutable game options. /// @@ -60,6 +65,7 @@ public class World ReadOnlyCollection units, ReadOnlyCollection retreatingUnits, ReadOnlyDictionary orderHistory, + ReadOnlyCollection orderSets, Options options) { this.Provinces = provinces; @@ -69,6 +75,7 @@ public class World this.Units = units; this.RetreatingUnits = retreatingUnits; this.OrderHistory = orderHistory; + this.OrderSets = orderSets; this.Options = options; } @@ -83,6 +90,7 @@ public class World ReadOnlyCollection? units = null, ReadOnlyCollection? retreatingUnits = null, ReadOnlyDictionary? orderHistory = null, + ReadOnlyCollection? orderSets = null, Options? options = null) : this( provinces ?? previous.Provinces, @@ -92,6 +100,7 @@ public class World units ?? previous.Units, retreatingUnits ?? previous.RetreatingUnits, orderHistory ?? previous.OrderHistory, + orderSets ?? previous.OrderSets, options ?? previous.Options) { } @@ -110,6 +119,7 @@ public class World new(new List()), new(new List()), new(new Dictionary()), + new(new List()), new Options()); } @@ -123,7 +133,8 @@ public class World IEnumerable? seasons = null, IEnumerable? units = null, IEnumerable? retreats = null, - IEnumerable>? orders = null) + IEnumerable>? orders = null, + IEnumerable? orderSets = null) => new World( previous: this, seasons: seasons == null @@ -137,7 +148,10 @@ public class World : new(retreats.ToList()), orderHistory: orders == null ? 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())); /// /// Create a new world with new units created from unit specs. Units specs are in the format