A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
City panel: count every soldier housed in the city (Fixes #1345) (#1490)
Bericb4db508aebe
diff --git a/changelog.d/1345.md b/changelog.d/1345.mdnew file mode 100644index 000000000..2ddc44b44--- /dev/null+++ b/changelog.d/1345.md@@ -0,0 +1,4 @@+### Fixed++- The city panel's Recruits line, stuck at 0 since trained recruits became formations, now reads "Soldiers+ housed" and counts every Israeli formation the city houses: recruits, veterans, guns and armoured cars (#1345).diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex bec25ff49..e422be535 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -132,6 +132,14 @@ namespace Statecraft.Sim{var n = x.Civilians + x.Craftsmen + x.Recruits;foreach (var k in s.Cohorts.Values) if (k.City == x.Id) n += k.Count;+ return n + Soldiers(s, x);+ }++ /// <summary>R-HOUSE-003, R-UNIT-004 (Q-HOUSE-5): the Israeli formations the city houses, their strength summed:+ /// recruits, veterans, guns and armoured cars whose home it is, wherever they stand (#1345, the panel's soldiers line).</summary>+ public static int Soldiers(GameState s, City x)+ {+ var n = 0;foreach (var u in s.Units.Values) if (u.Side == "israel" && u.HomeCity == x.Id) n += u.Strength;return n;}diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csindex 182ead5c6..604a94a2c 100644--- a/unity/Assets/Scripts/UI/GddHexPanel.cs+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -95,7 +95,9 @@ namespace Statecraft.Game.UIvar waiting = Row(host, "city-waiting-row"); waiting.AddToClassList(PairsClass);Line(waiting, "city-refugees", text.Format("city.refugees", Groups(text, city.Refugees)));Line(waiting, "city-overflow", text.Format("city.overflow", Cities.Overflow(s, city)));- Line(host, "city-recruits", text.Format("city.recruits", Groups(text, city.Recruits)));+ // #1345: trained recruits are formations housed in their home city since #1130, so the line counts every Israeli+ // formation the city houses (Cities.Soldiers, part of Cities.Housed), not City.Recruits, which nothing writes now.+ Line(host, "city-soldiers", text.Format("city.soldiers", Groups(text, Cities.Soldiers(s, city))));// The Assign stepper: the ordered count (or the current one), one group a press, within R-CITY-001's limits as// the sim gives them with this turn's Train orders; stepping back to the current count withdraws the order.diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.csindex f66754a60..89deb1f26 100644--- a/unity/Assets/Tests/EditMode/CityPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs@@ -70,7 +70,7 @@ public class CityPanelTestsAssert.AreEqual(En.Format("city.jobs", city.Employed, city.JobSlots), ui.Q<Label>("city-jobs").text);Assert.AreEqual(En.Format("city.craftsmen", 3), ui.Q<Label>("city-craftsmen").text);Assert.AreEqual(En.Format("city.refugees", En.Format("city.groups", city.Refugees)), ui.Q<Label>("city-refugees").text);- Assert.AreEqual(En.Format("city.recruits", En.Format("city.groups", city.Recruits)), ui.Q<Label>("city-recruits").text);+ Assert.AreEqual(En.Format("city.soldiers", En.Format("city.groups", 0)), ui.Q<Label>("city-soldiers").text);Assert.AreEqual(En.Format("city.workers", En.Format("city.groups", city.Employed)), ui.Q<Label>("city-workers").text);}@@ -93,6 +93,35 @@ public class CityPanelTestsAssert.AreEqual(En.Format("city.housing_condition", 15, En.Format("city.groups", city.HousingCapacity), PlayerText.Percent(city.Condition!.Value)), ui.Q<Label>("city-housing").text);}+ [Test]+ public void TheSoldiersLineCountsEveryIsraeliFormationHousedInTheCity([Values] bool hebrew)+ {+ // #1345 (owner ruling, 23 Oct 2026, option b): since #1130 trained recruits are formations housed in their home city+ // (R-HOUSE-003, R-UNIT-004), so the line counts every Israeli formation whose HomeCity is the city, the same sum+ // Cities.Housed takes: a recruit group, a promoted veteran, guns and armoured cars, wherever they stand. A formation+ // homed elsewhere and an Arab unit are not the city's.+ var t = hebrew ? He : En;+ using var ui = new UiTestKit();+ var bridge = Bridge(t, s =>+ {+ void Add(string type, string side, int strength, string home)+ {+ var id = s.NextId++;+ s.Units.Add(id, new Unit(id, type, CityHex.q, CityHex.r, 0, side, strength, "", "", home));+ }+ Add("recruit", "israel", 2, City);+ Add("veteran_soldier", "israel", 3, City);+ Add("artillery", "israel", 1, City);+ Add("armoured_car", "israel", 1, City);+ Add("recruit", "israel", 4, "jerusalem");+ Add("egyptian_army", "egypt", 5, City);+ });+ using var panel = Panel(ui, bridge, t);+ panel.Show(CityHex.q, CityHex.r);+ Assert.AreEqual(0, bridge.State.Cities[City].Recruits, "precondition: nothing writes City.Recruits since #1130");+ Assert.AreEqual(t.Format("city.soldiers", t.Format("city.groups", 7)), ui.Q<Label>("city-soldiers").text);+ }+[Test]public void TheCityHexShowsItsHousingConditionFromTheSim(){diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex d219f4c0c..94ec533a5 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -501,7 +501,7 @@ city.overflow: "Overflow: {0}"city.jobs: "Jobs: {0} of {1} filled"city.craftsmen: "Craftsmen: {0}"city.refugees: "Refugees waiting: {0}"-city.recruits: "Recruits: {0}"+city.soldiers: "Soldiers housed: {0}"city.workers: "In work: {0}"city.train_recruit: "Train recruits: 1 group, {0}, {1}"city.train_halutz: "Train halutzim: 1 group, {0}, {1}"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 536baaa1f..98194b6c0 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -538,7 +538,9 @@ city.jobs: "משרות: {0} מתוך {1} מאוישות"# native reviewer (#564).city.craftsmen: "בעלי מלאכה: {0}"city.refugees: "פליטים ממתינים: {0}"-city.recruits: "מגויסים: {0}"+# #1345: every Israeli formation the city houses.+# Approved by Beri, a native speaker, on #1345 (23 Oct 2026).+city.soldiers: "חיילים בעיר: {0}"city.workers: "בעבודה: {0}"city.train_recruit: "אימון מגויסים: קבוצה אחת, {0}, {1}"city.train_halutz: "הכשרת חלוצים: קבוצה אחת, {0}, {1}"