Compare commits
No commits in common. "601ce2d297168e6bbc7706443c8ab0f1ead558ca" and "9185534f70fb6e91b86183f890ae4726fcaea9a1" have entirely different histories.
601ce2d297
...
9185534f70
|
@ -8,12 +8,12 @@ public class MovementDecisions
|
||||||
public Dictionary<Unit, IsDislodged> IsDislodged { get; }
|
public Dictionary<Unit, IsDislodged> IsDislodged { get; }
|
||||||
public Dictionary<MoveOrder, HasPath> HasPath { get; }
|
public Dictionary<MoveOrder, HasPath> HasPath { get; }
|
||||||
public Dictionary<SupportOrder, GivesSupport> GivesSupport { get; }
|
public Dictionary<SupportOrder, GivesSupport> GivesSupport { get; }
|
||||||
public Dictionary<(Province, string), HoldStrength> HoldStrength { get; }
|
public Dictionary<(Province, Season), HoldStrength> HoldStrength { get; }
|
||||||
public Dictionary<MoveOrder, AttackStrength> AttackStrength { get; }
|
public Dictionary<MoveOrder, AttackStrength> AttackStrength { get; }
|
||||||
public Dictionary<MoveOrder, DefendStrength> DefendStrength { get; }
|
public Dictionary<MoveOrder, DefendStrength> DefendStrength { get; }
|
||||||
public Dictionary<MoveOrder, PreventStrength> PreventStrength { get; }
|
public Dictionary<MoveOrder, PreventStrength> PreventStrength { get; }
|
||||||
public Dictionary<MoveOrder, DoesMove> DoesMove { get; }
|
public Dictionary<MoveOrder, DoesMove> DoesMove { get; }
|
||||||
public Dictionary<string, AdvanceTimeline> AdvanceTimeline { get; }
|
public Dictionary<Season, AdvanceTimeline> AdvanceTimeline { get; }
|
||||||
|
|
||||||
public IEnumerable<AdjudicationDecision> Values =>
|
public IEnumerable<AdjudicationDecision> Values =>
|
||||||
IsDislodged.Values.Cast<AdjudicationDecision>()
|
IsDislodged.Values.Cast<AdjudicationDecision>()
|
||||||
|
@ -47,7 +47,7 @@ public class MovementDecisions
|
||||||
var submittedOrdersBySeason = orders.Cast<UnitOrder>().ToLookup(order => order.Unit.Season);
|
var submittedOrdersBySeason = orders.Cast<UnitOrder>().ToLookup(order => order.Unit.Season);
|
||||||
foreach (var group in submittedOrdersBySeason)
|
foreach (var group in submittedOrdersBySeason)
|
||||||
{
|
{
|
||||||
AdvanceTimeline[group.Key.Designation] = new(group.Key, group);
|
AdvanceTimeline[group.Key] = new(group.Key, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create timeline decisions for each season potentially affected by the submitted orders.
|
// Create timeline decisions for each season potentially affected by the submitted orders.
|
||||||
|
@ -60,27 +60,27 @@ public class MovementDecisions
|
||||||
{
|
{
|
||||||
case MoveOrder move:
|
case MoveOrder move:
|
||||||
AdvanceTimeline.Ensure(
|
AdvanceTimeline.Ensure(
|
||||||
move.Season,
|
world.Seasons[move.Season],
|
||||||
() => new(world.Seasons[move.Season], world.OrderHistory[move.Season].Orders));
|
() => new(world.Seasons[move.Season], world.OrderHistory[move.Season].Orders));
|
||||||
AdvanceTimeline[move.Season].Orders.Add(move);
|
AdvanceTimeline[world.Seasons[move.Season]].Orders.Add(move);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SupportHoldOrder supportHold:
|
case SupportHoldOrder supportHold:
|
||||||
AdvanceTimeline.Ensure(
|
AdvanceTimeline.Ensure(
|
||||||
supportHold.Target.Season.Designation,
|
supportHold.Target.Season,
|
||||||
() => new(supportHold.Target.Season, world.OrderHistory[supportHold.Target.Season.Designation].Orders));
|
() => new(supportHold.Target.Season, world.OrderHistory[supportHold.Target.Season.Designation].Orders));
|
||||||
AdvanceTimeline[supportHold.Target.Season.Designation].Orders.Add(supportHold);
|
AdvanceTimeline[supportHold.Target.Season].Orders.Add(supportHold);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SupportMoveOrder supportMove:
|
case SupportMoveOrder supportMove:
|
||||||
AdvanceTimeline.Ensure(
|
AdvanceTimeline.Ensure(
|
||||||
supportMove.Target.Season.Designation,
|
supportMove.Target.Season,
|
||||||
() => new(supportMove.Target.Season, world.OrderHistory[supportMove.Target.Season.Designation].Orders));
|
() => new(supportMove.Target.Season, world.OrderHistory[supportMove.Target.Season.Designation].Orders));
|
||||||
AdvanceTimeline[supportMove.Target.Season.Designation].Orders.Add(supportMove);
|
AdvanceTimeline[supportMove.Target.Season].Orders.Add(supportMove);
|
||||||
AdvanceTimeline.Ensure(
|
AdvanceTimeline.Ensure(
|
||||||
supportMove.Season.Designation,
|
supportMove.Season,
|
||||||
() => new(supportMove.Season, world.OrderHistory[supportMove.Season.Designation].Orders));
|
() => new(supportMove.Season, world.OrderHistory[supportMove.Season.Designation].Orders));
|
||||||
AdvanceTimeline[supportMove.Season.Designation].Orders.Add(supportMove);
|
AdvanceTimeline[supportMove.Season].Orders.Add(supportMove);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,18 +91,15 @@ public class MovementDecisions
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
(Province province, string season) UnitPoint(Unit unit)
|
(Province province, Season season) UnitPoint(Unit unit)
|
||||||
=> (world.Map.GetLocation(unit.Location).Province, unit.Season.Designation);
|
=> (world.Map.GetLocation(unit.Location).Province, unit.Season);
|
||||||
(Province province, string season) MovePoint(MoveOrder move)
|
(Province province, Season season) MovePoint(MoveOrder move)
|
||||||
=> (move.Province, move.Season);
|
=> (move.Province, world.Seasons[move.Season]);
|
||||||
|
|
||||||
// Create a hold strength decision with an associated order for every province with a unit.
|
// Create a hold strength decision with an associated order for every province with a unit.
|
||||||
foreach (UnitOrder order in relevantOrders)
|
foreach (UnitOrder order in relevantOrders)
|
||||||
{
|
{
|
||||||
HoldStrength[UnitPoint(order.Unit)] = new(
|
HoldStrength[UnitPoint(order.Unit)] = new(UnitPoint(order.Unit), order);
|
||||||
world.Map.GetLocation(order.Unit.Location).Province,
|
|
||||||
order.Unit.Season,
|
|
||||||
order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsIncoming(UnitOrder me, MoveOrder other)
|
bool IsIncoming(UnitOrder me, MoveOrder other)
|
||||||
|
@ -153,7 +150,7 @@ public class MovementDecisions
|
||||||
DoesMove[move] = new(move, opposingMove, competing);
|
DoesMove[move] = new(move, opposingMove, competing);
|
||||||
|
|
||||||
// Ensure a hold strength decision exists for the destination.
|
// Ensure a hold strength decision exists for the destination.
|
||||||
HoldStrength.Ensure(MovePoint(move), () => new(move.Province, world.Seasons[move.Season]));
|
HoldStrength.Ensure(MovePoint(move), () => new(MovePoint(move)));
|
||||||
}
|
}
|
||||||
else if (order is SupportOrder support)
|
else if (order is SupportOrder support)
|
||||||
{
|
{
|
||||||
|
@ -161,9 +158,7 @@ public class MovementDecisions
|
||||||
GivesSupport[support] = new(support, incoming);
|
GivesSupport[support] = new(support, incoming);
|
||||||
|
|
||||||
// Ensure a hold strength decision exists for the target's province.
|
// Ensure a hold strength decision exists for the target's province.
|
||||||
HoldStrength.Ensure(UnitPoint(support.Target), () => new(
|
HoldStrength.Ensure(UnitPoint(support.Target), () => new(UnitPoint(support.Target)));
|
||||||
world.Map.GetLocation(support.Target.Location).Province,
|
|
||||||
support.Target.Season));
|
|
||||||
|
|
||||||
if (support is SupportHoldOrder supportHold)
|
if (support is SupportHoldOrder supportHold)
|
||||||
{
|
{
|
||||||
|
@ -172,9 +167,7 @@ public class MovementDecisions
|
||||||
else if (support is SupportMoveOrder supportMove)
|
else if (support is SupportMoveOrder supportMove)
|
||||||
{
|
{
|
||||||
// Ensure a hold strength decision exists for the target's destination.
|
// Ensure a hold strength decision exists for the target's destination.
|
||||||
HoldStrength.Ensure(
|
HoldStrength.Ensure(supportMove.Point, () => new(supportMove.Point));
|
||||||
(supportMove.Province, supportMove.Season.Designation),
|
|
||||||
() => new(supportMove.Province, supportMove.Season));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -774,7 +774,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
|
||||||
// If there is a head to head battle, a unit at the destination that isn't moving away, or
|
// 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
|
// a unit at the destination that will fail to move away, then the attacking unit will have
|
||||||
// to dislodge it.
|
// to dislodge it.
|
||||||
UnitOrder? destOrder = decisions.HoldStrength[(decision.Order.Province, decision.Order.Season)].Order;
|
UnitOrder? destOrder = decisions.HoldStrength[(decision.Order.Province, world.Seasons[decision.Order.Season])].Order;
|
||||||
DoesMove? destMoveAway = destOrder is MoveOrder moveAway
|
DoesMove? destMoveAway = destOrder is MoveOrder moveAway
|
||||||
? decisions.DoesMove[moveAway]
|
? decisions.DoesMove[moveAway]
|
||||||
: null;
|
: null;
|
||||||
|
@ -953,7 +953,7 @@ public class MovementPhaseAdjudicator : IPhaseAdjudicator
|
||||||
// strength.
|
// strength.
|
||||||
NumericAdjudicationDecision defense = decision.OpposingMove != null
|
NumericAdjudicationDecision defense = decision.OpposingMove != null
|
||||||
? decisions.DefendStrength[decision.OpposingMove]
|
? decisions.DefendStrength[decision.OpposingMove]
|
||||||
: decisions.HoldStrength[(decision.Order.Province, decision.Order.Season)];
|
: decisions.HoldStrength[(decision.Order.Province, world.Seasons[decision.Order.Season])];
|
||||||
progress |= ResolveDecision(defense, world, decisions, depth + 1);
|
progress |= ResolveDecision(defense, world, decisions, depth + 1);
|
||||||
|
|
||||||
// If the attack doesn't beat the defense, resolve the move to false.
|
// If the attack doesn't beat the defense, resolve the move to false.
|
||||||
|
|
Loading…
Reference in New Issue