Reduce Order.Power to string
This commit is contained in:
parent
161e0a1ddb
commit
2e6e6c55b8
|
@ -77,13 +77,13 @@ internal static class AdjudicatorHelpers
|
|||
{
|
||||
InvalidateIfNotMatching(
|
||||
order => order switch {
|
||||
ConvoyOrder convoy => convoy.Power == convoy.Unit.Power,
|
||||
DisbandOrder disband => disband.Power == disband.Unit.Power,
|
||||
HoldOrder hold => hold.Power == hold.Unit.Power,
|
||||
MoveOrder move => move.Power == move.Unit.Power,
|
||||
RetreatOrder retreat => retreat.Power == retreat.Unit.Power,
|
||||
SupportHoldOrder support => support.Power == support.Unit.Power,
|
||||
SupportMoveOrder support => support.Power == support.Unit.Power,
|
||||
ConvoyOrder convoy => convoy.Power == convoy.Unit.Power.Name,
|
||||
DisbandOrder disband => disband.Power == disband.Unit.Power.Name,
|
||||
HoldOrder hold => hold.Power == hold.Unit.Power.Name,
|
||||
MoveOrder move => move.Power == move.Unit.Power.Name,
|
||||
RetreatOrder retreat => retreat.Power == retreat.Unit.Power.Name,
|
||||
SupportHoldOrder support => support.Power == support.Unit.Power.Name,
|
||||
SupportMoveOrder support => support.Power == support.Unit.Power.Name,
|
||||
// Any order not given to a unit, by definition, cannot be given to a unit of the
|
||||
// wrong power
|
||||
_ => true,
|
||||
|
|
|
@ -262,7 +262,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
|
|||
.Where(unit => !orderedUnits.Contains(unit))
|
||||
.ToList();
|
||||
List<HoldOrder> implicitHolds = unorderedUnits
|
||||
.Select(unit => new HoldOrder(unit.Power, unit))
|
||||
.Select(unit => new HoldOrder(unit.Power.Name, unit))
|
||||
.ToList();
|
||||
validationResults = validationResults
|
||||
.Concat(implicitHolds.Select(o => o.Validate(ValidationReason.Valid)))
|
||||
|
|
|
@ -17,7 +17,7 @@ public class BuildOrder : Order
|
|||
/// </summary>
|
||||
public UnitType Type { get; }
|
||||
|
||||
public BuildOrder(Power power, Location location, UnitType type)
|
||||
public BuildOrder(string power, Location location, UnitType type)
|
||||
: base (power)
|
||||
{
|
||||
this.Location = location;
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ConvoyOrder : UnitOrder
|
|||
/// </summary>
|
||||
public Province Province => this.Location.Province;
|
||||
|
||||
public ConvoyOrder(Power power, Unit unit, Unit target, Season season, Location location)
|
||||
public ConvoyOrder(string power, Unit unit, Unit target, Season season, Location location)
|
||||
: base (power, unit)
|
||||
{
|
||||
this.Target = target;
|
||||
|
|
|
@ -7,6 +7,6 @@ namespace MultiversalDiplomacy.Orders;
|
|||
/// </summary>
|
||||
public class DisbandOrder : UnitOrder
|
||||
{
|
||||
public DisbandOrder(Power power, Unit unit)
|
||||
public DisbandOrder(string power, Unit unit)
|
||||
: base (power, unit) {}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MultiversalDiplomacy.Orders;
|
|||
/// </summary>
|
||||
public class HoldOrder : UnitOrder
|
||||
{
|
||||
public HoldOrder(Power power, Unit unit)
|
||||
public HoldOrder(string power, Unit unit)
|
||||
: base (power, unit) {}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -23,7 +23,7 @@ public class MoveOrder : UnitOrder
|
|||
/// </summary>
|
||||
public Province Province => this.Location.Province;
|
||||
|
||||
public MoveOrder(Power power, Unit unit, string season, Location location)
|
||||
public MoveOrder(string power, Unit unit, string season, Location location)
|
||||
: base (power, unit)
|
||||
{
|
||||
this.Season = season;
|
||||
|
|
|
@ -22,9 +22,9 @@ public abstract class Order
|
|||
/// <summary>
|
||||
/// The power that submitted this order.
|
||||
/// </summary>
|
||||
public Power Power { get; }
|
||||
public string Power { get; }
|
||||
|
||||
public Order(Power power)
|
||||
public Order(string power)
|
||||
{
|
||||
this.Power = power;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class RetreatOrder : UnitOrder
|
|||
/// </summary>
|
||||
public Location Location { get; }
|
||||
|
||||
public RetreatOrder(Power power, Unit unit, Location location)
|
||||
public RetreatOrder(string power, Unit unit, Location location)
|
||||
: base (power, unit)
|
||||
{
|
||||
this.Location = location;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MultiversalDiplomacy.Orders;
|
|||
/// </summary>
|
||||
public class SupportHoldOrder : SupportOrder
|
||||
{
|
||||
public SupportHoldOrder(Power power, Unit unit, Unit target)
|
||||
public SupportHoldOrder(string power, Unit unit, Unit target)
|
||||
: base (power, unit, target)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SupportMoveOrder : SupportOrder
|
|||
/// </summary>
|
||||
public (Province province, Season season) Point => (this.Province, this.Season);
|
||||
|
||||
public SupportMoveOrder(Power power, Unit unit, Unit target, Season season, Location location)
|
||||
public SupportMoveOrder(string power, Unit unit, Unit target, Season season, Location location)
|
||||
: base(power, unit, target)
|
||||
{
|
||||
this.Season = season;
|
||||
|
|
|
@ -12,7 +12,7 @@ public abstract class SupportOrder : UnitOrder
|
|||
/// </summary>
|
||||
public Unit Target { get; }
|
||||
|
||||
public SupportOrder(Power power, Unit unit, Unit target)
|
||||
public SupportOrder(string power, Unit unit, Unit target)
|
||||
: base (power, unit)
|
||||
{
|
||||
this.Target = target;
|
||||
|
|
|
@ -17,7 +17,7 @@ public class SustainOrder : Order
|
|||
/// </summary>
|
||||
public int Timeline { get; }
|
||||
|
||||
public SustainOrder(Power power, Location timeCenter, int timeline)
|
||||
public SustainOrder(string power, Location timeCenter, int timeline)
|
||||
: base (power)
|
||||
{
|
||||
this.TimeCenter = timeCenter;
|
||||
|
|
|
@ -22,7 +22,7 @@ public abstract class UnitOrder : Order
|
|||
/// </summary>
|
||||
public Unit Unit { get; }
|
||||
|
||||
public UnitOrder(Power power, Unit unit) : base(power)
|
||||
public UnitOrder(string power, Unit unit) : base(power)
|
||||
{
|
||||
this.Unit = unit;
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ public class TestCaseBuilder
|
|||
|
||||
public IOrderDefinedContext<HoldOrder> Holds()
|
||||
{
|
||||
HoldOrder order = new HoldOrder(this.PowerContext.Power, this.Unit);
|
||||
HoldOrder order = new HoldOrder(this.PowerContext.Power.Name, this.Unit);
|
||||
this.Builder.OrderList.Add(order);
|
||||
return new OrderDefinedContext<HoldOrder>(this, order);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ public class TestCaseBuilder
|
|||
: this.Builder.World.Map.GetWater(provinceName, coast);
|
||||
Season destSeason = season ?? this.SeasonContext.Season;
|
||||
MoveOrder moveOrder = new MoveOrder(
|
||||
this.PowerContext.Power,
|
||||
this.PowerContext.Power.Name,
|
||||
this.Unit,
|
||||
destSeason.Key,
|
||||
destination);
|
||||
|
@ -494,7 +494,7 @@ public class TestCaseBuilder
|
|||
{
|
||||
Location location = this.Builder.World.Map.GetLand(provinceName);
|
||||
ConvoyOrder order = new ConvoyOrder(
|
||||
this.PowerContext.Power,
|
||||
this.PowerContext.Power.Name,
|
||||
this.UnitContext.Unit,
|
||||
this.Target,
|
||||
this.SeasonContext.Season,
|
||||
|
@ -569,7 +569,7 @@ public class TestCaseBuilder
|
|||
public IOrderDefinedContext<SupportHoldOrder> Hold()
|
||||
{
|
||||
SupportHoldOrder order = new SupportHoldOrder(
|
||||
this.PowerContext.Power,
|
||||
this.PowerContext.Power.Name,
|
||||
this.UnitContext.Unit,
|
||||
this.Target);
|
||||
this.Builder.OrderList.Add(order);
|
||||
|
@ -586,7 +586,7 @@ public class TestCaseBuilder
|
|||
: this.Builder.World.Map.GetWater(provinceName, coast);
|
||||
Season targetDestSeason = season ?? this.Target.Season;
|
||||
SupportMoveOrder order = new SupportMoveOrder(
|
||||
this.PowerContext.Power,
|
||||
this.PowerContext.Power.Name,
|
||||
this.UnitContext.Unit,
|
||||
this.Target,
|
||||
targetDestSeason,
|
||||
|
|
|
@ -124,7 +124,7 @@ class TestCaseBuilderTest
|
|||
Assert.That(orderMun, Is.Not.Null, "Expected order reference");
|
||||
Assert.That(
|
||||
orderMun.Order.Power,
|
||||
Is.EqualTo(setup.World.Map.GetPower("Germany")),
|
||||
Is.EqualTo("Germany"),
|
||||
"Wrong power");
|
||||
Assert.That(
|
||||
orderMun.Order.Unit.Location,
|
||||
|
|
Loading…
Reference in New Issue