A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: a held gdd-0.3 city pauses its job income and projects (R-CITY-010, Refs #1711) (#2166)
Berib4a4f6a07511
diff --git a/changelog.d/1711-held-city-pause.md b/changelog.d/1711-held-city-pause.mdnew file mode 100644index 000000000..430b15a12--- /dev/null+++ b/changelog.d/1711-held-city-pause.md@@ -0,0 +1,4 @@+### Changed++- Under gdd-0.3, an Israeli city with an enemy unit on it earns no job income and its building projects stop. Both pick up+ where they left off once the city is retaken, and nothing is deleted (R-CITY-010, Refs #1711).diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 0c71a7081..3ba1f8629 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -112,6 +112,8 @@ The #1696 status comment of 27 October 2026 says, "It does not yet provide the lR-CITY-009: The job default (Q-JOBS-1, owner, 15 October 2026). On each housing step, after the refugees become civilians (R-CITY-004), each city whose default is on sets its employed to `min(job slots, civilians + craftsmen)`, in ascending city id, at no Attention cost. Every city's default is on at the start; an accepted `AssignWorkers` order fixes that city's number and turns its default off for the rest of the game. Each change is a `city` cause on the Why screen ("Town: N groups in work"). A city's record writes `jobs=manual` into the state hash only when its default is off.+R-CITY-010: A city the enemy holds pauses (decision D6, owner, 1 November 2026, "Approve all six (Recommended)", [answers](https://github.com/eyalgolan/statecraft-israel/pull/1668#issuecomment-6553884547); #1711). Under gdd-0.3 only, a city is held in a turn when an enemy military unit (a unit with a `side` other than the player's; a halutz has no side and holds nothing, R-UNIT-001) stands on its settlement hex when steps 5 and 6 run, after step 3: no later step moves an enemy unit, so that is where it stands at the turn's end. An enemy formation that arrives on the hex at step 9 (R-UNIT-009) holds the city from the next turn. That turn a held city pays no R-CITY-002 job income and its R-PROJ-003 projects gain no progress: their records, turns left and carried fraction stay as they were. Housing, residents, jobs and every id are unchanged, nobody is evacuated, and an objective already awarded stays awarded. A turn in which no enemy unit is on the hex pays and builds as before. Cities have no Food production of their own on main (R-FIELD-002 fields belong to no city), so there is nothing else to pause until #1694 links fields to cities. gdd-0.1 and legacy are unchanged, and gdd-0.1 keeps its R-END-003 defeat. The turn-report line for a held city is still to come.+R-CITY-005: The cities' employed share (employed over civilians and craftsmen, summed over all cities; 1 with none) is an effect-web source of `morale`, Social cohesion (`work_lifts_cohesion`, source id `employed_share`), read after the turn's housing. The legacy loop has no cities, so there it reads 0 and adds nothing. Housing reaches Social cohesion through the existing `housing` link (`homes_lift_morale`) until Phase 3 makes it the cities' aggregate (Q-NAT-2, decided 15 October 2026). Phase 1's separate cohesion value and its two weights are gone (D-C1, Reading 2).R-CITY-006: The cities are the `city` and `town` rows of `map/settlements_1948.yaml`, in that file's order, and their start values are `cities.yaml`'s. Each of a city's values (`people`, `employed_share`, `housing_capacity`, `job_slots`) is required and has a status: `sourced` (read from the source named), `derived` (computed from sourced values), `wikipedia-only` (an owner-accepted Wikipedia figure) or `design` (a labelled design value, R-LOOP-005). A `sourced`, `derived` or `wikipedia-only` value has at least one source, each with a url and a checked date, and the day (YYYY-MM-DD) or month (YYYY-MM) it describes; the loader refuses a value without them, naming the file and field (GDD Phase 3 plan, review focus 3).diff --git a/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs b/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.csindex ce86c179e..063813786 100644--- a/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs+++ b/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs@@ -160,4 +160,48 @@ public class NoCityLossDefeatTestsvar result = Simulation.Step(c, s, new Command[] { new UnitOrder(1, "hold") });Assert.Equal(before, result.State.Describe()); Assert.Single(result.Rejected); Assert.Empty(result.Why);}++ static bool Paid(StepResult result, string city) => result.Why.Any(w => w.Key == CauseKeys.WagesPaid && w.Target == city);++ // R-CITY-010 (D6): under gdd-0.3 a city with an enemy military unit on its hex pays no job income and its projects+ // make no progress; the other city is unchanged. Retaken, both resume from where they stopped, with the same ids.+ [Fact]+ public void Gdd03HeldCityPausesItsJobsAndProjectsUntilRetaken()+ {+ var c = Load(); var s = Simulation.NewGame(c, 1, Mode.Historical); Occupy(s);+ s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3));+ s.CityProjects.Add(11, new CityProject(11, "housing", "town_b", 3, 2, 3));+ s.Objectives["already_awarded"] = s.Date;+ var cities = s.Cities.Keys.ToArray();+ var held = Simulation.Step(c, s, Array.Empty<Command>());+ Assert.False(Paid(held, "town_a"));+ Assert.True(Paid(held, "town_b"));+ Assert.Equal(3, held.State.CityProjects[10].TurnsLeft);+ Assert.Equal(0.0, held.State.CityProjects[10].Progress);+ Assert.Equal(2, held.State.CityProjects[11].TurnsLeft);+ Assert.Equal(cities, held.State.Cities.Keys);+ Assert.True(held.State.Objectives.ContainsKey("already_awarded"));++ var s2 = held.State; s2.Units.Remove(1); // retaken: no enemy unit on the hex at the turn's end+ var retaken = Simulation.Step(c, s2, Array.Empty<Command>());+ Assert.True(Paid(retaken, "town_a"));+ Assert.Equal(2, retaken.State.CityProjects[10].TurnsLeft);+ Assert.Equal(new[] { 10, 11 }, retaken.State.CityProjects.Keys.OrderBy(x => x));+ Assert.Equal(cities, retaken.State.Cities.Keys);+ Assert.True(retaken.State.Objectives.ContainsKey("already_awarded"));+ }++ // R-CITY-010, R-UNIT-001: a halutz holds nothing, and gdd-0.1 keeps paying the turn its R-END-003 defeat fires.+ [Theory]+ [InlineData(SaveGame.Gdd03Ruleset, true)]+ [InlineData(SaveGame.GddRuleset, false)]+ public void OnlyAnEnemyUnitUnderGdd03PausesACity(string ruleset, bool halutz)+ {+ var c = Load(ruleset); var s = Simulation.NewGame(c, 1, Mode.Historical);+ if (halutz) s.Units.Add(1, new Unit(1, "halutz", 1, 0)); else Occupy(s);+ s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3));+ var result = Simulation.Step(c, s, Array.Empty<Command>());+ Assert.True(Paid(result, "town_a"));+ Assert.Equal(2, result.State.CityProjects[10].TurnsLeft);+ }}diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex 2193ba5c2..225248180 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -78,13 +78,15 @@ namespace Statecraft.Sim}/// <summary>R-CITY-002, R-CRAFT-002: each city's employed units earn income_per_job_per_year for the turn's share of a- /// year. Craftsmen take the jobs first, and each employed craftsman earns craftsman_income_multiple times that.</summary>+ /// year. Craftsmen take the jobs first, and each employed craftsman earns craftsman_income_multiple times that.+ /// R-CITY-010: a city the enemy holds earns nothing.</summary>public static void Produce(Content c, GameState s, MvpRules r, double yearFraction, List<Cause> why){PopulationLedger.RefuseAggregate(s);+ var held = Held(c, s);foreach (var x in s.Cities.Values){- if (x.Employed == 0) continue;+ if (x.Employed == 0 || held.Contains(x.Id)) continue;var craftsmen = Math.Min(x.Craftsmen, x.Employed);var paid = ((x.Employed - craftsmen) + craftsmen * r.CraftsmanIncomeMultiple) * r.IncomePerJobPerYear * yearFraction;s.Treasury += paid;@@ -92,6 +94,23 @@ namespace Statecraft.Sim}}+ /// <summary>R-CITY-010 (D6, owner, 1 November 2026, #1711): under gdd-0.3, the ids of the cities with an enemy military+ /// unit on their settlement hex (a halutz has no side and holds nothing, R-UNIT-001; Movement's reading of "the+ /// enemy", as R-END-003's). Read in steps 5 and 6: no step after step 3 moves an enemy unit, so this is the turn's end;+ /// a formation arriving at step 9 counts from the next turn.+ /// Empty under every other ruleset.</summary>+ public static HashSet<string> Held(Content c, GameState s)+ {+ var held = new HashSet<string>(StringComparer.Ordinal);+ if (c.Ruleset != SaveGame.Gdd03Ruleset) return held;+ var enemy = new HashSet<(int Q, int R)>();+ foreach (var u in s.Units.Values)+ if (u.Side != "" && u.Side != Movement.PlayerSide) enemy.Add((u.Q, u.R));+ foreach (var h in c.SettlementHexes)+ if (s.Cities.ContainsKey(h.Id) && enemy.Contains((h.Q, h.R))) held.Add(h.Id);+ return held;+ }+/// <summary>R-MONEY-002: annual Money upkeep for the civilian places that exist at the start of step 7. Only completed/// projects and camp sites count. The six rates are explicit content design values; all are 0 in the MVP.</summary>public static double AnnualUpkeep(Content c, GameState s, MvpRules r)diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex fda649210..e1b52ed97 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -342,11 +342,12 @@ namespace Statecraft.Sim/// <summary>R-PROJ-003, step 5 of the turn (D-A6), after the pioneer work: in ascending id, each city project being built/// has one turn less to go. One that reaches 0 is built on <paramref name="next"/>, the turn's end date, and adds its/// kind's housing capacity, condition (kept from 0 to 1) and job slots to its city, once: a built project is never- /// advanced again.</summary>+ /// advanced again. R-CITY-010: a project in a city the enemy holds keeps its record as it is.</summary>public static void AdvanceCity(Content c, GameState s, DateTime next, List<Cause> why){var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop, the only loop TurnResolver runs this in- foreach (var p in s.CityProjects.Values.Where(x => x.BuiltOn == null).ToList())+ var held = Cities.Held(c, s);+ foreach (var p in s.CityProjects.Values.Where(x => x.BuiltOn == null && !held.Contains(x.City)).ToList()){// R-MIN-001, R-MIN-002 (D-H3; Q-MIN-1, Q-MIN-2): the office of the kind's system scales the turn of// progress the project gains this turn, with R-MIN-002's floor and carry as at the sites (Advance).