A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: a housing repair off its city's hex does not split the shared refusal (Refs #1700) (#2498)
Eyal Golanec3c48836ecc
diff --git a/changelog.d/1700-repair-shared-refusal.md b/changelog.d/1700-repair-shared-refusal.mdnew file mode 100644index 000000000..ea33df26d--- /dev/null+++ b/changelog.d/1700-repair-shared-refusal.md@@ -0,0 +1,4 @@+- GDD 0.3 housing repair on a hex off its city (Refs #1700): under the gdd-0.3 ruleset, on a hex where every other+ city project is refused for the same reason, the hex panel again says that reason once instead of one line per+ kind; the housing repair, which is only ever done on its city's own hex, no longer splits it. The current game+ (gdd-0.1) is unchanged.diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csindex ad18362f5..35e577322 100644--- a/unity/Assets/Scripts/UI/GddHexPanel.cs+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -377,8 +377,9 @@ namespace Statecraft.Game.UIvar words = refusals.Select(x => x == null ? null : ReasonText(x, text, c, townName)).ToList();// Every kind refused for one reason (not land, a placement there, the turn's limit): said once, with no buttons,// as the map actions do (#398). A kind this city lacks the resource for (R-PROJ-005: the winery outside Rishon- // LeZion) does not split that line into one per kind.- var shared = words.Where((x, i) => refusals[i]?.Kind != "no_resource").ToList();+ // LeZion) does not split that line into one per kind, nor does the gdd-0.3 housing repair off its city's own hex+ // (R-HOUSE-006: repair_city_hex comes before the shared reasons, so it would hide them on every other hex).+ var shared = words.Where((x, i) => refusals[i]?.Kind != "no_resource" && refusals[i]?.Kind != "repair_city_hex").ToList();if (words.All(x => x != null) && shared.Count > 0 && shared.Distinct().Count() == 1) { Line(list, "city-project-reason", shared[0]!); return; }// A kind the sim refuses shows its reason alone, which names the kind (no disabled Build above it: one line, not two).for (int i = 0; i < c.ProjectKinds.Count; i++)diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs b/unity/Assets/Tests/EditMode/CityProjectPanelTests.csindex 02f7dd10a..5e58e535f 100644--- a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs@@ -547,6 +547,39 @@ public class WorkshopPanelTestsAssert.IsNull(ui.Root.Q("city-project-housing"), "refused for all alike: no buttons");}+ // R-HOUSE-006 (#2409): off its city's own hex a housing repair is refused as repair_city_hex, a check that comes before+ // the placement and both turn limits. So on a hex where every other kind is refused for one of those reasons (the+ // winery's missing vineyards aside), the repair's own reason must not split the line: the shared reason is said once,+ // with no buttons and no line for the repair. gdd-0.1 (CityProjectPanelTests) has no repair kind, so this runs gdd-0.3.+ [Test]+ public void ARepairOffItsCitysHexDoesNotSplitTheSharedRefusal([Values] bool hebrew, [Values("placement", "turn_cap")] string why)+ {+ var t = hebrew ? He : En;+ var (q, r) = Hex(C03);+ var g = GameSession.New(C03, GoldenRun.Seed, Mode.Historical);+ g.State.Policies[MapActions.MaabarotPolicy] = 1; // so the transit camp is refused for the shared reason too+ if (why == "placement") g.State.Placements.Add(new Placement(MapActions.Housing, q, r, g.State.Date));+ else { g.State.MapActionsTurnDate = g.State.Date; g.State.MapActionsThisTurn = C03.RulesAt(g.State.Date).MapActionsPerTurn; }+ var bridge = new SimBridge(g, t) { TownNamesHe = TownsHe };+ var s0 = bridge.State;+ Assert.IsTrue(C03.ProjectKinds.Any(k => k.Id == Projects.HousingRepair), "precondition: gdd-0.3 has the housing repair kind");+ Assert.AreEqual("repair_city_hex", Projects.CheckCityReason(C03, s0, Projects.HousingRepair, City, q, r)?.Kind,+ "precondition: the sim refuses the repair off Haifa's own hex");+ Assert.AreEqual(why == "placement" ? "occupied" : "turn_cap", Projects.CheckCityReason(C03, s0, "housing", City, q, r)?.Kind,+ "precondition: the sim refuses the other kinds for the shared reason");+ var expected = why == "placement"+ ? t.Format("info.map_action_reason.occupied", t["info.map_action.housing"])+ : t.Format("city.project_reason.turn_cap", C03.RulesAt(s0.Date).MapActionsPerTurn);+ using var ui = new UiTestKit();+ using var panel = Panel(ui, bridge, t);+ panel.Show(q, r);+ Assert.AreEqual(expected, ui.Q<Label>("city-project-reason").text, "the shared reason, said once");+ Assert.IsNull(ui.Root.Q("city-project-" + Projects.HousingRepair + "-reason"), "the repair's own reason does not split the line");+ Assert.IsNull(ui.Root.Q("city-project-housing-reason"));+ Assert.IsNull(ui.Root.Q("city-project-housing"), "refused for all alike: no buttons");+ if (!hebrew) Assert.AreEqual(Projects.CheckCity(C03, s0, "housing", City, q, r), expected, "the English is the sim's own sentence");+ }+// R-ARMS-006, R-ARMS-007, R-CITY-010: a staffed workshop's cycle under way (staffed months of workshop.staffed_turns and// the Money paid), the pause while the enemy holds its city, and the last turn's pauses for its city as the Why screen// words them; with no cycle, the next cycle's price at its worker's tier.