diff --git a/MultiversalDiplomacy/Adjudicate/Decision/HoldStrength.cs b/MultiversalDiplomacy/Adjudicate/Decision/HoldStrength.cs index 35d1d46..39c0628 100644 --- a/MultiversalDiplomacy/Adjudicate/Decision/HoldStrength.cs +++ b/MultiversalDiplomacy/Adjudicate/Decision/HoldStrength.cs @@ -6,13 +6,20 @@ namespace MultiversalDiplomacy.Adjudicate.Decision; public class HoldStrength : NumericAdjudicationDecision { public Province Province { get; } + public Season Season { get; } public UnitOrder? Order { get; } public List Supports { get; } - public HoldStrength(Province province, UnitOrder? order = null) + public HoldStrength(Province province, Season season, UnitOrder? order = null) { this.Province = province; + this.Season = season; this.Order = order; this.Supports = new(); } + + public HoldStrength((Province province, Season season) point, UnitOrder? order = null) + : this(point.province, point.season, order) + { + } } diff --git a/MultiversalDiplomacy/Adjudicate/Decision/MovementDecisions.cs b/MultiversalDiplomacy/Adjudicate/Decision/MovementDecisions.cs index ba85108..c8d8e39 100644 --- a/MultiversalDiplomacy/Adjudicate/Decision/MovementDecisions.cs +++ b/MultiversalDiplomacy/Adjudicate/Decision/MovementDecisions.cs @@ -8,7 +8,7 @@ public class MovementDecisions public Dictionary IsDislodged { get; } public Dictionary HasPath { get; } public Dictionary GivesSupport { get; } - public Dictionary HoldStrength { get; } + public Dictionary<(Province, Season), HoldStrength> HoldStrength { get; } public Dictionary AttackStrength { get; } public Dictionary DefendStrength { get; } public Dictionary PreventStrength { get; } @@ -46,8 +46,7 @@ public class MovementDecisions // Ensure a hold strength decision exists. Overwrite any previous once, since it may // have been created without an order by a previous move or support. - Province province = order.Unit.Location.Province; - this.HoldStrength[province] = new(province, order); + this.HoldStrength[order.Unit.Point] = new(order.Unit.Point, order); if (order is MoveOrder move) { @@ -78,10 +77,9 @@ public class MovementDecisions this.DoesMove[move] = new(move, opposingMove, competing); // Ensure a hold strength decision exists for the destination. - Province dest = move.Location.Province; - if (!this.HoldStrength.ContainsKey(dest)) + if (!this.HoldStrength.ContainsKey(move.Point)) { - this.HoldStrength[dest] = new(dest); + this.HoldStrength[move.Point] = new(move.Point); } } else if (order is SupportOrder support) @@ -90,23 +88,21 @@ public class MovementDecisions this.GivesSupport[support] = new(support, incoming); // Ensure a hold strength decision exists for the target's province. - Province target = support.Target.Location.Province; - if (!this.HoldStrength.ContainsKey(target)) + if (!this.HoldStrength.ContainsKey(support.Target.Point)) { - this.HoldStrength[target] = new(target); + this.HoldStrength[support.Target.Point] = new(support.Target.Point); } if (support is SupportHoldOrder supportHold) { - this.HoldStrength[target].Supports.Add(supportHold); + this.HoldStrength[support.Target.Point].Supports.Add(supportHold); } else if (support is SupportMoveOrder supportMove) { // Ensure a hold strength decision exists for the target's destination. - Province dest = supportMove.Location.Province; - if (!this.HoldStrength.ContainsKey(dest)) + if (!this.HoldStrength.ContainsKey(supportMove.Point)) { - this.HoldStrength[dest] = new(dest); + this.HoldStrength[supportMove.Point] = new(supportMove.Point); } } } diff --git a/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs b/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs index 5d9c115..837d035 100644 --- a/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs +++ b/MultiversalDiplomacy/Adjudicate/MovementPhaseAdjudicator.cs @@ -584,7 +584,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator // If there is a head to head battle, a unit at the destination that isn't moving away, or // a unit at the destination that will fail to move away, then the attacking unit will have // to dislodge it. - UnitOrder? destOrder = decisions.HoldStrength[decision.Order.Location.Province].Order; + UnitOrder? destOrder = decisions.HoldStrength[decision.Order.Point].Order; DoesMove? destMoveAway = destOrder is MoveOrder moveAway ? decisions.DoesMove[moveAway] : null; @@ -757,7 +757,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator // strength. NumericAdjudicationDecision defense = decision.OpposingMove != null ? decisions.DefendStrength[decision.OpposingMove] - : decisions.HoldStrength[decision.Order.Location.Province]; + : decisions.HoldStrength[decision.Order.Point]; progress |= ResolveDecision(defense, world, decisions); // If the attack doesn't beat the defense, resolve the move to false. diff --git a/MultiversalDiplomacy/Model/Unit.cs b/MultiversalDiplomacy/Model/Unit.cs index 3a59560..74bde97 100644 --- a/MultiversalDiplomacy/Model/Unit.cs +++ b/MultiversalDiplomacy/Model/Unit.cs @@ -30,6 +30,11 @@ public class Unit /// public UnitType Type { get; } + /// + /// The unit's spatiotemporal location as a province-season tuple. + /// + public (Province province, Season season) Point => (this.Location.Province, this.Season); + private Unit(Unit? past, Location location, Season season, Power power, UnitType type) { this.Past = past; diff --git a/MultiversalDiplomacy/Orders/MoveOrder.cs b/MultiversalDiplomacy/Orders/MoveOrder.cs index 77a867b..3aa890b 100644 --- a/MultiversalDiplomacy/Orders/MoveOrder.cs +++ b/MultiversalDiplomacy/Orders/MoveOrder.cs @@ -17,6 +17,11 @@ public class MoveOrder : UnitOrder /// public Location Location { get; } + /// + /// The destination's spatiotemporal location as a province-season tuple. + /// + public (Province province, Season season) Point => (this.Location.Province, this.Season); + public MoveOrder(Power power, Unit unit, Season season, Location location) : base (power, unit) { diff --git a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs index 8f91167..df72eb8 100644 --- a/MultiversalDiplomacy/Orders/SupportMoveOrder.cs +++ b/MultiversalDiplomacy/Orders/SupportMoveOrder.cs @@ -17,6 +17,11 @@ public class SupportMoveOrder : SupportOrder /// public Location Location { get; } + /// + /// The target's destination's spatiotemporal location as a province-season tuple. + /// + public (Province province, Season season) Point => (this.Location.Province, this.Season); + public SupportMoveOrder(Power power, Unit unit, Unit target, Season season, Location location) : base(power, unit, target) {