diff --git a/server/Adjudication/Execution/Executor.cs b/server/Adjudication/Execution/Executor.cs index b8ab456..85c13e8 100644 --- a/server/Adjudication/Execution/Executor.cs +++ b/server/Adjudication/Execution/Executor.cs @@ -10,7 +10,7 @@ public class Executor(World world, List regions) private readonly List originalRetreatingUnits = world.Boards.SelectMany(b => b.Units).Where(u => u!.MustRetreat).ToList(); private readonly List regions = regions; - private readonly MapComparer mapComparer = new(); + private readonly MapComparer mapComparer = new(world.Orders.OfType().ToList()); public void ExecuteOrders() { diff --git a/server/Adjudication/Execution/MapComparer.cs b/server/Adjudication/Execution/MapComparer.cs index ef79d09..ad32ded 100644 --- a/server/Adjudication/Execution/MapComparer.cs +++ b/server/Adjudication/Execution/MapComparer.cs @@ -2,11 +2,13 @@ namespace Adjudication; -public class MapComparer : EqualityComparer +public class MapComparer(List builds) : EqualityComparer { private readonly CentreComparer centreComparer = new(); private readonly UnitComparer unitComparer = new(); + private readonly List builds = builds; + public override bool Equals(Board? x, Board? y) { if (x == null || y == null) @@ -24,10 +26,10 @@ public override bool Equals(Board? x, Board? y) return false; } - var hasMatchingUnits = x.Units - .OrderBy(u => u.Location.RegionId) - .SequenceEqual(y.Units.OrderBy(u => u.Location.RegionId), - unitComparer); + var xUnits = x.Units.Where(u => !builds.Any(b => b.Unit == u)).OrderBy(u => u.Location.RegionId); + var yUnits = y.Units.Where(u => !builds.Any(b => b.Unit == u)).OrderBy(u => u.Location.RegionId); + + var hasMatchingUnits = xUnits.SequenceEqual(yUnits, unitComparer); return hasMatchingUnits; }