Еда воинов и раненых по типам (решения 01.11, п. 4): 0,15 / 0,20 / 0,15 / 0,15, раненые -- даже в ожидании койки

IArmy.GetAllTroops; PopulationRules.FoodPerTroopTypePerHour (без таблицы -- как раньше);
EconomyConfig.population.foodPerTroopTypePerHour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexander
2026-11-04 15:13:02 +01:00
co-authored by Claude Opus 5.5
parent fae42716a7
commit cfbdfd9876
11 changed files with 70 additions and 2 deletions
@@ -1949,4 +1949,34 @@ public class ModuleTests
Assert.AreEqual(20, army.GetWoundedWaiting(0) + 10, "ещё 20 легли сразу после улучшения: ждут 10");
Assert.AreEqual(40, army.Healing[0].Count + army.Healing[1].Count);
}
// Решения 01.11, п. 4: воины и раненые едят по норме своего типа, раненые -- даже ожидая койку
[Test]
public void Population_FoodByTroopType_IncludesWounded()
{
var army = new ArmyService(2, new HospitalRules { TemporaryBeds = 0 }); // мест нет -- все раненые ждут
GameServices.Register<IArmy>(army);
GameServices.Register<IEconomy>(new PopulationTests.FakeEconomy());
GameServices.Register<ISettlement>(new PopulationTests.FakeSettlement { TownHallLevel = 1 });
var population = new PopulationService(new PopulationRules { FoodPerTroopTypePerHour = new[] { 0.15, 0.2, 0.15, 0.15 } });
GameServices.Register<IPopulation>(population);
double civilians = population.Civilians * 0.1;
army.AddTroops(0, 20); // пехота 20 x 0,15 = 3
army.AddTroops(1, 10); // лучники 10 x 0,20 = 2
army.AddTroops(3, 4); // осадные 4 x 0,15 = 0,6
Assert.AreEqual(civilians + 5.6, population.FoodPerHour, 0.001);
army.TakeForMarch(1, 14); // в походе -- тоже едят
Assert.AreEqual(civilians + 5.6, population.FoodPerHour, 0.001, "поход не меняет еду");
int[] sent = army.GetMarchUnits(1);
var wounded = new int[4];
for (int t = 0; t < 4; t++) wounded[t] = sent[t] / 2; // половина ранена, остальные погибли
army.ReturnUnits(1, null, wounded, 0);
Assert.AreEqual(0, army.Healing.Count, "коек нет -- раненые ждут");
double expected = 0;
for (int t = 0; t < 4; t++) expected += army.GetAllTroops(t) * new[] { 0.15, 0.2, 0.15, 0.15 }[t];
Assert.AreEqual(civilians + expected, population.FoodPerHour, 0.001, "ждущие койку раненые едят полную норму");
Assert.Less(expected, 5.6, "погибшие больше не едят");
}
}