Армии в пути проходят друг через друга (решения 31.10, п. 3): правило в документе, тест на одну точку в один момент

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexander
2026-11-01 13:09:26 +01:00
co-authored by Claude Opus 5.5
parent 3a86eadc0b
commit 24268f3cfb
2 changed files with 35 additions and 0 deletions
@@ -1599,4 +1599,36 @@ public class ModuleTests
world.Advance(2000, new List<WorldEvent>());
Assert.AreEqual(24, world.ResourcePoints.Count, "повторный расчёт ничего не добавляет");
}
// Решения 31.10, п. 3: армии в пути проходят друг через друга -- без боя, остановки и перехвата,
// даже в одной точке в один момент. Каждая воюет только со своей целью.
[Test]
public void World_ArmiesPassThroughEachOther_NoBattleOnTheWay()
{
long t0 = 1_000_000_000_000;
var world = new WorldSimulation(WorldMapLayout.CreateDefault(), new BattleSystem(BattleRules.NoRandom));
var alone = new WorldSimulation(WorldMapLayout.CreateDefault(), new BattleSystem(BattleRules.NoRandom));
// Две армии разных владельцев выходят из одного места к одной цели в один момент -- всю дорогу в одной точке
MarchData mine = world.StartMarch(LocalPlayer.Id, WorldMapLayout.PlayerCityId, "camp_4", 30, t0, out _);
MarchData theirs = world.StartMarch("npc_1", WorldMapLayout.PlayerCityId, "camp_4", 30, t0, out _);
MarchData solo = alone.StartMarch(LocalPlayer.Id, WorldMapLayout.PlayerCityId, "camp_4", 30, t0, out _);
foreach (var m in new[] { mine, theirs, solo }) { m.units = new[] { 30, 0, 0, 0 }; }
long mid = (t0 + mine.arriveMs) / 2;
Assert.IsTrue(world.TryGetPositionAt(mine, mid, out int x1, out int y1, out _, out _, out int n1));
Assert.IsTrue(world.TryGetPositionAt(theirs, mid, out int x2, out int y2, out _, out _, out int n2));
Assert.AreEqual(x1, x2); Assert.AreEqual(y1, y2); // одна точка, один момент
var events = new List<WorldEvent>();
world.Advance(mid, events);
Assert.AreEqual(0, events.Count, "встреча в пути -- не событие");
Assert.AreEqual(30, n1); Assert.AreEqual(30, n2);
Assert.AreEqual(MarchState.Outbound, mine.state);
Assert.AreEqual(solo.arriveMs, mine.arriveMs, "встреча не задержала и не остановила войско");
world.Advance(mine.arriveMs, events);
alone.Advance(solo.arriveMs, new List<WorldEvent>());
Assert.AreEqual(2, events.Count, "два боя -- каждое войско с целью, а не друг с другом");
Assert.AreEqual(solo.survivors, mine.survivors, "первым дошёл -- бьётся с лагерем так же, как в одиночку");
}
}