From be3f6a527fb74d929aa62b48d5c1085d0813eaf0 Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Tue, 22 Mar 2022 12:57:01 -0700 Subject: [PATCH] Refactor Support*Order to inherit from abstract SupportOrder --- .../Orders/SupportHoldOrder.cs | 10 ++-------- .../Orders/SupportMoveOrder.cs | 10 ++-------- MultiversalDiplomacy/Orders/SupportOrder.cs | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 MultiversalDiplomacy/Orders/SupportOrder.cs diff --git a/MultiversalDiplomacy/Orders/SupportHoldOrder.cs b/MultiversalDiplomacy/Orders/SupportHoldOrder.cs index 97ddbb9..eb8a3a4 100644 --- a/MultiversalDiplomacy/Orders/SupportHoldOrder.cs +++ b/MultiversalDiplomacy/Orders/SupportHoldOrder.cs @@ -5,16 +5,10 @@ namespace MultiversalDiplomacy.Orders; /// /// An order for a unit to support another unit's hold order. /// -public class SupportHoldOrder : UnitOrder +public class SupportHoldOrder : SupportOrder { - /// - /// The unit to support. - /// - public Unit Target { get; } - public SupportHoldOrder(Power power, Unit unit, Unit target) - : base (power, unit) + : base (power, unit, target) { - this.Target = target; } } \ No newline at end of file diff --git a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs index 45fae77..3f98917 100644 --- a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs +++ b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs @@ -5,13 +5,8 @@ namespace MultiversalDiplomacy.Orders; /// /// An order for a unit to support another unit's move order. /// -public class SupportMoveOrder : UnitOrder +public class SupportMoveOrder : SupportOrder { - /// - /// The unit to support. - /// - public Unit Target { get; } - /// /// The destination season to which the target is moving. /// @@ -23,9 +18,8 @@ public class SupportMoveOrder : UnitOrder public Location Location { get; } public SupportMoveOrder(Power power, Unit unit, Unit target, Season season, Location location) - : base (power, unit) + : base(power, unit, target) { - this.Target = target; this.Season = season; this.Location = location; } diff --git a/MultiversalDiplomacy/Orders/SupportOrder.cs b/MultiversalDiplomacy/Orders/SupportOrder.cs new file mode 100644 index 0000000..db80b67 --- /dev/null +++ b/MultiversalDiplomacy/Orders/SupportOrder.cs @@ -0,0 +1,20 @@ +using MultiversalDiplomacy.Model; + +namespace MultiversalDiplomacy.Orders; + +/// +/// An order for a unit to support another unit. +/// +public abstract class SupportOrder : UnitOrder +{ + /// + /// The unit to support. + /// + public Unit Target { get; } + + public SupportOrder(Power power, Unit unit, Unit target) + : base (power, unit) + { + this.Target = target; + } +} \ No newline at end of file