A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Name English counts of one in the singular (#2541)
agamrafaeli-instinctee3f767180cd
diff --git a/changelog.d/2530-singular-forms.md b/changelog.d/2530-singular-forms.mdnew file mode 100644index 000000000..6e77b0c82--- /dev/null+++ b/changelog.d/2530-singular-forms.md@@ -0,0 +1,3 @@+### Fixed+- English counts of one name the singular: "1 unit of Food", "1 turn of occupation left", "1 group", "1 civilian",+ "1 week" (#2530).diff --git a/sim/Statecraft.Sim.Tests/ArrivalsTests.cs b/sim/Statecraft.Sim.Tests/ArrivalsTests.csindex 0b7a6c68c..b9dae233f 100644--- a/sim/Statecraft.Sim.Tests/ArrivalsTests.cs+++ b/sim/Statecraft.Sim.Tests/ArrivalsTests.cs@@ -64,6 +64,22 @@ public class ArrivalsTestsAssert.Equal(new[] { 6, 6, 11 }, added); // the fixture's 230 people are 23 units: quotas 5.75, 5.75, 11.5}+ // R-CITY-003, #2530: a count of 1 names the singular.+ [Fact]+ public void ASingleArrivingGroupNamesTheSingular()+ {+ var c = Three();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ var r = c.RulesAt(s.Date).Mvp!;+ var next = s.Date;+ while (Cities.ArrivedUnits(c, s.Date, next, r.PeoplePerUnit) < 1) next = next.AddDays(1);+ var why = new List<Cause>();+ Cities.Arrive(c, s, r, next, why);+ var line = Assert.Single(why, w => w.Key == CauseKeys.ImmigrantsWaiting);+ Assert.Equal(1.0, line.Delta);+ Assert.Equal("Town C: 1 group of immigrants arrived and wait for homes", line.Message);+ }+// R-CITY-003: the split is a function of the cities' cumulative units alone, so a city never gives a unit back, as a fresh// largest-remainder split of each total would (the Alabama paradox: at 7 units Petah Tikva would lose one).[Fact]diff --git a/sim/Statecraft.Sim.Tests/CitiesTests.cs b/sim/Statecraft.Sim.Tests/CitiesTests.csindex 70f7b5754..02c98b9e9 100644--- a/sim/Statecraft.Sim.Tests/CitiesTests.cs+++ b/sim/Statecraft.Sim.Tests/CitiesTests.cs@@ -40,6 +40,17 @@ public class CitiesTestsAssert.False(r.State.Cities["tel_aviv"].JobsDefault); // R-CITY-009: the order fixes the number}+ // R-CITY-001, #2530: a count of 1 names the singular.+ [Fact]+ public void ASingleGroupInWorkNamesTheSingular()+ {+ var c = Town();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ var r = Step(c, s, new AssignWorkers("town_a", "job", 1));+ Assert.Empty(r.Rejected);+ Assert.Contains(r.Why, x => x.System == "city" && x.Message == "Town A: 1 group in work");+ }+// R-CITY-001[Theory][InlineData("town_a", "job", -1, "The number of workers cannot be negative")]diff --git a/sim/Statecraft.Sim.Tests/FieldsTests.cs b/sim/Statecraft.Sim.Tests/FieldsTests.csindex b3b924a25..9110adbb0 100644--- a/sim/Statecraft.Sim.Tests/FieldsTests.cs+++ b/sim/Statecraft.Sim.Tests/FieldsTests.cs@@ -62,6 +62,22 @@ public class FieldsTestsAssert.Contains(b.Why, w => w.System == "economy" && w.Target == "food" && w.Delta == 7 && w.Message == "Site A fields: the plowed land yielded 7 units of Food");}+ // R-FIELD-002, #2530: a count of 1 names the singular.+ [Fact]+ public void ASingleUnitOfFoodNamesTheSingular()+ {+ var c = ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>+ {+ ["sites.yaml"] = Fixture.GddSites + FieldSite("[field]"),+ ["rules.yaml"] = Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts)+ + Fixture.GddRules.Replace("field_food_per_turn: 7", "field_food_per_turn: 1"),+ })));+ var s = NoImports(c);+ s.Sites["site_a_field"] = SiteWork.Built("site_a_field", new DateTime(1948, 5, 15));+ var r = Step(c, s);+ Assert.Contains(r.Why, w => w.System == "economy" && w.Target == "food" && w.Delta == 1 && w.Message == "Site A fields: the plowed land yielded 1 unit of Food");+ }+// R-FIELD-002, D-A6: the field's Food reaches the stock before the nation eats (step 7), so it covers part of the need. Added// after eating, the same turn would leave all 100 units unmet and 7 in the stock. Production (step 6's jobs income) moves// only the Treasury, so the order against it shows only in the order of the causes.diff --git a/sim/Statecraft.Sim.Tests/HousingTests.cs b/sim/Statecraft.Sim.Tests/HousingTests.csindex 52fd051e2..8e1aa76ef 100644--- a/sim/Statecraft.Sim.Tests/HousingTests.cs+++ b/sim/Statecraft.Sim.Tests/HousingTests.cs@@ -83,6 +83,16 @@ public class HousingTestsAssert.Contains(r.Why, w => w.System == "city" && w.Target == "town_a" && w.Message == "Town A: 3 groups more than its homes hold");}+ // R-HOUSE-002, #2530: a count of 1 names the singular.+ [Fact]+ public void ASingleGroupOfOverflowNamesTheSingular()+ {+ var c = Town();+ var s = With(Simulation.NewGame(c, 1, Mode.Historical), "town_a", 10, 6, 3); // 13 people, housing for 12+ var r = Simulation.Step(c, s, Array.Empty<Command>());+ Assert.Contains(r.Why, w => w.System == "city" && w.Target == "town_a" && w.Message == "Town A: 1 group more than its homes hold");+ }+// R-HOUSE-002[Fact]public void ConditionNeverFallsBelowZero()diff --git a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs b/sim/Statecraft.Sim.Tests/MinistersGddTests.csindex 2c27db78f..22bd4b26b 100644--- a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs+++ b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs@@ -164,6 +164,19 @@ offices:Assert.Contains(res.Why, w => w.System == "city" && w.Message == "Town A: 3 groups of immigrants housed");}+ // R-MIN-002, #2530: a count of 1 names the singular.+ [Fact]+ public void ASingleGroupHousedNamesTheSingular()+ {+ var c = Town(budget: "immigration_minister");+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ var x = s.Cities["town_a"];+ s.Cities["town_a"] = x.WithCounts(x.Civilians, x.Employed, 2); // floor(2 x 0.75) houses 1+ var r = Step(c, s);+ Assert.Contains(r.Why, w => w.System == "city" && w.Message == "Town A: 1 group of immigrants housed");+ Assert.Equal(1, r.State.Cities["town_a"].Refugees);+ }+// R-MIN-003[Fact]public void AVacantOrEndedOfficeIsAsStated()diff --git a/sim/Statecraft.Sim.Tests/OccupyTests.cs b/sim/Statecraft.Sim.Tests/OccupyTests.csindex b127b7636..2c84cf21a 100644--- a/sim/Statecraft.Sim.Tests/OccupyTests.cs+++ b/sim/Statecraft.Sim.Tests/OccupyTests.cs@@ -136,6 +136,17 @@ public class OccupyTestsAssert.Equal((SettlementControl.Occupied, 1), (ctrl.State, ctrl.Turns));}+ // R-CTRL-012, #2530: a count of 1 names the singular.+ [Fact]+ public void TheOccupationCountdownNamesASingleTurn()+ {+ var c = Load();+ var s = Awaiting(c, Soldier(1, 1, 0), Soldier(2, 4, 0));+ s = Step(c, s, Occupy()).State; // the timer starts at 2: this turn's step 10 already counts one off+ var next = Step(c, s);+ Assert.Contains(next.Why, x => x.Target == "town_a" && x.Message == "TOWN A: 1 turn of occupation left");+ }+// R-CTRL-013 (Q-OCC-2 (a)): withdrawal before the timer ends is allowed and becomes a Raid. The occupation lasts while// an Israeli military unit is on the hex; when step 10 finds none (the player moved them out), the lost marker remains, the// place is under enemy control again with its residents unchanged, no upkeep is paid that turn and nothing elsediff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.csindex a184de162..8cbb3e5dc 100644--- a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs@@ -15,12 +15,12 @@ public class RemainingCauseKeysTestspublic static IEnumerable<object[]> Producers(){- yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", city, count - x.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, city)}: {count} groups in work\")" };+ yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", city, count - x.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, city)}: {Groups(count)} in work\")" };yield return new object[] { "Cities.cs", "WagesPaid", "new Cause(\"city\", x.Id, paid, $\"{PlayerText.Settlement(c, x.Id)}: jobs paid {PlayerText.MoneyChange(c, \"treasury\", paid)}\"" };- yield return new object[] { "Cities.cs", "ImmigrantsHoused", "new Cause(\"city\", x.Id, absorbed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed\")" };- yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", x.Id, work - housed.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {work} groups in work\")" };- yield return new object[] { "Cities.cs", "HousingShortage", "new Cause(\"city\", x.Id, over, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold\")" };- yield return new object[] { "Cities.cs", "ImmigrantsWaiting", "new Cause(\"city\", x.Id, added, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {added} groups of immigrants arrived and wait for homes\")" };+ yield return new object[] { "Cities.cs", "ImmigrantsHoused", "new Cause(\"city\", x.Id, absorbed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {Groups(absorbed)} of immigrants housed\")" };+ yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", x.Id, work - housed.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {Groups(work)} in work\")" };+ yield return new object[] { "Cities.cs", "HousingShortage", "new Cause(\"city\", x.Id, over, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {Groups(over)} more than its homes hold\")" };+ yield return new object[] { "Cities.cs", "ImmigrantsWaiting", "new Cause(\"city\", x.Id, added, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {Groups(added)} of immigrants arrived and wait for homes\")" };yield return new object[] { "Military.cs", "RecruitsVeteran", "new Cause(\"city\", \"units\", u.Strength, \"Recruits became veteran soldiers\"" };yield return new object[] { "Corridors.cs", "CorridorStarted", "new Cause(\"map\", def.Id, 1, $\"{name}: a group of halutzim began building, cost {PlayerText.Money(c, \"treasury\", cost)}\"" };yield return new object[] { "Corridors.cs", "CorridorCancelled", "new Cause(\"map\", work.Id, -1, $\"{SegmentName(def, index)}: the halutzim stopped building; the Money spent is not returned\"" };@@ -37,7 +37,7 @@ public class RemainingCauseKeysTestsyield return new object[] { "Projects.cs", "ProjectCancelled", "new Cause(\"city\", p.City, -1, $\"{PlayerText.Settlement(c, p.City)}: {k.Name} was cancelled; the Money spent is not returned\"" };yield return new object[] { "Projects.cs", "ProjectCompleted", "new Cause(\"city\", p.City, 1, $\"{PlayerText.Settlement(c, p.City)}: {k.Name} was finished\"" };yield return new object[] { "Pools.cs", "ArmsBought", "new Cause(\"economy\", \"arms\", count, FormattableString.Invariant($\"Bought {count} Arms, cost {PlayerText.Money(c, \"treasury\", cost)}\")" };- yield return new object[] { "Pools.cs", "FoodHarvest", "new Cause(\"economy\", \"food\", yield, FormattableString.Invariant($\"{f.Name}: the plowed land yielded {yield} units of Food\")" };+ yield return new object[] { "Pools.cs", "FoodHarvest", "new Cause(\"economy\", \"food\", yield, FormattableString.Invariant($\"{f.Name}: the plowed land yielded {Units(yield)} of Food\")" };yield return new object[] { "Pools.cs", "FoodShortage", "new Cause(\"economy\", \"food\", 0, FormattableString.Invariant($\"Food ran out: {s.FoodUnmet} of {need} units of the month's need went unmet\")" };yield return new object[] { "Pools.cs", "FoodWithoutImports", "new Cause(\"economy\", \"food\", -eaten, FormattableString.Invariant($\"No Food imported (foreign currency crisis): the stock fell to {s.Food} units\")" };yield return new object[] { "Prisoners.cs", "PrisonerFood", "new Cause(\"economy\", \"food\", -eaten, FormattableString.Invariant($\"The prisoners held ate {eaten} units of Food\")" };@@ -81,7 +81,7 @@ public class RemainingCauseKeysTestsyield return new object[] { "SettlementControl.cs", "OccupationStarted", "new Cause(\"map\", id, turns, FormattableString.Invariant($\"{name} is occupied for {turns} turns: an Israeli unit stays there. \") + Residents(x)" };yield return new object[] { "SettlementControl.cs", "PendingBecameRaid", "new Cause(\"map\", id, 0, $\"{c.SettlementNames[id]}: no decision was made before the game ended, so it counts as a raid\"" };yield return new object[] { "SettlementControl.cs", "OccupationLostUnit", "new Cause(\"map\", id, 0, $\"{name}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {Residents(x)}\"" };- yield return new object[] { "SettlementControl.cs", "OccupationCountdown", "new Cause(\"map\", id, left, left == 0\n ? $\"{name}: the occupation period has ended. It awaits a decision\"\n : FormattableString.Invariant($\"{name}: {left} turns of occupation left\")" };+ yield return new object[] { "SettlementControl.cs", "OccupationCountdown", "new Cause(\"map\", id, left, left == 0\n ? $\"{name}: the occupation period has ended. It awaits a decision\"\n : FormattableString.Invariant($\"{name}: {TurnsLeft(left)} of occupation left\")" };yield return new object[] { "SettlementControl.cs", "DepopulationSupport", "new Cause(\"map\", SupportIndicator, change, $\"{PlayerText.Change(c, SupportIndicator, change)} (the places depopulated by Deport)\"" };}diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex 7f8dd8f17..2d5e1f57f 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -78,6 +78,9 @@ namespace Statecraft.Simif (housing != null) s.Indicators[housing.Id] = EffectsSystem.Level(c, s, housing); // R-HOUSE-004 from the first day}+ // #2530: a count of 1 names the singular, as the UI's helper does.+ static string Groups(int n) => n == 1 ? "1 group" : FormattableString.Invariant($"{n} groups");+/// <summary>R-CITY-001: sets the number of the city's people in jobs (a standing order), and turns that city's job/// default off (R-CITY-009). Refused, state untouched, when the city or role is unknown or the count is negative, above/// the job slots or above the civilians and craftsmen. Step has already refused it in the legacy loop.</summary>@@ -97,7 +100,7 @@ namespace Statecraft.Sim? FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.JobSlots} jobs"): string.Format(System.Globalization.CultureInfo.InvariantCulture, Workshops.RefusedPeople, PlayerText.Settlement(c, city), x.Civilians + x.Craftsmen - Workshops.Staffed(s, city) - Projects.Builders(s, city));s.Cities[city] = x.WithCounts(x.Civilians, count, x.Refugees).WithJobsDefault(false);- why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {count} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(count) }));+ why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {Groups(count)} in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(count) }));return null;}@@ -177,11 +180,11 @@ namespace Statecraft.Simvar absorbed = x.Refugees == 0 ? 0 : Math.Min(x.Refugees, (int)Math.Floor(x.Refugees * m));var housed = absorbed == 0 ? x : x.WithCounts(x.Civilians + absorbed, x.Employed, x.Refugees - absorbed);if (absorbed != 0)- why.Add(new Cause("city", x.Id, absorbed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed"), key: CauseKeys.ImmigrantsHoused, args: new[] { CauseKeys.Number(absorbed) }));+ why.Add(new Cause("city", x.Id, absorbed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {Groups(absorbed)} of immigrants housed"), key: CauseKeys.ImmigrantsHoused, args: new[] { CauseKeys.Number(absorbed) }));var work = MaxWorkers(s, housed);if (housed.JobsDefault && work != housed.Employed){- why.Add(new Cause("city", x.Id, work - housed.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {work} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(work) }));+ why.Add(new Cause("city", x.Id, work - housed.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {Groups(work)} in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(work) }));housed = housed.WithCounts(housed.Civilians, work, housed.Refugees);}s.Cities[x.Id] = housed;@@ -262,7 +265,7 @@ namespace Statecraft.Simif (over == 0) continue;if (gdd03 == null && x.Condition is double now)s.Cities[x.Id] = x.WithCondition(Math.Max(0.0, now - r.OverflowConditionLoss!.Value * over / Housed(s, x)));- why.Add(new Cause("city", x.Id, over, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold"), key: CauseKeys.HousingShortage, args: new[] { CauseKeys.Number(over) }));+ why.Add(new Cause("city", x.Id, over, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {Groups(over)} more than its homes hold"), key: CauseKeys.HousingShortage, args: new[] { CauseKeys.Number(over) }));}if (gdd03 != null) SettleGdd03(c, s, surcharge, cohesion, why);}@@ -343,7 +346,7 @@ namespace Statecraft.Simif (added == 0) continue;var x = s.Cities[kv.Key];s.Cities[x.Id] = x.WithCounts(x.Civilians, x.Employed, x.Refugees + added);- why.Add(new Cause("city", x.Id, added, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {added} groups of immigrants arrived and wait for homes"), key: CauseKeys.ImmigrantsWaiting, args: new[] { CauseKeys.Number(added) }));+ why.Add(new Cause("city", x.Id, added, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {Groups(added)} of immigrants arrived and wait for homes"), key: CauseKeys.ImmigrantsWaiting, args: new[] { CauseKeys.Number(added) }));}}diff --git a/sim/Statecraft.Sim/Pools.cs b/sim/Statecraft.Sim/Pools.csindex 0b50f5267..186431c21 100644--- a/sim/Statecraft.Sim/Pools.cs+++ b/sim/Statecraft.Sim/Pools.cs@@ -92,6 +92,9 @@ namespace Statecraft.Sim/// <summary>The nation's need for one turn: its head count in population units, rounded half away from zero.</summary>static int Need(GameState s, MvpRules r) => (int)Math.Round(s.TotalPopulation / r.PeoplePerUnit, MidpointRounding.AwayFromZero);+ // #2530: a count of 1 names the singular, as the UI's helper does.+ static string Units(int n) => n == 1 ? "1 unit" : FormattableString.Invariant($"{n} units");+/// <summary>R-FIELD-002, step 6 after the cities' production (D-A6): in ordinal site id order, every plowed field (a built/// field site, R-FIELD-001) adds field_food_per_turn to the stock, with no workers (Q-FIELD-2). It comes before the/// nation eats in step 7, so in a turn with imports the import only tops the stock up by less.</summary>@@ -104,7 +107,7 @@ namespace Statecraft.Sim{if (!(s.Sites.TryGetValue(f.Id, out var w) && w.BuiltOn != null)) continue;s.Food += yield;- why.Add(new Cause("economy", "food", yield, FormattableString.Invariant($"{f.Name}: the plowed land yielded {yield} units of Food"), key: CauseKeys.FoodHarvest, args: new[] { f.Id }));+ why.Add(new Cause("economy", "food", yield, FormattableString.Invariant($"{f.Name}: the plowed land yielded {Units(yield)} of Food"), key: CauseKeys.FoodHarvest, args: new[] { f.Id }));}}diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex 040d6c712..b824d03b6 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -413,6 +413,9 @@ namespace Statecraft.Simreturn null;}+ // #2530: a count of 1 names the singular, as the UI's helper does.+ static string Groups(int n) => n == 1 ? "1 group" : FormattableString.Invariant($"{n} groups");+/// <summary>R-CITY-011 (#1700; owner, 3 November 2026: "Builders in the MVP (Recommended)", "One builder, today's times/// (Recommended)"): AssignWorkers(city, "build", count), gdd-0.3 only, sets how many of the city's projects being built/// have a builder. A rise puts builders on the projects that have none, in ascending id; a fall takes them off the@@ -438,7 +441,7 @@ namespace Statecraft.Simif (employed != x.Employed){s.Cities[city] = x.WithCounts(x.Civilians, employed, x.Refugees);- why.Add(new Cause("city", city, employed - x.Employed, FormattableString.Invariant($"{name}: {employed} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(employed) }));+ why.Add(new Cause("city", city, employed - x.Employed, FormattableString.Invariant($"{name}: {Groups(employed)} in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(employed) }));}if (count > builders)foreach (var p in building.Where(p => !p.Builder).Take(count - builders))diff --git a/sim/Statecraft.Sim/SettlementControl.cs b/sim/Statecraft.Sim/SettlementControl.csindex ba1b1737f..26e5e0e49 100644--- a/sim/Statecraft.Sim/SettlementControl.cs+++ b/sim/Statecraft.Sim/SettlementControl.cs@@ -351,6 +351,9 @@ namespace Statecraft.Sim}}+ // #2530: a count of 1 names the singular, as the UI's helper does.+ static string TurnsLeft(int n) => n == 1 ? "1 turn" : FormattableString.Invariant($"{n} turns");+/// <summary>Resolver step 10, the occupation timers, in ordinal id order (R-CTRL-011 to R-CTRL-013). An occupied place/// with no Israeli military unit left on its hex has been withdrawn from before the timer ended, which is a Raid/// (Q-OCC-2 (a)): its record becomes ownerless, so it is under enemy control again, its residents unchanged, and nothing is paid.@@ -375,7 +378,7 @@ namespace Statecraft.Sims.Settlements[id] = new SettlementControl(x.Owner, left == 0 ? AwaitingEnd : Occupied, x.Since, x.Depopulated, x.Combatants, x.Buildings, left, x.Fled);why.Add(new Cause("map", id, left, left == 0? $"{name}: the occupation period has ended. It awaits a decision"- : FormattableString.Invariant($"{name}: {left} turns of occupation left"), key: CauseKeys.OccupationCountdown));+ : FormattableString.Invariant($"{name}: {TurnsLeft(left)} of occupation left"), key: CauseKeys.OccupationCountdown));}}diff --git a/sim/Statecraft.Sim/Workshops.cs b/sim/Statecraft.Sim/Workshops.csindex b23a621ae..ccb7f0799 100644--- a/sim/Statecraft.Sim/Workshops.cs+++ b/sim/Statecraft.Sim/Workshops.cs@@ -94,6 +94,9 @@ namespace Statecraft.Simpublic static int Staffed(GameState s, string city) =>s.Workshops.Values.Count(w => w.Staffed && s.CityProjects[w.Project].City == city);+ // #2530: a count of 1 names the singular, as the UI's helper does.+ static string Groups(int n) => n == 1 ? "1 group" : FormattableString.Invariant($"{n} groups");+/// <summary>R-ARMS-005 (27M-13: "Any free civilian. The cost tier follows the worker"): AssignWorkers(city, "workshop",/// count), a standing order: the city's first <paramref name="count"/> built workshops, in ascending id, are staffed and/// the rest are not. A newly staffed workshop takes one of the city's civilians and craftsmen who hold no job (it stays@@ -112,7 +115,7 @@ namespace Statecraft.Simif (employed != x.Employed){s.Cities[city] = x.WithCounts(x.Civilians, employed, x.Refugees);- why.Add(new Cause("city", city, employed - x.Employed, FormattableString.Invariant($"{name}: {employed} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(employed) }));+ why.Add(new Cause("city", city, employed - x.Employed, FormattableString.Invariant($"{name}: {Groups(employed)} in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(employed) }));}for (int i = 0; i < built.Count; i++){diff --git a/unity/Assets/Scripts/UI/CauseText.cs b/unity/Assets/Scripts/UI/CauseText.csindex 24d2a58d0..f6a411f11 100644--- a/unity/Assets/Scripts/UI/CauseText.cs+++ b/unity/Assets/Scripts/UI/CauseText.cs@@ -100,6 +100,11 @@ namespace Statecraft.Game.UIstring Site(string id) { var x = c.Sites.First(s => s.Id == id); return Pick(x.Name, x.NameHe); }string Groups(string count) => text["ui.lang"] == UiLanguage.Hebrew ? count: count == "1" ? "1 group" : count + " groups";+ // #2530: the same singular for the Food and occupation lines; the Hebrew names the count in a label, as for groups.+ string Units(string count) => text["ui.lang"] == UiLanguage.Hebrew ? count+ : count == "1" ? "1 unit" : count + " units";+ string Turns(string count) => text["ui.lang"] == UiLanguage.Hebrew ? count+ : count == "1" ? "1 turn" : count + " turns";string Course(string id) => text["why.cause.course." + id];string Residents(string fled) => text["why.cause.residents." + fled];string Parties(string ids) => string.Join(", ", ids.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)@@ -115,15 +120,15 @@ namespace Statecraft.Game.UIswitch (cause.Key){case CauseKeys.WorkersAssigned:- return text.Format(key, Settlement(cause.Target), A(0));+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));case CauseKeys.WagesPaid:return text.Format(key, Settlement(cause.Target), PlayerText.MoneyChange(c, "treasury", cause.Delta));case CauseKeys.ImmigrantsHoused:- return text.Format(key, Settlement(cause.Target), A(0));+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));case CauseKeys.HousingShortage:- return text.Format(key, Settlement(cause.Target), A(0));+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));case CauseKeys.ImmigrantsWaiting:- return text.Format(key, Settlement(cause.Target), A(0));+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));case CauseKeys.RecruitsVeteran:return text.Format(key);case CauseKeys.CorridorStarted:@@ -170,7 +175,7 @@ namespace Statecraft.Game.UIcase CauseKeys.DollarsConvertedFx: // #2527: the reserves drop, worded as foreign currency, not a Money changereturn text.Format(key, Money(c, "fx_reserves", A(0)), PlayerText.MoneyChange(c, "fx_reserves", cause.Delta));case CauseKeys.FoodHarvest:- return text.Format(key, Site(A(0)), cause.Delta);+ return text.Format(key, Site(A(0)), Units(cause.Delta.ToString(CultureInfo.InvariantCulture)));case CauseKeys.FoodShortage:return text.Format(key, A(0), A(1)); // the unmet, then the need: the line is informational (#2527)case CauseKeys.FoodWithoutImports:@@ -257,7 +262,7 @@ namespace Statecraft.Game.UIreturn text.Format(key, Settlement(cause.Target), Residents(A(0)));case CauseKeys.OccupationCountdown:if (cause.Delta == 0) return text.Format(key + "_ended", Settlement(cause.Target));- return text.Format(key, Settlement(cause.Target), cause.Delta);+ return text.Format(key, Settlement(cause.Target), Turns(cause.Delta.ToString(CultureInfo.InvariantCulture)));case CauseKeys.DepopulationSupport:return text.Format(key, Name(text, cause.Target), Change(c, cause.Target, cause.Delta));default: throw new InvalidOperationException("Unknown remaining Cause key: " + cause.Key);diff --git a/unity/Assets/Scripts/UI/DefencePresenter.cs b/unity/Assets/Scripts/UI/DefencePresenter.csindex f23278bc9..57b1327c6 100644--- a/unity/Assets/Scripts/UI/DefencePresenter.cs+++ b/unity/Assets/Scripts/UI/DefencePresenter.cs@@ -124,6 +124,11 @@ namespace Statecraft.Game.UIif (SameAsToday(level)) Withdraw(new SetMobilization(0)); else bridge.Queue(new SetMobilization(level));}+ /// <summary>#2530: "1 week" in English; the Hebrew names the number in a label, grammatical for any count.</summary>+ static string Weeks(UiText text, int weeks) => text["ui.lang"] == UiLanguage.Hebrew+ ? weeks.ToString(System.Globalization.CultureInfo.InvariantCulture)+ : weeks == 1 ? "1 week" : weeks + " weeks";+/// <summary>The string key for a turn length. A switch, so a new TurnLength value fails loudly (and in a test).</summary>public static string TurnKey(TurnLength length){@@ -172,7 +177,7 @@ namespace Statecraft.Game.UI}var ceasefire = screen.Q<Label>("ceasefire");if (c.IsGdd) ceasefire.text = ""; // the GDD loop retires the clock (R-WAR-003): no ceasefire to promise- else if (s.Rung == 5 && target == 5) ceasefire.text = text.Format("defence.ceasefire", s.CeasefireWeeksLeft);+ else if (s.Rung == 5 && target == 5) ceasefire.text = text.Format("defence.ceasefire", Weeks(text, s.CeasefireWeeksLeft));else if (s.Rung == 5) ceasefire.text = text["defence.ceasefire_stops"]; // a lowering is queuedelse if (target == 5) ceasefire.text = text.Format("defence.ceasefire_starts", SecuritySystem.CeasefireWeeksAfter(c, s.Date, s.Rung, s.CeasefireWeeksLeft, target));else ceasefire.text = "";diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex 5de812a59..f066c4231 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -317,10 +317,26 @@ namespace Statecraft.Game.UI}foreach (var (pattern, format) in ReasonFormats)if (pattern.Match(reason) is { Success: true } m)- return text.Format(format, m.Groups.Cast<Group>().Skip(1).Select(v => (object)ReasonValue(text, v.Value, c, townsHe)).ToArray());+ return text.Format(format, CountNoun(text, format,+ m.Groups.Cast<Group>().Skip(1).Select(v => (object)ReasonValue(text, v.Value, c, townsHe)).ToArray()));return reason;}+ /// <summary>#2530: an English count names its noun in the singular for 1 ("1 civilian without work"); the Hebrew+ /// strings name the number in a label, grammatical for any count. Any other count reads as the sim's own English.</summary>+ static object[] CountNoun(UiText text, string key, object[] values)+ {+ if (text["ui.lang"] == UiLanguage.Hebrew || values.Length != 2 || values[1] is not string n) return values;+ values[1] = key switch+ {+ "unit.reinforce_refused.idle" => n == "1" ? "1 civilian without work" : n + " civilians without work",+ "workshop.refused_people" => n == "1" ? "1 civilian or craftsman" : n + " civilians and craftsmen",+ "workshop.refused_people_no_job" => n == "1" ? "1 civilian or craftsman without a job" : n + " civilians and craftsmen without a job",+ _ => values[1],+ };+ return values;+ }+static string ReasonValue(UiText text, string value, Content? c, IReadOnlyDictionary<string, string>? townsHe){if (c == null) return value;diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.csindex 14d266a72..168e9ffa1 100644--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs@@ -464,6 +464,13 @@ public class CauseTextTestsnew Cause("draft", "treasury", 1.44, "Converted $4.0m of foreign currency into Money: IL\u00A0+1.4m", key: CauseKeys.DollarsConverted, args: new[] { "4" }),new Cause("draft", "fx_reserves", -4, "Foreign currency converted into Money: $-4.0m", key: CauseKeys.DollarsConvertedFx, args: new[] { "4" }), // #2527new Cause("draft", "food", 2000000000, "Site: the plowed land yielded 2000000000 units of Food", key: CauseKeys.FoodHarvest, args: new[] { "site" }),+ // #2530: a count of 1 names the singular; the helpers name "1 group"/"1 unit"/"1 turn" in English only.+ new Cause("draft", "town", 1, "Town: 1 group in work", key: CauseKeys.WorkersAssigned, args: new[] { "1" }),+ new Cause("draft", "town", 1, "Town: 1 group of immigrants housed", key: CauseKeys.ImmigrantsHoused, args: new[] { "1" }),+ new Cause("draft", "town", 1, "Town: 1 group more than its homes hold", key: CauseKeys.HousingShortage, args: new[] { "1" }),+ new Cause("draft", "town", 1, "Town: 1 group of immigrants arrived and wait for homes", key: CauseKeys.ImmigrantsWaiting, args: new[] { "1" }),+ new Cause("draft", "food", 1, "Site: the plowed land yielded 1 unit of Food", key: CauseKeys.FoodHarvest, args: new[] { "site" }),+ new Cause("draft", "town", 1, "Town: 1 turn of occupation left", key: CauseKeys.OccupationCountdown),new Cause("draft", "food", 0, "Food ran out: 2000000000 of 2000000001 units of the month's need went unmet", key: CauseKeys.FoodShortage, args: new[] { "2000000000", "2000000001" }), // informational (#2527): the unmet, then the neednew Cause("draft", "food", -1, "No Food imported (foreign currency crisis): the stock fell to 2000000000 units", key: CauseKeys.FoodWithoutImports, args: new[] { "2000000000" }),new Cause("draft", "food", 150, "The month's eating and Food imports brought the stock to 2000000000 units", key: CauseKeys.FoodImported, args: new[] { "2000000000" }), // #2527@@ -521,7 +528,7 @@ public class CauseTextTestsvar raid = new Cause("map", "town", 0,"Town: no decision was made before the game ended, so it counts as a raid", key: CauseKeys.PendingBecameRaid);Assert.IsTrue(string.Equals("{0}: מוחזק, תורות שנותרו: {1}", he["why.cause.occupation_countdown"], StringComparison.Ordinal));- Assert.IsTrue(string.Equals("{0}: {1} turns of occupation left", en["why.cause.occupation_countdown"], StringComparison.Ordinal));+ Assert.IsTrue(string.Equals("{0}: {1} of occupation left", en["why.cause.occupation_countdown"], StringComparison.Ordinal)); // #2530: the count names its noun ("1 turn"/"N turns")Assert.IsTrue(string.Equals("{0}: לא התקבלה החלטה עד סוף המשחק, ולכן הדבר נחשב לפשיטה", he["why.cause.pending_became_raid"], StringComparison.Ordinal));Assert.IsTrue(string.Equals("{0}: no decision was made before the game ended, so it counts as a raid", en["why.cause.pending_became_raid"], StringComparison.Ordinal));Assert.IsTrue(string.Equals("Town: 3 turns of occupation left", CauseText.Line(countdown, c, NoRows, en), StringComparison.Ordinal));@@ -551,7 +558,7 @@ public class CauseTextTestsCauseKeys.EventRejoin, CauseKeys.EventSetRung, CauseKeys.EventStock, CauseKeys.EventUnlock,CauseKeys.MilitaryUpkeep, CauseKeys.HousingSurcharge, CauseKeys.HousingCohesion,CauseKeys.ObjectiveCompleted, CauseKeys.PrisonersReturned, CauseKeys.SoldiersReturned,- CauseKeys.FieldFood }), rows.Select(x => x.Key), "all remaining keys"); // FieldFood (#2471): only the gdd-0.3 field fixture makes it, no turn yet, so no wording yet+ CauseKeys.FieldFood }), rows.Select(x => x.Key).Distinct(), "all remaining keys"); // FieldFood (#2471): only the gdd-0.3 field fixture makes it, no turn yet, so no wording yetvar appointed = rows.Single(x => x.Key == CauseKeys.Appointed);StringAssert.Contains("התפקיד שנשמר", CauseText.Line(appointed, c, NoRows, he, names), "historical title, not current title");}diff --git a/unity/Assets/Tests/EditMode/DefenceScreenTests.cs b/unity/Assets/Tests/EditMode/DefenceScreenTests.csindex 4ea10da15..133fe3faf 100644--- a/unity/Assets/Tests/EditMode/DefenceScreenTests.cs+++ b/unity/Assets/Tests/EditMode/DefenceScreenTests.cs@@ -69,6 +69,23 @@ public class DefenceScreenTests}}+ /// <summary>#2530: the legacy loop's ceasefire clock names one week in the singular ("in 1 week"); the sim's English+ /// and the Hebrew label are unchanged for every other count.</summary>+ [Test]+ public void TheCeasefireClockNamesOneWeekInTheSingular()+ {+ var ui = new UiTestKit();+ using (ui)+ {+ ui.Q<VisualElement>("screen-defence").style.display = DisplayStyle.Flex;+ var bridge = new SimBridge(GameSession.New(SimBridgeGddTests.Legacy, GoldenRun.Seed, Mode.Historical), Text);+ bridge.Session.State.Rung = 5;+ bridge.Session.State.CeasefireWeeksLeft = 1;+ using var defence = new DefencePresenter(ui.Root, bridge, Text);+ Assert.AreEqual("If full war goes on, the UN imposes a ceasefire in 1 week", ui.Q<Label>("ceasefire").text);+ }+ }+[Test]public void OrdersAreQueuedAndTheTurnCarriesThemOut(){diff --git a/unity/Assets/Tests/EditMode/RefusalTextTests.cs b/unity/Assets/Tests/EditMode/RefusalTextTests.csnew file mode 100644index 000000000..7988dca55--- /dev/null+++ b/unity/Assets/Tests/EditMode/RefusalTextTests.cs@@ -0,0 +1,35 @@+#nullable enable+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;++/// <summary>#2530: a refusal's English count names its noun in the singular for 1 ("1 civilian without work"), and reads+/// as the sim's own English for every other count; the Hebrew strings name the number in a label, grammatical for any+/// count. The sim's refusal formats are unchanged.</summary>+public class RefusalTextTests+{+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");++ [Test]+ public void ACivilianCountOfOneNamesTheSingularInEnglishOnly()+ {+ var town = "Rishon LeZion";+ Assert.AreEqual(town + " has 1 civilian without work",+ SimBridge.ReasonText(En, string.Format(System.Globalization.CultureInfo.InvariantCulture, Training.RefusedIdle, town, 1)));+ Assert.AreEqual(town + " has 1 civilian or craftsman",+ SimBridge.ReasonText(En, string.Format(System.Globalization.CultureInfo.InvariantCulture, Workshops.RefusedPeople, town, 1)));+ Assert.AreEqual(town + " has 1 civilian or craftsman without a job",+ SimBridge.ReasonText(En, string.Format(System.Globalization.CultureInfo.InvariantCulture, Workshops.RefusedPeopleNoJob, town, 1)));+ // Every other count is the sim's own English, word for word.+ var reason = string.Format(System.Globalization.CultureInfo.InvariantCulture, Training.RefusedIdle, town, 6);+ Assert.AreEqual(reason, SimBridge.ReasonText(En, reason));+ // The Hebrew names the number in its label: no noun to inflect.+ var he = SimBridge.ReasonText(He, string.Format(System.Globalization.CultureInfo.InvariantCulture, Training.RefusedIdle, town, 1));+ StringAssert.IsMatch("[\u05D0-\u05EA]", he);+ StringAssert.Contains("1", he);+ }+}diff --git a/unity/Assets/Tests/EditMode/RefusalTextTests.cs.meta b/unity/Assets/Tests/EditMode/RefusalTextTests.cs.metanew file mode 100644index 000000000..2793a78c0--- /dev/null+++ b/unity/Assets/Tests/EditMode/RefusalTextTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: af101225285d4049873ff185f3637b40\ No newline at end of filediff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 2243de26d..d28fe181b 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -360,7 +360,7 @@ defence.turn_quarter: "turns of a quarter"defence.turn_month: "turns of a month"defence.turn_week: "turns of a week"defence.command: "Minister of Defense {0} · Chief of Staff {1}"-defence.ceasefire: "If full war goes on, the UN imposes a ceasefire in {0} weeks"+defence.ceasefire: "If full war goes on, the UN imposes a ceasefire in {0}" # {0} is "1 week"/"N weeks" (DefencePresenter.Weeks, #2530)defence.order: "Ordered: level {0} to {1}"defence.mob: "{0} of reserves called up (level {1} needs at least {2})"defence.mob_cost: "Costs {0} a year in pay and lost work"@@ -850,8 +850,8 @@ city.workshop_held: "Paused: the enemy holds {0}"# A workshop staffing order's refusals (R-ARMS-005): the sim's own English (Workshops.Refused*), {0} the city, {1} a count.workshop.refused_built_one: "{0} has 1 arms workshop"workshop.refused_built: "{0} has {1} arms workshops"-workshop.refused_people: "{0} has {1} civilians and craftsmen"-workshop.refused_people_no_job: "{0} has {1} civilians and craftsmen without a job"+workshop.refused_people: "{0} has {1}" # the count names its noun (SimBridge.CountNoun, #2530)+workshop.refused_people_no_job: "{0} has {1}" # the count names its noun (SimBridge.CountNoun, #2530)site.available: "A designated site for a new yishuv"site.group: "halutz group {0}"site.build: "Build a yishuv with {0}: {1}, {2}"@@ -1099,15 +1099,15 @@ unit.reinforce_refused.count: "Train at least one group"unit.reinforce_refused.no_camp: "{0} has no military camp"unit.reinforce_refused.no_industry: "{0} has no completed industry project"unit.reinforce_refused.no_hakhshara: "{0} has no Hakhshara"-unit.reinforce_refused.idle: "{0} has {1} civilians without work"+unit.reinforce_refused.idle: "{0} has {1}" # the count names its noun (SimBridge.CountNoun, #2530)unit.reinforce_refused.arms: "{0}: not enough Arms for {1} (need {2}, have {3})"# #1682 remaining Cause producers. English report wording preserved.-why.cause.workers_assigned: "{0}: {1} groups in work"+why.cause.workers_assigned: "{0}: {1} in work" # {1} is "1 group"/"N groups" (CauseText.Groups, #2530)why.cause.wages_paid: "{0}: jobs paid {1}"-why.cause.immigrants_housed: "{0}: {1} groups of immigrants housed"-why.cause.housing_shortage: "{0}: {1} groups more than its homes hold"-why.cause.immigrants_waiting: "{0}: {1} groups of immigrants arrived and wait for homes"+why.cause.immigrants_housed: "{0}: {1} of immigrants housed" # {1} is "1 group"/"N groups" (#2530)+why.cause.housing_shortage: "{0}: {1} more than its homes hold" # {1} is "1 group"/"N groups" (#2530)+why.cause.immigrants_waiting: "{0}: {1} of immigrants arrived and wait for homes" # {1} is "1 group"/"N groups" (#2530)why.cause.recruits_veteran: "Recruits became veteran soldiers"why.cause.corridor_started: "{0}: a group of halutzim began building, cost {1}"why.cause.corridor_cancelled: "{0}: the halutzim stopped building; the Money spent is not returned"@@ -1133,7 +1133,7 @@ why.cause.workshop_workers: "{0}: arms workshops staffed: {1}"why.cause.workshop_arms: "{0}: an arms workshop made 1 Arms"why.cause.workshop_paused.no_worker: "{0}: an arms workshop has no worker without a job this month"why.cause.workshop_paused.debt_ceiling: "{0}: an arms workshop's next cycle waits: paying for it would take the debt past its ceiling"-why.cause.food_harvest: "{0}: the plowed land yielded {1} units of Food"+why.cause.food_harvest: "{0}: the plowed land yielded {1} of Food" # {1} is "1 unit"/"N units" (CauseText.Units, #2530)why.cause.food_shortage: "Food ran out: {0} of {1} units of the month's need went unmet"why.cause.food_without_imports: "No Food imported (foreign currency crisis): the stock fell to {0} units"why.cause.food_imported: "The month's eating and Food imports brought the stock to {0} units"@@ -1176,7 +1176,7 @@ why.cause.deport_cost: "{0} {1} (Deport of {2})"why.cause.occupation_started: "{0} is occupied for {1} turns: an Israeli unit stays there. {2}"why.cause.pending_became_raid: "{0}: no decision was made before the game ended, so it counts as a raid"why.cause.occupation_lost_unit: "{0}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {1}"-why.cause.occupation_countdown: "{0}: {1} turns of occupation left"+why.cause.occupation_countdown: "{0}: {1} of occupation left" # {1} is "1 turn"/"N turns" (CauseText.Turns, #2530)why.cause.depopulation_support: "{0} {1} (the places depopulated by Deport)"why.cause.work.plow: "plowing"why.cause.work.drain: "draining the swamp"