A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: the GDD loop refuses the legacy map actions (R-PROJ-004, refs #735) (#1255)
Berifa35e557d9f4
diff --git a/changelog.d/735-map-actions.md b/changelog.d/735-map-actions.mdnew file mode 100644index 000000000..20bb83c3e--- /dev/null+++ b/changelog.d/735-map-actions.md@@ -0,0 +1,5 @@+### Changed++- **The GDD game no longer builds the old transit camps and housing placements.** A map action is refused there with+ "Map actions are not part of this game: start a city project instead", and its Attention comes back; the info panel+ shows no Build camp or Build housing button. Housing and transit camps are city projects now (R-PROJ-004, #735).diff --git a/docs/mvp-checklist.md b/docs/mvp-checklist.mdindex efcc4a987..04b251aa1 100644--- a/docs/mvp-checklist.md+++ b/docs/mvp-checklist.md@@ -45,7 +45,7 @@ The design of record is [the GDD](GDD.md), especially "MVP scope 1948 to 1951".- [x] **Done: CHANGELOG entry "The GDD game has its twelve cities".** PR 1 twelve cities' start values (#821).- [x] **Done: CHANGELOG entry "The GDD game's immigrants arrive in all twelve cities".** PR 2 arrivals over the cities (#847).- [x] **Done: CHANGELOG entry "The GDD game's cities house every arriving immigrant".** PR 3 housing capacity, condition and overflow (#855; `docs/rules/mvp.md`, R-HOUSE-001 to R-HOUSE-004).-- [ ] **Open: #735.** PR 4 city projects. Housing types and industry are on `main` (#982; `docs/rules/mvp.md`, R-PROJ-001 to R-PROJ-003); R-PROJ-004 (map actions refused in the GDD loop) remains.+- [x] **Done: `docs/rules/mvp.md`, R-PROJ-001 to R-PROJ-004.** PR 4 city projects: housing types and industry (#982), and the legacy map actions refused in the GDD loop (#735).- [x] **Done: `docs/rules/mvp.md`, R-CRAFT-001, R-CRAFT-002 and R-CITY-009.** PR 5 the craftsman (#1049; #736).- [ ] **Open: #737.** PR 6 the winery. The local-resource rule is on `main` (#1025). **Decided (owner, 20 Oct 2026; #737):** the winery is in Rishon LeZion. Its content rows are the `winery` kind and Rishon LeZion's vineyards, flagged `to_verify`; the vineyards' source still waits for a person's check.- [x] **Done: `docs/rules/mvp.md`, R-OBJ-004, and `content/objectives.yaml`.** PR 7 objective 2, absorb immigrants: the condition is on `main` (#1019), followed by the sourced objective and card (#1055; #1039, #738).diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 414b915b6..070a68f17 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -78,14 +78,16 @@ R-HOUSE-004: In the GDD loop the base of the national `housing` indicator is the## City projects-A city project is built in a city (GDD "Cities and construction"; Phase 3 PR 4, #735). The kinds are in `content/projects.yaml`, every number a design value (Q-PROJ-1, Q-PROJ-5, owner, 15 October 2026, #375: "Take all recommendations", with agent-proposed values the owner may override): permanent housing (`housing`), the transit camp (`transit_camp`, D-D3, Q-HOUSE-3) and `industry`. The legacy map actions still run beside them; refusing them in the GDD loop (R-PROJ-004) is a separate PR. Until then a map action does not check the city projects, so one can still be placed on a project's hex; R-PROJ-004 removes that path.+A city project is built in a city (GDD "Cities and construction"; Phase 3 PR 4, #735). The kinds are in `content/projects.yaml`, every number a design value (Q-PROJ-1, Q-PROJ-5, owner, 15 October 2026, #375: "Take all recommendations", with agent-proposed values the owner may override): permanent housing (`housing`), the transit camp (`transit_camp`, D-D3, Q-HOUSE-3) and `industry`. They replace the legacy map actions, which the GDD loop refuses (R-PROJ-004).-R-PROJ-001: `StartProject(kind, city, q, r)` starts a city project of a `projects.yaml` kind for a city on hex (q, r). The Treasury pays the kind's cost at once and borrows what it lacks (Q-PROJ-1, Q-MONEY-3, "Allow borrowing"); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It needs no workers (Q-PROJ-3). It is refused, state and Attention unchanged, for an unknown kind or city; a locked kind that no event has unlocked (R-EFX-008); a transit camp without the `maabarot` policy at 0.5 or more (Q-HOUSE-3: the policy carries the camp's sourced date, and the map actions' 1 January 1950 window does not apply); a hex that is not land, is more than `map_action_max_distance` from the city's settlement hex, or holds a map-action placement or another city project, built or not (Q-PROJ-2); and once `map_actions_per_turn` projects were started this turn, counted nationally with the map actions (Q-PROJ-4). The legacy loop refuses it before charging Attention. Its Attention cost is `attention_cost.start_project` (1, Q-PROJ-5).+R-PROJ-001: `StartProject(kind, city, q, r)` starts a city project of a `projects.yaml` kind for a city on hex (q, r). The Treasury pays the kind's cost at once and borrows what it lacks (Q-PROJ-1, Q-MONEY-3, "Allow borrowing"); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It needs no workers (Q-PROJ-3). It is refused, state and Attention unchanged, for an unknown kind or city; a locked kind that no event has unlocked (R-EFX-008); a transit camp without the `maabarot` policy at 0.5 or more (Q-HOUSE-3: the policy carries the camp's sourced date, and the map actions' 1 January 1950 window does not apply); a hex that is not land, is more than `map_action_max_distance` from the city's settlement hex, or holds a map-action placement or another city project, built or not (Q-PROJ-2); and once `map_actions_per_turn` projects were started this turn, counted nationally (Q-PROJ-4; the GDD loop builds no map action, R-PROJ-004). The legacy loop refuses it before charging Attention. Its Attention cost is `attention_cost.start_project` (1, Q-PROJ-5).R-PROJ-002: `CancelProject(id)` removes a city project that is being built. The Money paid is not returned, and there are no people to return (D-A3, Q-PROJ-3). An unknown or built project is refused with the state unchanged. Its Attention cost is `attention_cost.cancel_project` (0.5, Q-PROJ-5).R-PROJ-003: On step 5 of the turn (D-A6), after the pioneer work, every city project being built has one turn of work less to go, in ascending id - `1 x m` of one at the system's office multiplier since the ministers (R-MIN-002), the fraction carried on the record as on R-SITE-003. One that reaches 0 is built on the turn's end date and adds its kind's `capacity` to the city's housing capacity, its `condition` to the city's housing condition (kept from 0 to 1, R-HOUSE-001) and its `job_slots` to the city's job slots, once: a built project keeps its record, with its hex, and is never advanced again. `GameState.CityProjects` is hashed as `cproj[...]` only when it has a project (R-LOOP-002).+R-PROJ-004: In the GDD loop a map action (`map_action`, the legacy transit camp or housing placement) is refused with the reason "Map actions are not part of this game: start a city project instead" and its Attention refunded, whatever its action or hex (plan PR 4, spec §1.4: "Placements become completed projects"). So no placement is built and none counts against R-PROJ-001's turn limit. The info panel shows no legacy Build button in the GDD loop. The legacy loop keeps the map actions until that code is deleted (D-E1). The pioneer orders from the map (`pioneer_work`, R-SITE-001) are not map actions.+R-PROJ-005: A specialised project is allowed only in a city that has its resource (D-D8: "A winery requires areas for grapes"; Phase 3 PR 6, #737). A `projects.yaml` kind may name a `requires:` resource; a `cities.yaml` city lists its `resources:`, each with an id and sources (a url and a checked date each), and may say what the sources leave open (`to_verify`). `StartProject` of such a kind in a city without the resource is refused like the other R-PROJ-001 refusals, before the hex checks; a city founded in play has no resources. The loader refuses a resource without sources and a kind whose resource no city has. Otherwise the kind is an ordinary city project (R-PROJ-003). The one such kind is the winery, which needs vineyards, in Rishon LeZion with its vineyards flagged `to_verify` (owner, 20 October 2026, on #737, as GDD v0.2 says; this replaces the 18 October default of Zikhron Ya'akov, which has no winery).## Trainingdiff --git a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs b/sim/Statecraft.Sim.Tests/CityProjectsTests.csindex b831575c7..2eeef8f46 100644--- a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs+++ b/sim/Statecraft.Sim.Tests/CityProjectsTests.cs@@ -121,18 +121,18 @@ public class CityProjectsTestsAssert.Empty(Step(c, r.State, new StartProject("industry", "town_a", 0, 1)).Rejected);}- // R-PROJ-001 (Q-PROJ-4): the cap counts map actions too, so two map actions leave no start for a project.+ // R-PROJ-004 with R-PROJ-001 (Q-PROJ-4): the GDD loop refuses map actions, so two of them use none of the turn's starts.[Fact]- public void TwoMapActionsUseUpTheTurnsStarts()+ public void RefusedMapActionsUseNoneOfTheTurnsStarts(){var c = Town();var s = New(c);s.Attention = 10;s.Date = new DateTime(1948, 6, 1); // map_actions_from in the fixturevar two = new Command[] { new MapAction("housing", 1, 1), new MapAction("housing", 2, 0) };- var r = Step(c, s, two.Append(new StartProject("industry", "town_a", 0, 1)).ToArray());- Assert.Equal("No more than 2 map actions and city projects in one turn", Assert.Single(r.Rejected).Reason);- Assert.Equal(Step(c, s, two).State.Hash(), r.State.Hash());+ var r = Step(c, s, two.Append(new StartProject("industry", "town_a", 0, 1)).Append(new StartProject("industry", "town_a", 2, 0)).ToArray());+ Assert.Equal(two, r.Rejected.Select(x => x.Command));+ Assert.Equal(2, r.State.CityProjects.Count);}// R-PROJ-001 (Q-MONEY-3): a short Treasury borrows, it is not refused.diff --git a/sim/Statecraft.Sim.Tests/FinalWaveTests.cs b/sim/Statecraft.Sim.Tests/FinalWaveTests.csindex 621917c13..f88010e20 100644--- a/sim/Statecraft.Sim.Tests/FinalWaveTests.cs+++ b/sim/Statecraft.Sim.Tests/FinalWaveTests.cs@@ -128,7 +128,7 @@ public class FinalWaveTests[Fact]public void MapActionReasonsAndCausesNameNoCoordinates(){- var c = Real;+ var c = RealContentTests.Legacy(); // R-PROJ-004: the map actions build only in the legacy loopvar s = GoldenRun.Play(c, new DateTime(1950, 6, 15));var sea = c.Hexes.First(h => !h.Land);Assert.Equal("This hex is not land", MapActions.Check(c, s, MapActions.Housing, sea.Q, sea.R));diff --git a/sim/Statecraft.Sim.Tests/MapActionTests.cs b/sim/Statecraft.Sim.Tests/MapActionTests.csindex 6f9b30186..26fbc8c9e 100644--- a/sim/Statecraft.Sim.Tests/MapActionTests.cs+++ b/sim/Statecraft.Sim.Tests/MapActionTests.cs@@ -89,6 +89,29 @@ public class MapActionTestsAssert.Equal("Transit camps and housing projects can be placed from 1 June 1948", reason.Text);}+ /// <summary>R-PROJ-004: the GDD loop refuses both legacy map actions with a reason, on hexes the legacy loop accepts, and+ /// refunds their Attention: the turn ends as if they had not been ordered. City projects replace them (R-PROJ-001).</summary>+ [Fact]+ public void TheGddLoopRefusesMapActions()+ {+ var c = ContentLoader.Load(Fixture.Write(Fixture.Gdd()));+ Assert.True(c.IsGdd);+ var s = Simulation.NewGame(c, 42, Mode.Historical);+ s.Date = new DateTime(1948, 6, 1); // map_actions_from in the fixture+ s.Policies["maabarot"] = 1.0;+ Assert.Null(MapActions.Check(C, Ready(), "transit_camp", 2, 0)); // the legacy loop accepts both here+ Assert.Null(MapActions.Check(C, Ready(), "housing", 1, 1));+ var reason = MapActions.CheckReason(c, s, "housing", 1, 1);+ Assert.NotNull(reason);+ Assert.Equal("gdd_loop", reason!.Kind);+ Assert.Empty(reason.Values);+ Assert.Equal("Map actions are not part of this game: start a city project instead", reason.Text);+ var r = Simulation.Step(c, s, new Command[] { new MapAction("transit_camp", 2, 0), new MapAction("housing", 1, 1) });+ Assert.Equal(new[] { reason.Text, reason.Text }, r.Rejected.Select(x => x.Reason));+ Assert.Empty(r.State.Placements);+ Assert.Equal(Simulation.Step(c, s, new Command[0]).State.Hash(), r.State.Hash()); // Attention refunded, nothing built+ }+[Fact]public void TransitCampsNeedTheMaabarotPolicy(){@@ -172,7 +195,7 @@ public class MapActionTests[Fact]public void JaffaAndTelAvivShareAHexAndBuildingThereWorks(){- var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var c = RealContentTests.Legacy();var jaffa = c.SettlementHexes.Single(x => x.Id == "jaffa");var tlv = c.SettlementHexes.Single(x => x.Id == "tel_aviv");Assert.Equal((-3, 19), (tlv.Q, tlv.R));@@ -214,7 +237,7 @@ public class MapActionTests[Fact]public void RealContentOpensCampsWithTheMaabarotDecision(){- var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var c = RealContentTests.Legacy();var s = GoldenRun.Play(c, new DateTime(1950, 9, 1));var tlv = c.SettlementHexes.Single(x => x.Id == "tel_aviv");Assert.Null(MapActions.Check(c, s, "transit_camp", tlv.Q, tlv.R));diff --git a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs b/sim/Statecraft.Sim.Tests/PlayerTextTests.csindex d9469eba2..30ae7bc02 100644--- a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs+++ b/sim/Statecraft.Sim.Tests/PlayerTextTests.cs@@ -56,7 +56,7 @@ public class PlayerTextTests[Fact]public void TheMapActionStartDateIsShownInTheDayMonthYearFormat(){- var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var c = RealContentTests.Legacy();var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);var reason = MapActions.Check(c, s, MapActions.Housing, 0, 0);Assert.Equal("Transit camps and housing projects can be placed from 1 January 1950", reason);@@ -193,7 +193,8 @@ public class PlayerTextTestshousing |= r.Why.Any(w => w.System == "map" && w.Target == MapActions.Housing);s = r.State;}- Assert.True(budget && camp && housing, $"the script ran every command (budget {budget}, camp {camp}, housing {housing})");+ // R-PROJ-004: the GDD loop refuses every map action, so only legacy content builds a camp and housing.+ Assert.True(budget && (c.IsGdd || camp && housing), $"the script ran every command (budget {budget}, camp {camp}, housing {housing})");Assert.True(appointable.SetEquals(appointedOffices), $"every appointable office was filled: missing {string.Join(", ", appointable.Except(appointedOffices))}");Assert.True(c.Policies.All(p => policiesSet.Contains(p.Id)), $"every policy was set: missing {string.Join(", ", c.Policies.Select(p => p.Id).Except(policiesSet))}");Assert.Contains(causes, w => w.Message.StartsWith("Borrowed ", StringComparison.Ordinal));@@ -258,7 +259,8 @@ public class PlayerTextTestsvar s = Simulation.NewGame(Real, 1, Mode.Historical);var why = new List<Cause>();SecuritySystem.SetMobilization(Real, s, 0, why); // below the floor: the ladder message- var texts = why.Select(w => w.Message).Append(MapActions.Check(Real, s, MapActions.Housing, 0, 0)!).ToList(); // before map actions open+ var legacy = RealContentTests.Legacy(); // R-PROJ-004: only the legacy loop still checks a map action's dates+ var texts = why.Select(w => w.Message).Append(MapActions.Check(legacy, Simulation.NewGame(legacy, 1, Mode.Historical), MapActions.Housing, 0, 0)!).ToList(); // before map actions openforeach (var phrase in SimPhrases) Assert.Contains(texts, t => t.Contains(phrase));}diff --git a/sim/Statecraft.Sim.Tests/RealContentTests.cs b/sim/Statecraft.Sim.Tests/RealContentTests.csindex aee8910c2..66d941463 100644--- a/sim/Statecraft.Sim.Tests/RealContentTests.cs+++ b/sim/Statecraft.Sim.Tests/RealContentTests.cs@@ -15,6 +15,24 @@ public class RealContentTestsreturn Path.Combine(dir?.FullName ?? throw new DirectoryNotFoundException("content/people.yaml not found above test dir"), "content");}+ /// <summary>The real content with the GDD loop switch taken out of eras.yaml: the legacy loop, where the map actions+ /// still run (R-PROJ-004 refuses them in the GDD loop; D-E1 keeps the legacy code until it is deleted). Unity's tests+ /// use the same content (SimBridgeGddTests.Legacy).</summary>+ public static Content Legacy()+ {+ const string loop = " systems: { loop: gdd }\n";+ var dir = ContentRoot();+ Assert.Contains(loop, File.ReadAllText(Path.Combine(dir, "eras.yaml"))); // the switch to take out+ var events = Directory.GetFiles(Path.Combine(dir, "events"), "*.yaml").Select(f => "events/" + Path.GetFileName(f)).ToList();+ return ContentLoader.Load(rel =>+ {+ var path = Path.Combine(dir, rel);+ if (!File.Exists(path)) return null;+ var text = File.ReadAllText(path);+ return rel == "eras.yaml" ? text.Replace(loop, "") : text;+ }, events);+ }+static readonly Content C = ContentLoader.Load(ContentRoot());static readonly DateTime Checked = new DateTime(2026, 10, 9);diff --git a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs b/sim/Statecraft.Sim.Tests/SliceSmokeTests.csindex dcc86a566..b48a0ba2e 100644--- a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs+++ b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs@@ -256,7 +256,8 @@ public class SliceSmokeTestsAssertClean("player", run, Play(Real, Player, reload: false, guard: null));// Attention runs out some turns: the UI refuses those extra orders at queue time, which is not a sim refusal.Assert.True(run.Orders > run.Turns, $"{run.Orders} orders in {run.Turns} turns");- var uiKinds = new[] { "choose_event_option", "appoint", "allocate_budget", "set_mobilization", "map_action", "security_order" };+ // No map_action: the GDD loop refuses it (R-PROJ-004) and the info panel offers no legacy Build button there.+ var uiKinds = new[] { "choose_event_option", "appoint", "allocate_budget", "set_mobilization", "security_order" };Assert.Empty(uiKinds.Except(run.Carried)); // every order a UI screen can queue was carried outAssert.True(clock.Elapsed < TimeSpan.FromMinutes(1), $"took {clock.Elapsed}");}diff --git a/sim/Statecraft.Sim/MapActions.cs b/sim/Statecraft.Sim/MapActions.csindex 9cce1cfc9..120d34f2e 100644--- a/sim/Statecraft.Sim/MapActions.cs+++ b/sim/Statecraft.Sim/MapActions.cs@@ -53,6 +53,9 @@ namespace Statecraft.Sim/// <summary>Null when the action may be placed, else a stable kind and invariant values for a UI, plus English text.</summary>public static MapActionReason? CheckReason(Content c, GameState s, string action, int q, int r){+ // R-PROJ-004: the GDD loop builds with city projects (R-PROJ-001), so it refuses every map action, before the id is+ // read; Simulation refunds the Attention of a refused order. The legacy loop keeps the checks below (D-E1).+ if (c.IsGdd) return new MapActionReason("gdd_loop", "Map actions are not part of this game: start a city project instead");// No id in either reason: a command from an old save or a stale UI may name an action this content lacks; the// replay refuses it here, before anything is formatted, so a placement always has its rule (fix round 3, m-6).if (!Actions.Contains(action)) return new MapActionReason("unknown", "There is no such map action");diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex 94490b0d7..d582f1fb3 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -299,12 +299,14 @@ namespace Statecraft.Game.UIplacement.text = queued != null ? text.Format("info.queued", PlayerText.Capitalised(text["info.map_action." + queued.Action])): here != null ? text.Format("info.built", PlayerText.Capitalised(text["info.map_action." + here.Action]),Control1948.LineDateText(here.Date.ToString("yyyy-MM", System.Globalization.CultureInfo.InvariantCulture), k => text[k])) : ""; // PlayerText.Month is always English (#701)- var campReason = MapActions.CheckReason(c, s, MapActions.TransitCamp, q, r);- var housingReason = MapActions.CheckReason(c, s, MapActions.Housing, q, r);+ // The GDD loop refuses every map action and builds with city projects instead (R-PROJ-004): it has no map-action+ // button and no reason, so its refusal is not asked for (the UI has no words for it).+ var campReason = c.IsGdd ? null : MapActions.CheckReason(c, s, MapActions.TransitCamp, q, r);+ var housingReason = c.IsGdd ? null : MapActions.CheckReason(c, s, MapActions.Housing, q, r);var campWhy = campReason == null ? null : MapActionReasonText(campReason, text);var housingWhy = housingReason == null ? null : MapActionReasonText(housingReason, text);// eras.yaml systems.map_actions (#58): an action the era does not allow has no button and no reason- var allowed = c.SystemsAt(s.Date).MapActions;+ var allowed = c.IsGdd ? new System.Collections.Generic.List<string>() : c.SystemsAt(s.Date).MapActions;bool campOn = allowed.Contains(MapActions.TransitCamp), housingOn = allowed.Contains(MapActions.Housing);// Both refused for the same reason (in 1948: "...can be placed from 1 January 1950"; or not land, too far, the// turn's cap): neither can be ordered on this hex now, so the reason is said once and no button shows (#398).diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex ba368e0ef..8adf5c89b 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -586,7 +586,7 @@ public class GameSceneTestspublic void PlacementsAreRedrawnOnlyWhenTheyChange(){var root = Boot();- var c = Inputs.Content;+ var c = SimBridgeGddTests.Legacy; // the map actions build only in the legacy loop (R-PROJ-004)var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);while (g.State.Date < new DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(c, g.State));var bridge = root.Bridge!;diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.csindex 2aff82b94..c4eb9b8f2 100644--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs@@ -305,12 +305,13 @@ public class InfoPanelLayoutTestspublic void OneSharedRefusalShowsOnceWithoutButtons(){using var ui = new UiTestKit();- var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ var legacy = SimBridgeGddTests.Legacy; // the GDD loop shows no map-action button or reason (R-PROJ-004)+ var bridge = new SimBridge(GameSession.New(legacy, GoldenRun.Seed, Mode.Historical), Text);var info = new InfoPanelPresenter(ui.Root, bridge, Text, Names());- var tlv = C.SettlementHexes.Single(s => s.Id == "tel_aviv");+ var tlv = legacy.SettlementHexes.Single(s => s.Id == "tel_aviv");info.Show(tlv.Q, tlv.R);- var why = MapActions.Check(C, bridge.State, MapActions.TransitCamp, tlv.Q, tlv.R);- Assert.AreEqual(why, MapActions.Check(C, bridge.State, MapActions.Housing, tlv.Q, tlv.R), "precondition: one shared reason in 1948");+ var why = MapActions.Check(legacy, bridge.State, MapActions.TransitCamp, tlv.Q, tlv.R);+ Assert.AreEqual(why, MapActions.Check(legacy, bridge.State, MapActions.Housing, tlv.Q, tlv.R), "precondition: one shared reason in 1948");Assert.AreEqual(why, ui.Q<Label>("info-reason").text, "the reason, once");foreach (var b in new[] { "build-camp", "build-housing" }){diff --git a/unity/Assets/Tests/EditMode/MapActionUiTests.cs b/unity/Assets/Tests/EditMode/MapActionUiTests.csindex 7e403f806..d4c3cdab0 100644--- a/unity/Assets/Tests/EditMode/MapActionUiTests.cs+++ b/unity/Assets/Tests/EditMode/MapActionUiTests.cs@@ -14,7 +14,8 @@ using UnityEngine.UIElements;public class MapActionUiTests{- static readonly Content C = ContentLoader.Load(Paths.Content);+ // The legacy loop: the GDD loop refuses every map action and offers no Build button (R-PROJ-004).+ static readonly Content C = SimBridgeGddTests.Legacy;static readonly HexFile Hexes = MapBuilder.LoadHexes(Path.Combine(Paths.Content, "map", "hexes.json"));static readonly System.Collections.Generic.List<Settlement> Towns =SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", SettlementPlacer.DefaultFileName)));@@ -478,12 +479,34 @@ public class MapActionUiTestsAssert.AreEqual(0, clicks);}+ /// <summary>R-PROJ-004: the GDD game (the real content) offers no legacy Build button and no map-action reason, before+ /// 1950 or after it: the sim refuses every map action there, and city projects replace them.</summary>+ [Test]+ public void TheGddLoopShowsNoMapActionButtons()+ {+ var gdd = ContentLoader.Load(Paths.Content);+ Assert.IsTrue(gdd.IsGdd);+ var g = GameSession.New(gdd, GoldenRun.Seed, Mode.Historical);+ using var ui = new UiTestKit();+ var info = new InfoPanelPresenter(ui.Root, new SimBridge(g, Text), Text, Towns.ToDictionary(t => t.Id, t => t.Name));+ var tlv = gdd.SettlementHexes.Single(s => s.Id == "tel_aviv");+ foreach (var date in new[] { new DateTime(1949, 6, 1), new DateTime(1950, 8, 1) })+ {+ while (g.State.Date < date) g.Step(HistoricalAI.Commands(gdd, g.State));+ info.Show(tlv.Q, tlv.R);+ foreach (var b in new[] { "build-camp", "build-housing" })+ Assert.AreEqual(DisplayStyle.None, ui.Q<Button>(b).style.display.value, $"{b} on {date:yyyy-MM-dd}");+ Assert.AreEqual("", ui.Q<Label>("info-reason").text, $"no map-action reason on {date:yyyy-MM-dd}");+ }+ info.Dispose();+ }+/// <summary>eras.yaml systems.map_actions (#58): an action the era does not allow has no button and no reason; with/// both allowed both show. Played on a copy of the content, switching the list between renders.</summary>[Test]public void OnlyTheErasMapActionsHaveButtons(){- var c = ContentLoader.Load(Paths.Content);+ var c = SimBridgeGddTests.LoadLegacy();var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);while (g.State.Date < new DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(c, g.State));using var ui = new UiTestKit();diff --git a/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs b/unity/Assets/Tests/EditMode/SimBridgeGddTests.csindex e5022d688..50e12dcea 100644--- a/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs+++ b/unity/Assets/Tests/EditMode/SimBridgeGddTests.cs@@ -16,7 +16,8 @@ public class SimBridgeGddTests/// <summary>The legacy loop: the real content without eras.yaml's loop switch (the real game runs gdd since the cutover).</summary>internal static readonly Content Legacy = LoadLegacy();- static Content LoadLegacy()+ /// <summary>A fresh copy of the legacy content, for a test that changes it.</summary>+ internal static Content LoadLegacy(){const string loop = " systems: { loop: gdd }\n";var dir = Paths.Content;diff --git a/unity/Assets/Tests/EditMode/StartScreenTests.cs b/unity/Assets/Tests/EditMode/StartScreenTests.csindex bf7602ba6..a92ebd87f 100644--- a/unity/Assets/Tests/EditMode/StartScreenTests.cs+++ b/unity/Assets/Tests/EditMode/StartScreenTests.cs@@ -449,23 +449,24 @@ public class StartScreenTests[UnityTest]public IEnumerator ASaveFrom1950KeepsTheLiveHudOutOfReach(){- var g = GameSession.New(C, 9, Mode.Historical);- while (g.State.Date < new DateTime(1950, 8, 1) || g.State.PendingEvents.Count == 0) g.Step(HistoricalAI.Commands(C, g.State));+ var legacy = SimBridgeGddTests.Legacy; // the live Build buttons are the legacy loop's (R-PROJ-004)+ var g = GameSession.New(legacy, 9, Mode.Historical);+ while (g.State.Date < new DateTime(1950, 8, 1) || g.State.PendingEvents.Count == 0) g.Step(HistoricalAI.Commands(legacy, g.State));var store = TempStore();store.WriteAutosave(g.Save.Write());using var ui = new RenderedUi();- var bridge = new SimBridge(GameStart.Begin(C, store, () => 4UL, new List<string>(), Text, out var resumed), Text);+ var bridge = new SimBridge(GameStart.Begin(legacy, store, () => 4UL, new List<string>(), Text, out var resumed), Text);var owned = new List<IDisposable>();try{ui.Root.Q("root").RemoveFromClassList("loading");owned.Add(new HudPresenter(ui.Root, bridge, Text));owned.Add(new ScreenNav(ui.Root));- var info = new InfoPanelPresenter(ui.Root, bridge, Text, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)); owned.Add(info);+ var info = new InfoPanelPresenter(ui.Root, bridge, Text, legacy.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)); owned.Add(info);var card = new EventCardPresenter(ui.Root, bridge, Text, null); owned.Add(card);var toast = new ToastPresenter(ui.Root, bridge, Text); owned.Add(toast);var newGame = new NewGamePresenter(ui.Root, bridge, store, toast, Text, () => 5UL); owned.Add(newGame);- var tlv = C.SettlementHexes.Single(x => x.Id == "tel_aviv");+ var tlv = legacy.SettlementHexes.Single(x => x.Id == "tel_aviv");info.Show(tlv.Q, tlv.R);var start = new StartScreenPresenter(ui.Root, newGame, resumed); owned.Add(start);start.Show();diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.csindex f8d472b42..77cb4761e 100644--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs@@ -94,15 +94,16 @@ public class UiLayoutTestsvar root = doc.rootVisualElement;// August 1950, when the map actions are open (in 1948 one shared refusal hides both build buttons, #398), so the// build button below is really on the panel before a screen covers it.- var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);- while (g.State.Date < new System.DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(C, g.State));+ var legacy = SimBridgeGddTests.Legacy; // the live Build buttons are the legacy loop's (R-PROJ-004)+ var g = GameSession.New(legacy, GoldenRun.Seed, Mode.Historical);+ while (g.State.Date < new System.DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(legacy, g.State));var bridge = new SimBridge(g, Text);- var info = new InfoPanelPresenter(root, bridge, Text, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id));+ var info = new InfoPanelPresenter(root, bridge, Text, legacy.SettlementHexes.ToDictionary(x => x.Id, x => x.Id));var nav = new ScreenNav(root);try{root.Q("root").RemoveFromClassList("loading");- var tlv = C.SettlementHexes.Single(x => x.Id == "tel_aviv");+ var tlv = legacy.SettlementHexes.Single(x => x.Id == "tel_aviv");info.Show(tlv.Q, tlv.R);for (int i = 0; i < 4; i++) yield return null;var panel = root.Q("info-panel");@@ -155,8 +156,9 @@ public class UiLayoutTestsdoc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);go.SetActive(true);var root = doc.rootVisualElement;- var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);- while (g.State.Date < new System.DateTime(1950, 8, 1) || g.State.PendingEvents.Count == 0) g.Step(HistoricalAI.Commands(C, g.State));+ var legacy = SimBridgeGddTests.Legacy; // the live Build buttons are the legacy loop's (R-PROJ-004)+ var g = GameSession.New(legacy, GoldenRun.Seed, Mode.Historical);+ while (g.State.Date < new System.DateTime(1950, 8, 1) || g.State.PendingEvents.Count == 0) g.Step(HistoricalAI.Commands(legacy, g.State));var bridge = new SimBridge(g, Text);var owned = new List<System.IDisposable>();void Resize(int w, int h) { var old = rt; rt = new RenderTexture(w, h, 0); ps.targetTexture = rt; old.Release(); Object.DestroyImmediate(old); }@@ -165,9 +167,9 @@ public class UiLayoutTestsroot.Q("root").RemoveFromClassList("loading");owned.Add(new HudPresenter(root, bridge, Text));var nav = new ScreenNav(root); owned.Add(nav);- var info = new InfoPanelPresenter(root, bridge, Text, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)); owned.Add(info);+ var info = new InfoPanelPresenter(root, bridge, Text, legacy.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)); owned.Add(info);var card = new EventCardPresenter(root, bridge, Text, null); owned.Add(card);- var tlv = C.SettlementHexes.Single(x => x.Id == "tel_aviv");+ var tlv = legacy.SettlementHexes.Single(x => x.Id == "tel_aviv");info.Show(tlv.Q, tlv.R);for (int i = 0; i < 4; i++) yield return null;Assert.IsNotNull(root.Q("event-options").Q<Button>(), "precondition: an event's options are shown");