Enable hold strength across parallel worlds
This commit is contained in:
parent
ff64b459ca
commit
aa9c9c548b
@ -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<SupportHoldOrder> 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class MovementDecisions
|
||||
public Dictionary<Unit, IsDislodged> IsDislodged { get; }
|
||||
public Dictionary<MoveOrder, HasPath> HasPath { get; }
|
||||
public Dictionary<SupportOrder, GivesSupport> GivesSupport { get; }
|
||||
public Dictionary<Province, HoldStrength> HoldStrength { get; }
|
||||
public Dictionary<(Province, Season), HoldStrength> HoldStrength { get; }
|
||||
public Dictionary<MoveOrder, AttackStrength> AttackStrength { get; }
|
||||
public Dictionary<MoveOrder, DefendStrength> DefendStrength { get; }
|
||||
public Dictionary<MoveOrder, PreventStrength> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -30,6 +30,11 @@ public class Unit
|
||||
/// </summary>
|
||||
public UnitType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The unit's spatiotemporal location as a province-season tuple.
|
||||
/// </summary>
|
||||
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;
|
||||
|
@ -17,6 +17,11 @@ public class MoveOrder : UnitOrder
|
||||
/// </summary>
|
||||
public Location Location { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The destination's spatiotemporal location as a province-season tuple.
|
||||
/// </summary>
|
||||
public (Province province, Season season) Point => (this.Location.Province, this.Season);
|
||||
|
||||
public MoveOrder(Power power, Unit unit, Season season, Location location)
|
||||
: base (power, unit)
|
||||
{
|
||||
|
@ -17,6 +17,11 @@ public class SupportMoveOrder : SupportOrder
|
||||
/// </summary>
|
||||
public Location Location { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The target's destination's spatiotemporal location as a province-season tuple.
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user