Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

UI: city projects in the info panel (Fixes #1122, refs #739) (#1150)

Beri0deb411625ed
diff --git a/changelog.d/ui-city-projects-1122.md b/changelog.d/ui-city-projects-1122.md
new file mode 100644
index 000000000..c1ae51941
--- /dev/null
+++ b/changelog.d/ui-city-projects-1122.md
@@ -0,0 +1,8 @@
+- City projects in the info panel: on a hex a city can build on, the panel names the city that builds (the player picks
+ when several are in reach) and offers Build for each `projects.yaml` kind with its cost and turns, or shows the sim's
+ own refusal in English or Hebrew; a project there shows its turns left and Cancel, or its finishing day. The turns are
+ the sim's forecast at the kind's minister multiplier (`Projects.CityTurnsToBuild`). The sim adds `Projects.CitiesFor`
+ (cities in reach, by the one range check) and `Projects.CheckCityReason` (structured refusals, a locked kind included;
+ `CheckCity`'s English and order unchanged), and the kinds gain draft Hebrew names for native review (#564; refs #1122).
+- On a city's own hex, on a stacked bar or a short window, the project part folds behind one "City projects (N)"
+ toggle that opens and closes the list, so the panel stays clear of the left column (owner ruling on #1150).
diff --git a/content/projects.yaml b/content/projects.yaml
index 6454cc0cf..2b780b92a 100644
--- a/content/projects.yaml
+++ b/content/projects.yaml
@@ -15,8 +15,11 @@
# winery: the plan's Q-SPEC-2 values (PR 6: industry's IL 2m and 6 turns, and 10 job slots, more than industry's 5).
# It needs vineyards (`requires:`, R-PROJ-005), which only Rishon LeZion has (cities.yaml; owner, 20 October 2026, #737).
# name: the phrase the player reads in a sentence ("a transit camp").
+# name_he: the Hebrew UI's noun for the kind (#1122, owner ruling 3), optional: without it the Hebrew UI shows `name`.
+# Draft wording, not a native-language approval: name_he_review: agent-checked until a native speaker reviews it.
+# For the native reviewer (#564).
projects:
- - { id: housing, name: a housing project, cost: 6, turns: 6, capacity: 5, condition: 0.03, job_slots: 0 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3, D-D3; Q-PROJ-1, Q-HOUSE-3: permanent housing)
- - { id: transit_camp, name: a transit camp, cost: 1.5, turns: 1, capacity: 5, condition: -0.02, job_slots: 0 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3, D-D3; Q-PROJ-1, Q-HOUSE-3: the low-condition type)
- - { id: industry, name: an industry project, cost: 2, turns: 6, capacity: 0, condition: 0, job_slots: 5 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3; Q-PROJ-1: job slots)
+ - { id: housing, name: a housing project, name_he: מיזם דיור, name_he_review: agent-checked, cost: 6, turns: 6, capacity: 5, condition: 0.03, job_slots: 0 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3, D-D3; Q-PROJ-1, Q-HOUSE-3: permanent housing)
+ - { id: transit_camp, name: a transit camp, name_he: מעברה, name_he_review: agent-checked, cost: 1.5, turns: 1, capacity: 5, condition: -0.02, job_slots: 0 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3, D-D3; Q-PROJ-1, Q-HOUSE-3: the low-condition type)
+ - { id: industry, name: an industry project, name_he: מיזם תעשייה, name_he_review: agent-checked, cost: 2, turns: 6, capacity: 0, condition: 0, job_slots: 5 } # DESIGN VALUE: owner-set balance, not a historical figure (D-C6, D-A3; Q-PROJ-1: job slots)
- { id: winery, name: a winery, cost: 2, turns: 6, capacity: 0, condition: 0, job_slots: 10, requires: vineyards } # DESIGN VALUE: owner-set balance, not a historical figure (D-D8, D-C6; Q-SPEC-2: the specialised industry)
diff --git a/docs/gdd/city-projects.md b/docs/gdd/city-projects.md
index 296cd4ae6..c4b9a3694 100644
--- a/docs/gdd/city-projects.md
+++ b/docs/gdd/city-projects.md
@@ -15,10 +15,11 @@ As a player of the MVP, I want to build housing and industry in a city over seve
- `CancelProject(id)` stops a project being built; the Money is not returned. It costs 0.5 Attention (R-PROJ-002).
- Construction resolves on the turn's construction step, after the pioneer work; the turn of the order counts. A finished project adds its capacity, condition and job slots once (R-PROJ-003).
- A specialised project, such as the winery, needs a local resource: it starts only in a city whose `cities.yaml` row lists that resource with its sources, and otherwise it is an ordinary project. The winery needs vineyards, adds 10 units of job slots for IL 2m over 6 turns (design values, `Q-SPEC-2`) and goes in Rishon LeZion, its vineyards flagged `to_verify` (owner, 20 October 2026, on #737 [S6], replacing the 18 October default of Zikhron Ya'akov [S5]; R-PROJ-005).
+- The info panel offers the projects on any hex a city can build on (#1122): the city that builds (the player picks when several are in reach, `Projects.CitiesFor`), Build for each kind with its cost and turns, or the sim's own refusal (`Projects.CheckCityReason`) in English or Hebrew; a project there shows its turns left and Cancel, or the day it was finished.
## Data touched
-- `content/projects.yaml` (new; design values), read only in the GDD loop.
+- `content/projects.yaml` (new; design values), read only in the GDD loop; an optional draft Hebrew `name_he` per kind, pending native review (#564).
- `rules.yaml` `attention_cost.start_project` and `cancel_project`.
- `GameState.CityProjects`, hashed as `cproj[...]` when there are some; the map actions' per-turn counter; the city's capacity, condition and job slots; `Treasury` and `Debt`.
- Save files: the `project KIND CITY Q R` and `unproject ID` lines. Scenarios: `start_project` and `cancel_project`.
diff --git a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs b/sim/Statecraft.Sim.Tests/CityProjectsTests.cs
index 4561a82cf..b831575c7 100644
--- a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs
+++ b/sim/Statecraft.Sim.Tests/CityProjectsTests.cs
@@ -281,4 +281,92 @@ public class CityProjectsTests
s.CityProjects.Add(9, new CityProject(9, "industry", "town_a", 2, 0, 1)); // one at a time
Assert.DoesNotContain(ReferencePlayer.Commands(c, s), x => x is StartProject);
}
+
+ /// <summary>town_a on (1, 0) and town_b on (1, 1), next to it, both with the fixture's kinds; town_b has vineyards and the
+ /// winery needs them (R-PROJ-005). Fixture values, not the game's.</summary>
+ static Content Neighbours(bool lockIndustry = false) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["map/settlement_hexes.yaml"] = "settlements:\n - { id: town_a, q: 1, r: 0 }\n - { id: town_b, q: 1, r: 1 }\n",
+ ["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"]
+ + " - { id: town_b, name: Town B, lon: 34.42, lat: 33.28, type: town, founded: 1900, pre_modern: false }\n",
+ ["cities.yaml"] = "cities:\n" + Fixture.City("town_a", 12, 8, 10, 6)
+ + Fixture.City("town_b", 5, 2, 2, 1).Replace("facilities: [] }", Fixture.Vineyards + " }"),
+ ["projects.yaml"] = (lockIndustry ? Fixture.GddProjects.Replace("job_slots: 3 }", "job_slots: 3, locked: true }") : Fixture.GddProjects) + Fixture.Winery,
+ })));
+
+ // #1122 (owner ruling 1): the cities whose settlement hex is within map_action_max_distance of the hex, by CheckCity's own
+ // range check, nearest first and then in ordinal id order; none for a hex out of every city's reach.
+ [Fact]
+ public void CitiesForListsTheCitiesInReachNearestFirst()
+ {
+ var c = Neighbours();
+ var s = New(c);
+ Assert.Equal(new[] { "town_a" }, Projects.CitiesFor(c, s, 0, 0));
+ Assert.Equal(new[] { "town_a", "town_b" }, Projects.CitiesFor(c, s, 1, 0)); // its own hex first
+ Assert.Equal(new[] { "town_b", "town_a" }, Projects.CitiesFor(c, s, 1, 1));
+ Assert.Equal(new[] { "town_a", "town_b" }, Projects.CitiesFor(c, s, 2, 0)); // a tie: ordinal id order
+ Assert.Empty(Projects.CitiesFor(c, s, 5, 0));
+ var land = new[] { (1, 0), (2, 0), (1, 1), (3, 0) };
+ Assert.All(land, x => Assert.True(c.HexAt(x.Item1, x.Item2)?.Land, "precondition: land, so the validator gets to its distance check"));
+ Assert.Empty(Projects.CitiesFor(c, s, 3, 0)); // so both answers are compared below
+ foreach (var (q, r) in land)
+ foreach (var city in s.Cities.Keys) // the same answer as the validator's distance refusal, never a second rule
+ Assert.Equal(Projects.CitiesFor(c, s, q, r).Contains(city), Projects.CheckCityReason(c, s, "industry", city, q, r)?.Kind != "too_far");
+ }
+
+ // #1122 (owner ruling 2): every refusal has a stable kind and invariant values for the UI, and the same English text
+ // CheckCity returns.
+ [Theory]
+ [InlineData("unknown kind", "unknown_kind", "")]
+ [InlineData("unknown city", "unknown_city", "")]
+ [InlineData("a locked kind", "locked", "industry")]
+ [InlineData("camp without the policy", "maabarot_policy", "")]
+ [InlineData("no resource", "no_resource", "town_a|vineyards|winery")]
+ [InlineData("sea", "not_land", "")]
+ [InlineData("too far", "too_far", "1|town_a")]
+ [InlineData("a placement there", "occupied", "transit_camp")]
+ [InlineData("a project there", "occupied_project", "housing")]
+ [InlineData("the turn's cap", "turn_cap", "2")]
+ public void EveryRefusalHasAKindAndInvariantValues(string why, string kind, string values)
+ {
+ var c = Neighbours(lockIndustry: why == "a locked kind");
+ var s = New(c);
+ if (why == "a project there") s.CityProjects.Add(s.NextId, new CityProject(s.NextId++, "housing", "town_a", 1, 1, 2));
+ if (why == "a placement there") s.Placements.Add(new Placement(MapActions.TransitCamp, 1, 1, s.Date));
+ if (why == "the turn's cap") { s.MapActionsTurnDate = s.Date; s.MapActionsThisTurn = 2; }
+ var (k, city, q, r) = why switch
+ {
+ "unknown kind" => ("harbour", "town_a", 1, 1),
+ "unknown city" => ("housing", "atlantis", 1, 1),
+ "a locked kind" => ("industry", "town_a", 1, 1),
+ "camp without the policy" => ("transit_camp", "town_a", 1, 1),
+ "no resource" => ("winery", "town_a", 1, 1),
+ "sea" => ("housing", "town_a", 0, 0),
+ "too far" => ("housing", "town_a", 3, 0),
+ _ => ("housing", "town_a", 1, 1),
+ };
+ var reason = Projects.CheckCityReason(c, s, k, city, q, r);
+ Assert.NotNull(reason);
+ Assert.Equal((kind, values), (reason!.Kind, string.Join("|", reason.Values)));
+ Assert.Equal(Projects.CheckCity(c, s, k, city, q, r), reason.Text);
+ Assert.Null(Projects.CheckCityReason(c, New(c), "housing", "town_a", 1, 1));
+ }
+
+ // #1122 (owner ruling 3): a kind may carry a draft Hebrew name pending a native speaker's review (#564); a review flag
+ // other than agent-checked, or one without a name, is refused; a kind without Hebrew still loads.
+ [Fact]
+ public void AKindMayCarryADraftHebrewName()
+ {
+ Content Load(string extra) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["projects.yaml"] = Fixture.GddProjects + " - { id: depot, name: a depot, cost: 1, turns: 1, capacity: 0, condition: 0, job_slots: 1" + extra + " }\n",
+ })));
+ var c = Load(", name_he: מחסן, name_he_review: agent-checked");
+ var depot = c.ProjectKinds.Single(x => x.Id == "depot");
+ Assert.Equal(("מחסן", "agent-checked"), (depot.NameHe, depot.NameHeReview));
+ Assert.Equal("", c.ProjectKinds.Single(x => x.Id == "housing").NameHe);
+ Assert.Contains("name_he_review", Assert.Throws<ContentException>(() => Load(", name_he: מחסן, name_he_review: reviewed")).Message);
+ Assert.Contains("name_he_review", Assert.Throws<ContentException>(() => Load(", name_he: מחסן, name_he_review: ''")).Message); // a blank flag is not "reviewed"
+ Assert.Contains("name_he", Assert.Throws<ContentException>(() => Load(", name_he_review: agent-checked")).Message);
+ }
}
diff --git a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs
index 2e2b86357..6c48b2a6d 100644
--- a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs
+++ b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs
@@ -49,6 +49,17 @@ offices:
from: 1948-05-14
";
+ static readonly string AbleLabour = @"
+ - id: able_labour
+ name: Able Labour
+ living: false
+ competence: 10
+ loyalty: 9
+ offices:
+ - office: labour_minister
+ from: 1948-05-14
+";
+
static readonly string Map = @"
minister_systems:
housing_construction: labour_minister
@@ -293,4 +304,36 @@ offices:
Assert.NotNull(s.Sites[site.Id].BuiltOn);
}
+
+ // #1150 (owner review): a city project's forecast is AdvanceCity's count at its kind's minister multiplier, for a new
+ // order and for every turn under way, so the info panel's Build and turns-left lines say the turn it is built on.
+ [Theory]
+ [InlineData("housing", false)]
+ [InlineData("housing", true)]
+ [InlineData("industry", false)]
+ public void AScaledCityProjectForecastMatchesEveryRemainingTurn(string kind, bool able)
+ {
+ var c = able ? Town(AbleLabour, budget: "labour_minister") : Town();
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ Assert.NotEqual(1.0, EffectsSystem.GddSystemMultiplier(c, s, c.RulesAt(s.Date).Mvp!, Projects.SystemOfKind(kind)));
+ int Forecast(int left, double carry)
+ {
+ var hash = s.Hash();
+ var result = Projects.CityTurnsToBuild(c, s, kind, left, carry);
+ Assert.Equal(hash, s.Hash()); // a forecast never advances the real state
+ return result;
+ }
+ var forecasts = new List<int> { Forecast(c.ProjectKinds.Single(x => x.Id == kind).Turns, 0) };
+ s = Step(c, s, new StartProject(kind, "town_a", 1, 1)).State;
+ var id = s.CityProjects.Values.Single().Id;
+ int actual = 1;
+ while (s.CityProjects[id].BuiltOn == null && actual < 20)
+ {
+ var p = s.CityProjects[id];
+ forecasts.Add(Forecast(p.TurnsLeft, p.Progress));
+ s = Step(c, s).State; actual++;
+ }
+ Assert.NotNull(s.CityProjects[id].BuiltOn);
+ for (int i = 0; i < forecasts.Count; i++) Assert.Equal(actual - i, forecasts[i]);
+ }
}
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 93d561b57..0780790f3 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -627,6 +627,14 @@ namespace Statecraft.Sim
public string Id { get; set; } = "";
/// <summary>The phrase the player reads in a sentence ("a transit camp").</summary>
public string Name { get; set; } = "";
+ /// <summary>The Hebrew UI's name for the kind, a noun ("מעברה"), or "" for none: the UI then shows <see cref="Name"/>
+ /// (#1122, owner ruling 3). A draft until a native speaker reviews it (#564).</summary>
+ public string NameHe { get; set; } = "";
+ /// <summary>"agent-checked" while <see cref="NameHe"/> waits for a native speaker's review (#564); "" once reviewed.</summary>
+ public string NameHeReview { get => nameHeReview ?? ""; set => nameHeReview = value ?? ""; }
+ /// <summary>Whether the row sets name_he_review at all, so a blank flag is refused rather than read as "reviewed".</summary>
+ [YamlIgnore] public bool NameHeReviewGiven => nameHeReview != null;
+ string? nameHeReview;
/// <summary>IL millions, paid in full at the start (Q-PROJ-1).</summary>
public double Cost { get; set; }
/// <summary>Turns to build, the turn of the order the first (D-A3).</summary>
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index e57b930e0..d96190f14 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -1285,6 +1285,10 @@ namespace Statecraft.Sim
if (x.Capacity < 0) throw new ContentException(pf, at + ".capacity", "must not be negative");
if (x.JobSlots < 0) throw new ContentException(pf, at + ".job_slots", "must not be negative");
if (!(x.Condition >= -1 && x.Condition <= 1)) throw new ContentException(pf, at + ".condition", "must be a number from -1 to 1");
+ // #1122 (owner ruling 3): a draft Hebrew name is marked pending a native speaker's review (#564).
+ if (x.NameHeReviewGiven && x.NameHeReview != HebrewReview.AgentChecked)
+ throw new ContentException(pf, at + ".name_he_review", $"must be {HebrewReview.AgentChecked} (pending a native speaker's review, #564), or left out once a person has reviewed the name");
+ if (x.NameHeReviewGiven && string.IsNullOrWhiteSpace(x.NameHe)) throw new ContentException(pf, at + ".name_he", "required: name_he_review is set but the name is empty");
// R-PROJ-005: a kind whose resource no city has could never be built.
if (!string.IsNullOrEmpty(x.Requires) && !c.Cities.Any(k => k.Resources.Any(r => r.Id == x.Requires)))
throw new ContentException(pf, at + ".requires", $"no city in cities.yaml has the resource '{x.Requires}'");
diff --git a/sim/Statecraft.Sim/MapActions.cs b/sim/Statecraft.Sim/MapActions.cs
index bb5d3a198..9cce1cfc9 100644
--- a/sim/Statecraft.Sim/MapActions.cs
+++ b/sim/Statecraft.Sim/MapActions.cs
@@ -14,7 +14,7 @@ namespace Statecraft.Sim
public Placement(string action, int q, int r, DateTime date) { Action = action; Q = q; R = r; Date = date; }
}
- /// <summary>A map-action refusal's stable UI kind and invariant values, beside the English text used by the CLI.</summary>
+ /// <summary>A map-action or city-project refusal's stable UI kind and invariant values, beside the English text used by the CLI.</summary>
public sealed class MapActionReason
{
public string Kind { get; }
diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.cs
index cd9c3e10a..2ded1ab2b 100644
--- a/sim/Statecraft.Sim/Projects.cs
+++ b/sim/Statecraft.Sim/Projects.cs
@@ -88,6 +88,26 @@ namespace Statecraft.Sim
}
}
+ /// <summary><see cref="TurnsToBuild"/> for a city project (#1150): the turns, this one included, in which a project of
+ /// <paramref name="kind"/> completes its remaining whole turns and fractional carry at the kind's current minister
+ /// multiplier, as <see cref="AdvanceCity"/> counts them. Reads the current date's rules and changes no state. A new
+ /// order passes the kind's turns and zero carry.</summary>
+ public static int CityTurnsToBuild(Content c, GameState s, string kind, int left, double carry)
+ {
+ if (left < 1) throw new ArgumentOutOfRangeException(nameof(left));
+ if (!(carry >= 0 && carry < 1)) throw new ArgumentOutOfRangeException(nameof(carry));
+ var r = c.RulesAt(s.Date).Mvp!;
+ var m = EffectsSystem.GddSystemMultiplier(c, s, r, SystemOfKind(kind));
+ if (!(m > 0) || double.IsInfinity(m)) throw new InvalidOperationException("City project progress multiplier must be finite and positive");
+ for (int turns = 1; ; turns = checked(turns + 1))
+ {
+ carry += m;
+ if (carry >= left) return turns;
+ var whole = (int)Math.Floor(carry);
+ left -= whole; carry -= whole;
+ }
+ }
+
/// <summary>Whether a site or a corridor segment being built names <paramref name="unit"/>: the unit has a project
/// (D-D6).</summary>
public static bool IsBusy(GameState s, int unit) => s.Sites.Values.Any(w => w.BuiltOn == null && w.Unit == unit) || Corridors.WorkOf(s, unit) != null;
@@ -218,34 +238,62 @@ namespace Statecraft.Sim
/// land, is further than map_action_max_distance from the city's settlement hex, or holds a placement or another city
/// project (Q-PROJ-2); and once map_actions_per_turn map actions and city projects together were started this turn
/// (Q-PROJ-4). A short Treasury is not a reason: it borrows (Q-MONEY-3). The reference player asks this before it orders.</summary>
- public static string? CheckCity(Content c, GameState s, string kind, string city, int q, int r)
+ public static string? CheckCity(Content c, GameState s, string kind, string city, int q, int r) => CheckCityReason(c, s, kind, city, q, r)?.Text;
+
+ /// <summary><see cref="CheckCity"/>'s one validator (#1122, owner ruling 2): null when the project may be started, else a
+ /// stable kind and invariant values for a UI to word in its language (the map actions' pattern), plus the English text.
+ /// The kinds, in check order: unknown_kind, unknown_city, locked (kind), maabarot_policy, no_resource (city, resource, kind), not_land,
+ /// too_far (distance, city), occupied (the placement's action), occupied_project (the project's kind), turn_cap (cap).</summary>
+ public static MapActionReason? CheckCityReason(Content c, GameState s, string kind, string city, int q, int r)
{
var k = c.ProjectKinds.FirstOrDefault(x => x.Id == kind);
- if (k == null) return "There is no such city project";
- if (!s.Cities.ContainsKey(city)) return "There is no such city";
- if (k.Locked && !s.UnlockedProjects.Contains(kind)) return $"{PlayerText.Capitalised(k.Name)} is not available yet"; // R-EFX-008
+ if (k == null) return new MapActionReason("unknown_kind", "There is no such city project");
+ if (!s.Cities.ContainsKey(city)) return new MapActionReason("unknown_city", "There is no such city");
+ if (k.Locked && !s.UnlockedProjects.Contains(kind)) // R-EFX-008
+ return new MapActionReason("locked", $"{PlayerText.Capitalised(k.Name)} is not available yet", kind);
if (kind == MapActions.TransitCamp && !(s.Policies.TryGetValue(MapActions.MaabarotPolicy, out var m) && m >= 0.5))
- return "Transit camps need the ma'abarot policy";
+ return new MapActionReason("maabarot_policy", "Transit camps need the ma'abarot policy");
// R-PROJ-005. A city founded in play is not in cities.yaml, so it has no resources.
if (!string.IsNullOrEmpty(k.Requires) && c.Cities.FirstOrDefault(x => x.Id == city)?.Resources.Any(x => x.Id == k.Requires) != true)
- return $"{PlayerText.Settlement(c, city)} has no {k.Requires} for {k.Name}";
+ return new MapActionReason("no_resource", $"{PlayerText.Settlement(c, city)} has no {k.Requires} for {k.Name}", city, k.Requires, kind);
var hex = c.HexAt(q, r);
- if (hex == null || !hex.Land) return "This hex is not land";
+ if (hex == null || !hex.Land) return new MapActionReason("not_land", "This hex is not land");
var rules = c.RulesAt(s.Date); // the era the turn starts in
- var home = c.SettlementHexes.First(h => h.Id == city); // every city has one (ValidateGdd)
var max = rules.MapActionMaxDistance;
var name = PlayerText.Settlement(c, city);
- if (MapActions.Distance(q, r, home.Q, home.R) > max)
- return FormattableString.Invariant($"This hex is more than {max} {(max == 1 ? "hex" : "hexes")} from {name}");
- if (MapActions.At(s, q, r) is Placement placed) return $"This hex already has {PlayerText.MapAction(c, placed.Action)}";
- if (CityProjectAt(s, q, r) is CityProject other) return $"This hex already has {c.ProjectKinds.First(x => x.Id == other.Kind).Name}";
+ if (!InReach(c, s, city, q, r))
+ return new MapActionReason("too_far", FormattableString.Invariant($"This hex is more than {max} {(max == 1 ? "hex" : "hexes")} from {name}"),
+ max.ToString(System.Globalization.CultureInfo.InvariantCulture), city);
+ if (MapActions.At(s, q, r) is Placement placed)
+ return new MapActionReason("occupied", $"This hex already has {PlayerText.MapAction(c, placed.Action)}", placed.Action);
+ if (CityProjectAt(s, q, r) is CityProject other)
+ return new MapActionReason("occupied_project", $"This hex already has {c.ProjectKinds.First(x => x.Id == other.Kind).Name}", other.Kind);
// Last, as for map actions, so a player over the cap still sees the specific reason an order is illegal. The count
// is the map actions' own (one national limit, Q-PROJ-4).
if ((s.MapActionsTurnDate == s.Date ? s.MapActionsThisTurn : 0) >= rules.MapActionsPerTurn)
- return FormattableString.Invariant($"No more than {rules.MapActionsPerTurn} map actions and city projects in one turn");
+ return new MapActionReason("turn_cap", FormattableString.Invariant($"No more than {rules.MapActionsPerTurn} map actions and city projects in one turn"),
+ rules.MapActionsPerTurn.ToString(System.Globalization.CultureInfo.InvariantCulture));
return null;
}
+ /// <summary>Whether hex (q, r) is within map_action_max_distance of <paramref name="city"/>'s settlement hex (Q-PROJ-2): the
+ /// one range check, of <see cref="CheckCityReason"/> and <see cref="CitiesFor"/>.</summary>
+ static bool InReach(Content c, GameState s, string city, int q, int r) =>
+ Distance(c, city, q, r) <= c.RulesAt(s.Date).MapActionMaxDistance; // the era the turn starts in
+
+ static int Distance(Content c, string city, int q, int r)
+ {
+ var home = c.SettlementHexes.First(h => h.Id == city); // every city has one (ValidateGdd)
+ return MapActions.Distance(q, r, home.Q, home.R);
+ }
+
+ /// <summary>The cities that may own a city project on hex (q, r) (#1122, owner ruling 1): those whose settlement hex is in
+ /// reach (<see cref="InReach"/>), nearest first, then in ordinal id order. Being listed promises no kind: each still goes
+ /// through <see cref="CheckCityReason"/>.</summary>
+ public static IReadOnlyList<string> CitiesFor(Content c, GameState s, int q, int r) =>
+ s.Cities.Keys.Where(id => InReach(c, s, id, q, r))
+ .OrderBy(id => Distance(c, id, q, r)).ThenBy(id => id, StringComparer.Ordinal).ToList();
+
/// <summary>R-PROJ-001: starts city project <paramref name="kind"/> for <paramref name="city"/> on hex (q, r), or returns
/// the reason (<see cref="CheckCity"/>; state untouched). The Treasury pays the kind's cost now and borrows what it lacks
/// (Q-PROJ-1, Q-MONEY-3); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It
diff --git a/unity/Assets/Scripts/UI/ContentNames.cs b/unity/Assets/Scripts/UI/ContentNames.cs
index 30f8aad3c..42bb8b0d1 100644
--- a/unity/Assets/Scripts/UI/ContentNames.cs
+++ b/unity/Assets/Scripts/UI/ContentNames.cs
@@ -15,6 +15,8 @@ namespace Statecraft.Game.UI
public static string Of(UiText text, Party p) => Pick(text, p.Name, p.NameHe);
public static string Of(UiText text, Government g) => Pick(text, g.Name, g.NameHe);
public static string Of(UiText text, Legislature l) => Pick(text, l.Body, l.BodyHe);
+ /// <summary>A city project kind's name: its draft name_he, pending a native speaker's review (#564, #1122).</summary>
+ public static string Of(UiText text, ProjectKind k) => Pick(text, k.Name, k.NameHe);
/// <summary>The office's title for <paramref name="holder"/> (null: the office itself, masculine): a woman is given
/// the row's feminine title_he_f, which every office with a Hebrew title has (owner on #861: "Move to content"), so
diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.cs
index 24ba23064..d5baef4cc 100644
--- a/unity/Assets/Scripts/UI/GddHexPanel.cs
+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs
@@ -1,5 +1,6 @@
#nullable enable
using System;
+using System.Globalization;
using System.Linq;
using Statecraft.Sim;
using UnityEngine.UIElements;
@@ -13,27 +14,39 @@ namespace Statecraft.Game.UI
/// (R-TRAIN-002). On a site's hex (sites.yaml: a yishuv, camp, field or swamp site, #1124), its state, and Build with each idle pioneer
/// group (Projects.IsPioneer: a halutz or a veteran one), with the rules' cost and the unit's own turns (Projects.TurnsToBuild;
/// R-SITE-001, R-VET-002), or Stop while it is built (R-SITE-002).</para>
+ /// <para>On any hex a city can build on (Projects.CitiesFor, #1122): the city that builds (the player picks when several
+ /// can), and Build for each content project kind with its cost and turns (Projects.CityTurnsToBuild), disabled with the sim's own refusal
+ /// (Projects.CheckCityReason) worded in the UI's language; or the project there, with its turns left and Cancel, or the
+ /// day it was finished (R-PROJ-001 to R-PROJ-003).</para>
/// <para>Every number is the sim's, and every order goes through the bridge's queue: the sim rules on it when the turn
/// runs. No rule lives here: the limits are the sim's public helpers (Cities.MaxWorkers, Training.Available), asked with
/// the queue, and a button is disabled only where the sim would refuse that order, or another one in the queue, anyway.</para></summary>
public static class GddHexPanel
{
public const string HostName = "info-gdd";
+ /// <summary>The city-project part's host (#1122), in the hex's facts column: the GDD column beside it is already full on a city's
+ /// own hex, and the facts column has room (InfoPanelLayoutTests).</summary>
+ public const string ProjectsHostName = "info-projects";
+ /// <summary>On the city's own hex, on a stacked bar or a short window, the project part folds behind this toggle
+ /// ("City projects (N)") and the list it opens (owner ruling on #1150, 21 Oct 2026; Statecraft.uss .city-projects-list).</summary>
+ public const string ToggleName = "city-projects-toggle", ListName = "city-projects-list", OpenClass = "info-projects-open";
const string LineClass = "info-gdd-line", RowClass = "info-gdd-row", PairsClass = "info-gdd-pairs";
public static void Hide(VisualElement host) { host.Clear(); host.style.display = DisplayStyle.None; }
- /// <summary>Builds the hex's GDD part into <paramref name="host"/> (hidden when there is none) and returns the
- /// designated site's name in the UI's language when the hex holds one, else null.</summary>
- public static string? Render(VisualElement host, SimBridge bridge, UiText text, int q, int r)
+ /// <summary>Builds the hex's GDD part into <paramref name="host"/> and its city projects into <paramref name="projects"/>
+ /// (each hidden when there is none) and returns the designated site's name in the UI's language when the hex holds one,
+ /// else null. <paramref name="townName"/> names a city in the UI's language (InfoPanelPresenter's town names).</summary>
+ public static string? Render(VisualElement host, VisualElement projects, SimBridge bridge, UiText text, int q, int r, Func<string, string> townName)
{
- host.Clear();
+ host.Clear(); projects.Clear();
var c = bridge.Content; var s = bridge.State;
string? title = null;
if (c.IsGdd)
{
foreach (var at in c.SettlementHexes.Where(x => x.Q == q && x.R == r && s.Cities.ContainsKey(x.Id)))
City(host, bridge, text, at.Id);
+ var cityHere = host.childCount > 0;
// A hex may hold two sites, a yishuv or the Hula swamp and the field it readies (R-FIELD-001, R-SWAMP-001): each
// gets its own part, the one to finish first on top, and its name is the title (#1124).
foreach (var site in c.Sites.Where(x => x.Q == q && x.R == r && Work(x) != null).OrderBy(x => x.Kinds.Contains(Projects.FieldKind)))
@@ -43,8 +56,10 @@ namespace Statecraft.Game.UI
host.Add(part);
Site(part, bridge, text, site, Work(site)!.Value);
}
+ CityProjects(projects, bridge, text, q, r, townName, cityHere);
}
host.style.display = host.childCount > 0 ? DisplayStyle.Flex : DisplayStyle.None;
+ projects.style.display = projects.childCount > 0 ? DisplayStyle.Flex : DisplayStyle.None;
return title;
}
@@ -162,6 +177,99 @@ namespace Statecraft.Game.UI
else Line(host, "site-state", text.Format("site.built" + key, Date(text, work.BuiltOn.Value)));
}
+ /// <summary>The city projects of hex (q, r) (#1122). A project there shows its state and, while it is built, Cancel
+ /// (R-PROJ-002). Else, for the cities in reach (Projects.CitiesFor; none: nothing shows), the city that builds: the one
+ /// the player picked on this hex, else the queued order's, else the nearest. Build for each kind queues StartProject for
+ /// that city and hex, one order a hex (SimBridge's key, so another kind or city replaces it); the Attention is the
+ /// bridge's, which refuses an order it cannot pay for as for every order. On a city's own hex (<paramref name="cityHere"/>)
+ /// the cities and the kinds go into the ListName list under the ToggleName toggle, which the stylesheet shows only on a
+ /// stacked bar or a short window (InfoPanelPresenter.ShortClass) and which opens and closes the list there.</summary>
+ static void CityProjects(VisualElement host, SimBridge bridge, UiText text, int q, int r, Func<string, string> townName, bool cityHere)
+ {
+ var c = bridge.Content; var s = bridge.State;
+ string Kind(string id) => PlayerText.Capitalised(ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == id)));
+ if (Projects.CityProjectAt(s, q, r) is CityProject project)
+ {
+ if (project.BuiltOn is DateTime built)
+ {
+ Line(host, "city-project-state", text.Format("city.project_built", Kind(project.Kind), townName(project.City), Date(text, built)));
+ return;
+ }
+ Line(host, "city-project-state", text.Format("city.project_building", Kind(project.Kind), townName(project.City), Turns(text, Projects.CityTurnsToBuild(c, s, project.Kind, project.TurnsLeft, project.Progress))));
+ var cancelled = bridge.QueuedLike(new CancelProject(project.Id)) != null;
+ Button(host, "city-project-cancel", text[cancelled ? "city.cancel_ordered" : "city.cancel"],
+ () => bridge.Queue(new CancelProject(project.Id))).SetEnabled(!cancelled);
+ return;
+ }
+ var cities = Projects.CitiesFor(c, s, q, r);
+ if (cities.Count == 0 || c.ProjectKinds.Count == 0) return;
+ var queued = bridge.QueuedLike(new StartProject("", "", q, r)) as StartProject;
+ // Owner ruling on #1150 (21 Oct 2026): under the city's own part the full list ran into the left column on a stacked
+ // bar or a short window, so there it folds behind one toggle; a refusal is then one tap away. The open state is the
+ // host's class, kept across renders (InfoPanelPresenter.Show closes it for a newly chosen hex).
+ var list = host;
+ if (cityHere)
+ {
+ Button(host, ToggleName, text.Format("city.projects_toggle", c.ProjectKinds.Count), () => host.ToggleInClassList(OpenClass));
+ list = new VisualElement { name = ListName };
+ list.AddToClassList(ListName);
+ host.Add(list);
+ }
+ // The pick lives on the host, which the panel keeps across renders; it is for this hex only.
+ var city = host.userData is ValueTuple<int, int, string> pick && pick.Item1 == q && pick.Item2 == r && cities.Contains(pick.Item3) ? pick.Item3
+ : queued != null && cities.Contains(queued.City) ? queued.City : cities[0];
+ // The city's line and, when several can build, the pick on one row, so the part stays short (InfoPanelLayoutTests).
+ if (cities.Count == 1) Line(list, "city-project-for", text.Format("city.project_for", townName(city)));
+ else
+ {
+ var row = Row(list, "city-project-cities");
+ Line(row, "city-project-for", text.Format("city.project_for", townName(city)));
+ foreach (var id in cities)
+ Button(row, "city-project-city-" + id, townName(id), () =>
+ {
+ host.userData = (q, r, id);
+ host.Clear();
+ CityProjects(host, bridge, text, q, r, townName, cityHere);
+ // The pressed button is rebuilt (and now disabled): the focus stays in the row, for the keyboard.
+ host.Q("city-project-cities")?.Query<Button>().Where(b => b.enabledSelf).First()?.Focus();
+ }).SetEnabled(id != city);
+ }
+ var refusals = c.ProjectKinds.Select(k => Projects.CheckCityReason(c, s, k.Id, city, q, r)).ToList();
+ var 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();
+ 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++)
+ {
+ var k = c.ProjectKinds[i];
+ if (words[i] != null) { Line(list, $"city-project-{k.Id}-reason", words[i]!); continue; }
+ var ordered = queued != null && queued.ProjectKind == k.Id && queued.City == city;
+ Button(list, "city-project-" + k.Id, ordered ? text.Format("city.project_ordered", ContentNames.Of(text, k))
+ : text.Format("city.project_start", ContentNames.Of(text, k), PlayerText.Money(c, "treasury", k.Cost), Turns(text, Projects.CityTurnsToBuild(c, s, k.Id, k.Turns, 0))),
+ () => bridge.Queue(new StartProject(k.Id, city, q, r))).SetEnabled(!ordered);
+ }
+ }
+
+ /// <summary>A city-project refusal (Projects.CheckCityReason) in the UI's language: the map actions' strings where the
+ /// sim's English is theirs, else city.project_reason.*. The sim's English for the kinds this panel cannot meet: an
+ /// unknown kind or city, a distance (CitiesFor lists only the cities in reach) or another project on the hex (its
+ /// state shows instead).</summary>
+ static string ReasonText(MapActionReason reason, UiText text, Content c, Func<string, string> townName)
+ {
+ switch (reason.Kind)
+ {
+ case "maabarot_policy": case "not_land": return text["info.map_action_reason." + reason.Kind];
+ case "occupied": return text.Format("info.map_action_reason.occupied", text["info.map_action." + reason.Values[0]]);
+ case "no_resource": return text.Format("city.project_reason.no_resource", townName(reason.Values[0]), reason.Values[1],
+ ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == reason.Values[2])));
+ case "turn_cap": return text.Format("city.project_reason.turn_cap", int.Parse(reason.Values[0], CultureInfo.InvariantCulture));
+ default: return reason.Text;
+ }
+ }
+
/// <summary>"1 group" or "n groups" (population groups, D-A1), in the UI's language.</summary>
public static string Groups(UiText t, int n) => n == 1 ? t["city.groups_one"] : t.Format("city.groups", n);
/// <summary>"1 turn" or "n turns", in the UI's language.</summary>
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 157baca39..a759820fe 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -33,6 +33,8 @@ namespace Statecraft.Game.UI
readonly UiIcon thumb;
/// <summary>The GDD loop's part (GddHexPanel, #381): a city's counts and orders, or the designated site's.</summary>
readonly VisualElement gdd;
+ /// <summary>The hex's city projects (GddHexPanel, #1122), under the facts.</summary>
+ readonly VisualElement projects;
readonly IReadOnlyDictionary<string, string> settlementNames;
readonly MapRegions? regions;
readonly System.Func<string, (int q, int r)>? townHex;
@@ -64,6 +66,7 @@ namespace Statecraft.Game.UI
placement = panel.Q<Label>("info-placement"); reason = panel.Q<Label>("info-reason");
thumb = panel.Q<UiIcon>("info-thumb");
gdd = panel.Q<VisualElement>(GddHexPanel.HostName);
+ projects = panel.Q<VisualElement>(GddHexPanel.ProjectsHostName);
foreach (var row in panel.Query(className: RowClass).ToList()) rows.Add((row, row.Q<Label>()));
campButton = panel.Q<Button>("build-camp"); housingButton = panel.Q<Button>("build-housing");
onCamp = () => Build(MapActions.TransitCamp); onHousing = () => Build(MapActions.Housing);
@@ -74,11 +77,20 @@ namespace Statecraft.Game.UI
defenceButton.clicked += onDefence;
defenceButton.text = text["unit.defence"];
bridge.Changed += Render;
+ panel.parent?.RegisterCallback<GeometryChangedEvent>(OnHudGeometry);
Render();
}
+ void OnHudGeometry(GeometryChangedEvent e) => panel.EnableInClassList(ShortClass, e.newRect.height < ShortBelowPx);
+
/// <summary>Unsubscribes from the bridge and the buttons (the owner calls this when disabled).</summary>
- public void Dispose() { bridge.Changed -= Render; campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; }
+ public void Dispose() { bridge.Changed -= Render; panel.parent?.UnregisterCallback<GeometryChangedEvent>(OnHudGeometry); campButton.clicked -= onCamp; housingButton.clicked -= onHousing; defenceButton.clicked -= onDefence; }
+
+ /// <summary>Below this window height (logical px; 1366x657 is about 998) the panel gets ShortClass, and the city's own
+ /// hex folds its projects behind their toggle as on a stacked bar (GddHexPanel.ToggleName): there the full list ran into
+ /// the left column (InfoPanelLayoutTests).</summary>
+ public const float ShortBelowPx = 1040f;
+ public const string ShortClass = "info-short";
public (int q, int r)? Selected { get; private set; }
@@ -102,7 +114,9 @@ namespace Statecraft.Game.UI
public void Show(int q, int r)
{
if (Covered) return; // covered (#210)
- unitMode = false; Selected = (q, r); Render();
+ if (unitMode || Selected != (q, r)) projects.RemoveFromClassList(GddHexPanel.OpenClass); // a newly chosen hex starts with its city projects folded
+ unitMode = false; Selected = (q, r);
+ Render();
}
/// <summary>Shows the selected unit's card (the unit comes from the selectedUnit callback); ignored while covered.</summary>
@@ -245,7 +259,7 @@ namespace Statecraft.Game.UI
placement.text = card.Footer; reason.text = card.Note;
camp.style.display = DisplayStyle.None; housing.style.display = DisplayStyle.None;
ShowThumb(null);
- GddHexPanel.Hide(gdd);
+ GddHexPanel.Hide(gdd); GddHexPanel.Hide(projects);
return;
}
panel.EnableInClassList("info-empty", Selected == null);
@@ -256,7 +270,7 @@ namespace Statecraft.Game.UI
ShowLocalities("");
camp.style.display = DisplayStyle.None; housing.style.display = DisplayStyle.None;
ShowThumb(null);
- GddHexPanel.Hide(gdd);
+ GddHexPanel.Hide(gdd); GddHexPanel.Hide(projects);
return;
}
var (q, r) = Selected.Value;
@@ -265,7 +279,7 @@ namespace Statecraft.Game.UI
var owned = c.SettlementHexes.Where(x => x.Q == q && x.R == r).Select(x => TownName(x.Id)).ToList(); // strict: every settlement hex has a name (final review M4)
title.text = owned.Count > 0 ? owned[0] : hex == null ? text["info.off_map"] : text["info.biome." + hex.Biome];
// The GDD loop's city or designated site (#381); a site's hex has no settlement, so its name is the title.
- var siteName = GddHexPanel.Render(gdd, bridge, text, q, r);
+ var siteName = GddHexPanel.Render(gdd, projects, bridge, text, q, r, TownName);
if (siteName != null && owned.Count == 0) title.text = siteName;
subtitle.text = hex == null ? "" : text.Format("info.hex", text["info.biome." + hex.Biome], hex.ElevM); // no debug coordinates in player text (playtest 2, P2-6)
// The armistice zone in force, else the sub-district on 15 May 1948, and any armistice line in force through the
diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
new file mode 100644
index 000000000..9c1b91571
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
@@ -0,0 +1,280 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.UIElements;
+
+/// <summary>#1122: city projects in the info panel (R-PROJ-001 to R-PROJ-003), on a real SimBridge with the real content. On a
+/// hex a city can build on (Projects.CitiesFor), the city that builds (the player picks when several can) and Build for each
+/// loaded kind, with the content's cost and turns; the order goes into the bridge's queue for that kind, city and hex; a
+/// refused kind shows the sim's own reason (Projects.CheckCityReason) in English and Hebrew in place of its Build; a project under way shows its
+/// turns left and Cancel, a finished one its day.</summary>
+public class CityProjectPanelTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static readonly Dictionary<string, string> Towns =
+ SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", SettlementPlacer.DefaultFileName))).ToDictionary(t => t.Id, t => t.Name);
+ 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");
+ // Haifa has hexes no other city reaches; Tel Aviv's own hex is also in Petah Tikva's reach.
+ const string City = "haifa", TelAviv = "tel_aviv", Neighbour = "petah_tikva";
+
+ static (int q, int r) TelAvivHex => C.SettlementHexes.Where(x => x.Id == TelAviv).Select(x => (x.Q, x.R)).Single();
+
+ /// <summary>The first hex in (q, r) order whose land flag is <paramref name="land"/> and whose builders are exactly
+ /// <paramref name="cities"/>, by the sim's own helper: the panel's preconditions, not a second range rule.</summary>
+ static (int q, int r) HexWith(bool land, params string[] cities)
+ {
+ var s = GameSession.New(C, GoldenRun.Seed, Mode.Historical).State;
+ var hex = C.Hexes.Where(h => h.Land == land && Projects.CitiesFor(C, s, h.Q, h.R).SequenceEqual(cities))
+ .OrderBy(h => h.Q).ThenBy(h => h.R).First();
+ return (hex.Q, hex.R);
+ }
+
+ static (int q, int r) Lone => HexWith(true, City);
+
+ static SimBridge Bridge(UiText text, Action<GameState>? edit = null)
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ Assert.IsTrue(C.IsGdd, "precondition: the real content runs the GDD loop");
+ edit?.Invoke(g.State);
+ return new SimBridge(g, text);
+ }
+
+ static InfoPanelPresenter Panel(UiTestKit ui, SimBridge bridge, UiText text) => new InfoPanelPresenter(ui.Root, bridge, text, Towns);
+
+ static string Name(UiText t, string kind) => ContentNames.Of(t, C.ProjectKinds.Single(k => k.Id == kind));
+
+ static string Start(UiText t, ProjectKind k, GameState s) =>
+ t.Format("city.project_start", ContentNames.Of(t, k), PlayerText.Money(C, "treasury", k.Cost), GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C, s, k.Id, k.Turns, 0)));
+
+ [Test]
+ public void EveryLoadedKindIsOfferedWithItsContentCostAndTurns([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = Lone;
+ using var ui = new UiTestKit();
+ var bridge = Bridge(t, s => s.Policies[MapActions.MaabarotPolicy] = 1); // so the sim refuses no kind here
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.project_for", Towns[City]), ui.Q<Label>("city-project-for").text);
+ Assert.IsNull(ui.Root.Q("city-project-cities"), "one city in reach: nothing to pick");
+ Assert.GreaterOrEqual(C.ProjectKinds.Count, 3, "precondition: housing, the transit camp and industry");
+ foreach (var k in C.ProjectKinds)
+ {
+ // A kind that needs a resource Haifa lacks (the winery's vineyards, R-PROJ-005) shows the sim's reason instead.
+ if (Projects.CheckCityReason(C, bridge.State, k.Id, City, q, r)?.Kind == "no_resource") { Assert.IsNotNull(ui.Root.Q<Label>($"city-project-{k.Id}-reason"), k.Id); continue; }
+ Assert.AreEqual(Start(t, k, bridge.State), ui.Q<Button>("city-project-" + k.Id).text, k.Id);
+ }
+ // Draft Hebrew names (owner ruling 3), the English name where a kind has none.
+ Assert.AreEqual(hebrew ? "מיזם דיור" : "a housing project", Name(t, "housing"));
+ Assert.AreEqual("a depot", ContentNames.Of(t, new ProjectKind { Id = "depot", Name = "a depot" }));
+ }
+
+ [Test]
+ public void BuildQueuesTheKindForTheCityOnTheHexAndAnotherKindReplacesIt()
+ {
+ var (q, r) = Lone;
+ using var ui = new UiTestKit();
+ var bridge = Bridge(En);
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ Assert.IsTrue(ui.Q<Button>("city-project-housing").enabledSelf, "precondition: housing may be started");
+ ui.Press("city-project-housing");
+ var order = (StartProject)bridge.Queued.Single();
+ Assert.AreEqual(("housing", City, q, r), (order.ProjectKind, order.City, order.Q, order.R));
+ var housing = ui.Q<Button>("city-project-housing");
+ Assert.AreEqual(En.Format("city.project_ordered", Name(En, "housing")), housing.text);
+ Assert.IsFalse(housing.enabledSelf, "ordered: pressing again would change nothing");
+
+ ui.Press("city-project-industry"); // one order a hex (SimBridge's key): the other kind replaces it
+ order = (StartProject)bridge.Queued.Single();
+ Assert.AreEqual(("industry", City, q, r), (order.ProjectKind, order.City, order.Q, order.R));
+ Assert.AreEqual(Start(En, C.ProjectKinds.Single(k => k.Id == "housing"), bridge.State), ui.Q<Button>("city-project-housing").text);
+ Assert.IsTrue(ui.Q<Button>("city-project-housing").enabledSelf);
+ Assert.AreEqual(1, bridge.EndTurn().State.CityProjects.Values.Count(p => p.Kind == "industry" && p.City == City && p.Q == q && p.R == r),
+ "the sim accepts the order the panel queued");
+ }
+
+ [Test]
+ public void WhenSeveralCitiesCanBuildThePlayerPicksAndTheFocusStaysInTheRow()
+ {
+ var (q, r) = TelAvivHex;
+ Assert.AreEqual(new[] { TelAviv, Neighbour }, Projects.CitiesFor(C, Bridge(En).State, q, r), "precondition: Tel Aviv's own hex, and Petah Tikva next to it");
+ using var ui = new UiTestKit();
+ var bridge = Bridge(En);
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ Assert.AreEqual(En.Format("city.project_for", Towns[TelAviv]), ui.Q<Label>("city-project-for").text, "the nearest first");
+ Assert.IsFalse(ui.Q<Button>("city-project-city-" + TelAviv).enabledSelf);
+ var other = ui.Q<Button>("city-project-city-" + Neighbour);
+ Assert.AreEqual(Towns[Neighbour], other.text);
+ Assert.IsTrue(other.canGrabFocus, "keyboard: the pick is a focusable button");
+ other.Focus();
+ UiTestKit.Press(other);
+ Assert.AreEqual(En.Format("city.project_for", Towns[Neighbour]), ui.Q<Label>("city-project-for").text);
+ Assert.AreEqual("city-project-city-" + TelAviv, (ui.Root.focusController.focusedElement as VisualElement)?.name, "the focus stays in the row");
+ Assert.IsEmpty(bridge.Queued, "picking a city orders nothing");
+ ui.Press("city-project-industry");
+ var order = (StartProject)bridge.Queued.Single();
+ Assert.AreEqual(("industry", Neighbour, q, r), (order.ProjectKind, order.City, order.Q, order.R));
+ Assert.AreEqual(En.Format("city.project_for", Towns[Neighbour]), ui.Q<Label>("city-project-for").text, "the pick holds after the order");
+
+ panel.Show(Lone.q, Lone.r); // the pick is for its hex only
+ Assert.AreEqual(En.Format("city.project_for", Towns[City]), ui.Q<Label>("city-project-for").text);
+ }
+
+ [Test]
+ public void AProjectUnderWayShowsItsTurnsLeftAndCancelQueuesCancelProject([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = Lone;
+ int id = -1;
+ using var ui = new UiTestKit();
+ var bridge = Bridge(t, s => { id = s.NextId++; s.CityProjects.Add(id, new CityProject(id, "housing", City, q, r, 4)); });
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.project_building", PlayerText.Capitalised(Name(t, "housing")), Towns[City], GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C, bridge.State, "housing", 4, 0))), ui.Q<Label>("city-project-state").text);
+ Assert.IsNull(ui.Root.Q("city-project-housing"), "the hex is taken: no Build");
+ ui.Press("city-project-cancel");
+ Assert.AreEqual(id, ((CancelProject)bridge.Queued.Single()).Project);
+ var cancel = ui.Q<Button>("city-project-cancel");
+ Assert.AreEqual(t["city.cancel_ordered"], cancel.text);
+ Assert.IsFalse(cancel.enabledSelf);
+ Assert.IsFalse(bridge.EndTurn().State.CityProjects.ContainsKey(id), "the sim cancels it");
+ }
+
+ // #1150 (owner review): since #1147 the minister multiplier scales a city project's progress, so the turns on Build and
+ // under way are the sim's forecast (Projects.CityTurnsToBuild), not the kind's base turns or the raw turns left.
+ [Test]
+ public void TheTurnsAreTheSimsForecastAtTheMinistersMultiplier([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = Lone;
+ var housing = C.ProjectKinds.Single(k => k.Id == "housing");
+ // Labour's budget line unfunded: its factor at the 0.5 floor, so the multiplier is not 1.
+ void Unfund(GameState s) => s.Budget[Offices.BudgetLineOf(C, "labour_minister", s.Date)!] = 0;
+ using (var ui = new UiTestKit())
+ {
+ var bridge = Bridge(t, Unfund);
+ var turns = Projects.CityTurnsToBuild(C, bridge.State, "housing", housing.Turns, 0);
+ Assert.AreNotEqual(housing.Turns, turns, "precondition: the multiplier is not 1");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.project_start", Name(t, "housing"), PlayerText.Money(C, "treasury", housing.Cost), GddHexPanel.Turns(t, turns)),
+ ui.Q<Button>("city-project-housing").text);
+ }
+ using (var ui = new UiTestKit())
+ {
+ var bridge = Bridge(t, s => { Unfund(s); var id = s.NextId++; s.CityProjects.Add(id, new CityProject(id, "housing", City, q, r, 4).WithProgress(4, 0.5)); });
+ var left = Projects.CityTurnsToBuild(C, bridge.State, "housing", 4, 0.5);
+ Assert.AreNotEqual(4, left, "precondition: the multiplier is not 1");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.project_building", PlayerText.Capitalised(Name(t, "housing")), Towns[City], GddHexPanel.Turns(t, left)),
+ ui.Q<Label>("city-project-state").text);
+ }
+ }
+
+ [Test]
+ public void AFinishedProjectShowsItsDayAndNoCancel()
+ {
+ var (q, r) = Lone;
+ var day = new DateTime(1948, 9, 30);
+ using var ui = new UiTestKit();
+ var bridge = Bridge(En, s => { var id = s.NextId++; s.CityProjects.Add(id, new CityProject(id, "industry", City, q, r, 1).Built(day)); });
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ Assert.AreEqual(En.Format("city.project_built", "An industry project", Towns[City], En.Format("date.day_month_year", 30, En["date.month_9"], 1948)),
+ ui.Q<Label>("city-project-state").text);
+ Assert.IsNull(ui.Root.Q("city-project-cancel"));
+ }
+
+ /// <summary>Each refusal the panel can meet, from the sim's validator, worded in the UI's language: one kind refused (the
+ /// policy, a resource) under its own button; every kind refused for one reason (not land, a placement, the turn's limit)
+ /// said once with no buttons.</summary>
+ [Test]
+ public void TheSimsRefusalsShowInEnglishAndHebrew([Values] bool hebrew, [Values("policy", "resource", "sea", "placement", "turn_cap")] string why)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = why == "sea" ? HexWith(false, City) : Lone;
+ var winery = new ProjectKind { Id = "a_winery", Name = "a winery", Cost = 2, Turns = 2, JobSlots = 6, Requires = "vineyards" };
+ if (why == "resource") C.ProjectKinds.Add(winery);
+ try
+ {
+ using var ui = new UiTestKit();
+ var bridge = Bridge(t, s =>
+ {
+ // With the policy the transit camp is refused for the shared reason too, not for the policy first.
+ if (why != "policy" && why != "resource") s.Policies[MapActions.MaabarotPolicy] = 1;
+ if (why == "placement") s.Placements.Add(new Placement(MapActions.Housing, q, r, s.Date));
+ if (why == "turn_cap") { s.MapActionsTurnDate = s.Date; s.MapActionsThisTurn = C.RulesAt(s.Date).MapActionsPerTurn; }
+ });
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ var s0 = bridge.State;
+ var expected = why switch
+ {
+ "policy" => t["info.map_action_reason.maabarot_policy"],
+ "resource" => t.Format("city.project_reason.no_resource", Towns[City], "vineyards", ContentNames.Of(t, winery)),
+ "sea" => t["info.map_action_reason.not_land"],
+ "placement" => t.Format("info.map_action_reason.occupied", t["info.map_action.housing"]),
+ _ => t.Format("city.project_reason.turn_cap", C.RulesAt(s0.Date).MapActionsPerTurn),
+ };
+ var kind = why == "policy" ? MapActions.TransitCamp : why == "resource" ? winery.Id : "housing";
+ Assert.IsNotNull(Projects.CheckCityReason(C, s0, kind, City, q, r), "precondition: the sim refuses it");
+ if (why == "policy" || why == "resource")
+ {
+ Assert.AreEqual(expected, ui.Q<Label>($"city-project-{kind}-reason").text);
+ Assert.IsNull(ui.Root.Q("city-project-" + kind), "the reason alone, which names the kind");
+ Assert.IsTrue(ui.Q<Button>("city-project-industry").enabledSelf, "the other kinds stay open");
+ Assert.IsNull(ui.Root.Q("city-project-industry-reason"));
+ }
+ else
+ {
+ Assert.AreEqual(expected, ui.Q<Label>("city-project-reason").text);
+ Assert.IsNull(ui.Root.Q("city-project-housing"), "refused for all alike: no buttons");
+ }
+ if (!hebrew && why != "resource") // the English is the sim's own sentence
+ Assert.AreEqual(Projects.CheckCity(C, s0, kind, City, q, r), expected);
+ }
+ finally { C.ProjectKinds.Remove(winery); }
+ }
+
+ [Test]
+ public void AnOrderTheAttentionCannotPayIsRefusedByTheBridge()
+ {
+ var (q, r) = Lone;
+ var refusals = new List<string>();
+ using var ui = new UiTestKit();
+ var bridge = Bridge(En, s => s.Attention = 0);
+ bridge.Refused += refusals.Add;
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ var order = new StartProject("housing", City, q, r);
+ Assert.IsFalse(bridge.CanPay(order), "precondition: no Attention left");
+ ui.Press("city-project-housing");
+ Assert.IsEmpty(bridge.Queued);
+ Assert.AreEqual(new[] { En.Format("order.no_attention", bridge.Price(order), 0.0) }, refusals);
+ }
+
+ [Test]
+ public void AHexNoCityReachesShowsNoProjects()
+ {
+ var (q, r) = HexWith(true);
+ using var ui = new UiTestKit();
+ var bridge = Bridge(En);
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ Assert.IsNull(ui.Root.Q("city-project-for"));
+ Assert.IsNull(ui.Root.Q("city-project-housing"));
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs.meta b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs.meta
new file mode 100644
index 000000000..c626f2afb
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 65c8135f9b9145eea2887f7c7329b983
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index 9b80c3c93..2aff82b94 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -31,10 +31,14 @@ public class InfoPanelLayoutTests
(1024, 1024), (960, 1080), (800, 1000), (1531, 784), (2560, 1080), (1920, 900), (1600, 757), (1366, 657), (960, 600), (390, 844),
};
+ /// <summary>Windows where the city's own hex must show its projects behind the toggle (owner ruling on #1150, 21 Oct 2026):
+ /// the stacked bars and the short window whose full list ran into the left column. 1920x1080 keeps the full list.</summary>
+ static readonly (int w, int h)[] CollapsedWindows = { (1024, 1024), (960, 1080), (390, 844), (1366, 657) };
+
/// <summary>The real Game.uxml on the real PanelSettings at w x h, out of its loading state, with the top bar, an open event
/// card and the info panel (with the region lines) on the session given.</summary>
static IEnumerator Rendered(int w, int h, GameSession g, System.Action<VisualElement, InfoPanelPresenter> act, System.Action<VisualElement> check,
- UiText? text = null, bool hebrew = false)
+ UiText? text = null, bool hebrew = false, System.Action<VisualElement>? settled = null)
{
var t = text ?? Text;
var rt = new RenderTexture(w, h, 0);
@@ -58,6 +62,8 @@ public class InfoPanelLayoutTests
act(root, info);
for (int i = 0; i < 20 && float.IsNaN(root.Q("info-panel").worldBound.width); i++) yield return null;
for (int i = 0; i < 3; i++) yield return null; // text measured after the first layout settles
+ // A press on a button the stylesheet shows only once the HUD has its tier (the bar's classes come with the layout).
+ if (settled != null) { settled(root); for (int i = 0; i < 3; i++) yield return null; }
check(root);
}
finally
@@ -133,7 +139,8 @@ public class InfoPanelLayoutTests
}
/// <summary>GDD Phase 1 PR 8 (#381): the city panel with two training cohorts (a Cancel each) and the
- /// designated site's panel (two idle halutz groups, so two Build buttons), at every window size in English and Hebrew:
+ /// designated site's panel (two idle halutz groups, so two Build buttons), and a hex one city can build a city project on
+ /// (#1122; the city also with the ma'abarot policy, so every project kind is a button), at every window size in English and Hebrew:
/// the panel lies in the window, clear of the minimap, the left column and the top bar, and every shown label and
/// button lies inside the panel with its text fitting its box.</summary>
[UnityTest]
@@ -142,22 +149,39 @@ public class InfoPanelLayoutTests
var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
var city = C.SettlementHexes.Single(s => s.Id == "tel_aviv");
var site = C.Sites.Single(s => s.Id == "mefalsim");
+ var start = GameSession.New(C, GoldenRun.Seed, Mode.Historical).State;
+ var lone = C.Hexes.Where(x => x.Land && Projects.CitiesFor(C, start, x.Q, x.R).Count == 1).OrderBy(x => x.Q).ThenBy(x => x.R).First();
var hula = C.Sites.Single(s => s.Id == "hula"); // #1124: the swamp and its waiting field, the tallest site hex
var problems = new List<string>();
foreach (var hebrew in new[] { false, true })
foreach (var (w, h) in Windows)
- foreach (var (what, q, r) in new[] { ("city", city.Q, city.R), ("site", site.Q, site.R), ("field", site.Q, site.R), ("hula", hula.Q, hula.R) })
+ foreach (var (what, q, r) in new[] { ("city", city.Q, city.R), ("site", site.Q, site.R), ("projects", lone.Q, lone.R), ("city with the policy", city.Q, city.R),
+ ("field", site.Q, site.R), ("hula", hula.Q, hula.R) })
{
var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
var s = g.State;
for (int k = 0; k < 2; k++) { var id = s.NextId++; s.Cohorts.Add(id, new Cohort(id, k == 0 ? "recruit" : "halutz", "tel_aviv", 12, 4)); }
for (int k = 0; k < 2; k++) { var id = s.NextId++; s.Units.Add(id, new Unit(id, "halutz", city.Q, city.R)); }
+ // With the ma'abarot policy every project kind is a Build button: the city's tallest project part (#1122).
+ if (what == "city with the policy") s.Policies[MapActions.MaabarotPolicy] = 1;
if (what == "field") s.Sites[site.Id] = SiteWork.Built(site.Id, s.Date); // #1124: the yishuv built, its field's Plow
var at = $"{(hebrew ? "he" : "en")} {w}x{h} {what}";
yield return Rendered(w, h, g, (root, info) => info.Show(q, r), root =>
{
var panel = root.Q("info-panel"); var window = root.worldBound;
- if (root.Q(GddHexPanel.HostName).resolvedStyle.display != DisplayStyle.Flex) { problems.Add($"{at}: precondition: the GDD part shows"); return; }
+ var host = what == "projects" ? GddHexPanel.ProjectsHostName : GddHexPanel.HostName;
+ if (root.Q(host).resolvedStyle.display != DisplayStyle.Flex) { problems.Add($"{at}: precondition: {host} shows"); return; }
+ // Owner ruling on #1150 (21 Oct 2026): on a stacked bar or a short window the city's own hex shows its
+ // projects collapsed behind one toggle, so the city cases there are the collapsed state; elsewhere the full list.
+ // The opened list may run past the panel there: the ruling accepts it (TheCityProjectsToggleOpensAndCloses...).
+ if (what.StartsWith("city"))
+ {
+ var collapsed = root.Q("root").ClassListContains(HudPresenter.TwoRowClass) || panel.ClassListContains(InfoPanelPresenter.ShortClass);
+ if (collapsed ? (w, h) == (1920, 1080) : CollapsedWindows.Contains((w, h))) problems.Add($"{at}: the city projects collapse: {collapsed}, expected {!collapsed}");
+ var toggle = root.Q(GddHexPanel.ToggleName); var list = root.Q(GddHexPanel.ListName);
+ if (toggle == null || list == null) problems.Add($"{at}: precondition: the city's projects have a toggle and a list");
+ else if (Shown(toggle) != collapsed || Shown(list) == collapsed) problems.Add($"{at}: toggle shown {Shown(toggle)}, list shown {Shown(list)}, collapsed {collapsed}");
+ }
if (!Inside(panel.worldBound, window)) problems.Add($"{at}: the panel {panel.worldBound} leaves the window {window}");
foreach (var other in new[] { "minimap", "left-column", "top-bar" })
if (panel.worldBound.Overlaps(root.Q(other).worldBound)) problems.Add($"{at}: the panel {panel.worldBound} overlaps the {other} {root.Q(other).worldBound}");
@@ -171,6 +195,46 @@ public class InfoPanelLayoutTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+ /// <summary>Owner ruling on #1150 (21 Oct 2026): on a stacked bar (1024x1024) the city's own hex shows "City projects (N)", N
+ /// the kinds listed, and the list behind it; a tap opens it and another closes it. A hex only one city reaches keeps the full
+ /// list there, and the city's own hex keeps it on a tall one-row window (1920x1080). English and Hebrew.</summary>
+ [UnityTest]
+ public IEnumerator TheCityProjectsToggleOpensAndClosesTheListOnAStackedBar()
+ {
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ var city = C.SettlementHexes.Single(s => s.Id == "tel_aviv");
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var lone = C.Hexes.Where(x => x.Land && Projects.CitiesFor(C, g.State, x.Q, x.R).Count == 1).OrderBy(x => x.Q).ThenBy(x => x.R).First();
+ foreach (var hebrew in new[] { false, true })
+ {
+ var t = hebrew ? he : Text;
+ for (int presses = 0; presses < 3; presses++)
+ {
+ var n = presses;
+ yield return Rendered(1024, 1024, g, (root, info) => info.Show(city.Q, city.R), root =>
+ {
+ var toggle = root.Q<Button>(GddHexPanel.ToggleName);
+ Assert.IsTrue(Shown(toggle), $"{hebrew} {n}: the toggle shows");
+ Assert.AreEqual(t.Format("city.projects_toggle", C.ProjectKinds.Count), toggle.text);
+ Assert.AreEqual(n == 1, Shown(root.Q(GddHexPanel.ListName)), $"{hebrew}: the list after {n} presses");
+ }, t, hebrew, root =>
+ {
+ // The turn's decision card opens over the map and disables the panel under it: hidden first, as a player would.
+ UiTestKit.Press(root.Q<Button>("event-hide"));
+ Assert.IsTrue(root.Q("info-panel").enabledInHierarchy, "precondition: the panel takes the press");
+ for (int i = 0; i < n; i++) UiTestKit.Press(root.Q<Button>(GddHexPanel.ToggleName));
+ });
+ }
+ foreach (var (w, h, q, r) in new[] { (1024, 1024, lone.Q, lone.R), (1920, 1080, city.Q, city.R) })
+ yield return Rendered(w, h, g, (root, info) => info.Show(q, r), root =>
+ {
+ var toggle = root.Q(GddHexPanel.ToggleName);
+ Assert.IsTrue(toggle == null || !Shown(toggle), $"{hebrew} {w}x{h} ({q}, {r}): no toggle");
+ Assert.IsTrue(root.Q(GddHexPanel.ProjectsHostName).Query<Button>().ToList().Any(b => b.name != GddHexPanel.ToggleName && Shown(b)), $"{hebrew} {w}x{h} ({q}, {r}): the Build buttons show");
+ }, t, hebrew);
+ }
+ }
+
/// <summary>The empty hint stays inside the window and clear of the minimap in both languages: one line on desktop,
/// at most two on the phone tier, with no terrain sign, fact rows or spare panel height.</summary>
[UnityTest]
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 5173db410..6f0bfaefc 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -150,6 +150,8 @@
<ui:Button name="info-defence" />
</ui:VisualElement>
<ui:Label name="info-reason" class="reason" />
+ <!-- The hex's city projects (GddHexPanel, #1122): here, not in the GDD column, which a city's own hex fills. -->
+ <ui:VisualElement name="info-projects" class="info-projects" />
</ui:VisualElement>
<!-- The GDD loop's city counts and orders, or the designated site's state and Build/Stop (GddHexPanel, #381): a
second column beside the hex's facts, under them on the two- and three-row HUD (Statecraft.uss .info-gdd). -->
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 9810686ca..f85b27c57 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -362,7 +362,19 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.info-gdd { flex-direction: column; width: 380px; flex-shrink: 0; margin-left: 14px; padding-left: 14px; border-left-width: 1px; border-color: var(--gold-dim); }
.info-gdd-line { font-size: 17px; flex-shrink: 1; }
.info-gdd-row { flex-wrap: wrap; align-items: center; }
-.info-gdd Button { margin: 2px 6px 2px 0; font-size: 17px; white-space: normal; flex-shrink: 1; }
+.info-projects { flex-direction: column; }
+.info-gdd Button, .info-projects Button { margin: 2px 6px 2px 0; font-size: 17px; white-space: normal; flex-shrink: 1; }
+/* Shorter buttons and lines than the GDD column's: the project part sits under a city's facts and must keep the panel clear of the
+ left column on a phone (InfoPanelLayoutTests, #1122). */
+.info-projects Button { padding-top: 2px; padding-bottom: 2px; margin-top: 0; margin-bottom: 1px; }
+.info-projects Label { margin-top: 0; margin-bottom: 0; padding-top: 1px; padding-bottom: 1px; }
+/* Owner ruling on #1150 (21 Oct 2026): on the city's own hex the project list folds behind "City projects (N)" on a stacked bar
+ or a short window (InfoPanelPresenter.ShortClass), where the full list ran into the left column; elsewhere the toggle
+ hides and the list shows. The toggle opens the list with .info-projects-open (GddHexPanel). */
+#city-projects-toggle { display: none; }
+.hud-two-row #city-projects-toggle, .info-short #city-projects-toggle { display: flex; }
+.hud-two-row .city-projects-list, .info-short .city-projects-list { display: none; }
+.hud-two-row .info-projects-open > .city-projects-list, .info-short .info-projects-open > .city-projects-list { display: flex; }
/* Two counts on one row (Jobs | Craftsmen, Refugees waiting | Overflow; #1121): each keeps its width, so the row wraps
whole rather than squeezing a line into two, and a gap follows each (mirrored in Hebrew). */
.info-gdd-pairs > .info-gdd-line { flex-shrink: 0; margin-right: 14px; }
@@ -950,7 +962,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
panel keeps its 520 px and the GDD part stacks under the hex's facts, clear of the minimap. Last, so they win over the
rules above at equal specificity. */
.lang-he .info-gdd { margin-left: 0; padding-left: 0; border-left-width: 0; margin-right: 14px; padding-right: 14px; border-right-width: 1px; }
-.lang-he .info-gdd Button { margin: 2px 0 2px 6px; }
+.lang-he .info-gdd Button, .lang-he .info-projects Button { margin: 2px 0 2px 6px; }
.lang-he .info-gdd-pairs > .info-gdd-line { margin-right: 0; margin-left: 14px; }
.hud-two-row .info-panel.info-gdd-shown { width: 520px; flex-wrap: wrap; }
.hud-two-row .info-gdd { width: 100%; margin: 8px 0 0 0; padding: 8px 0 0 0; border-left-width: 0; border-right-width: 0; border-top-width: 1px; }
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index a19a7071a..91b077e5d 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -440,6 +440,18 @@ city.groups: "{0} groups"
city.turns_one: "1 turn"
city.turns: "{0} turns"
city.cancel_ordered: "Cancel ordered"
+# City projects on the chosen hex (#1122): the city that builds it, Build for each content kind (its name, then cost and
+# turns from content), the order, and a project under way or finished. Refusals the map actions share use their
+# info.map_action_reason.* strings; these are the city projects' own.
+city.project_for: "Project for {0}"
+city.project_start: "Build {0}: {1}, {2}"
+city.project_ordered: "Ordered: {0}"
+city.project_building: "{0} for {1}: {2} left"
+city.project_built: "{0} for {1}, finished on {2}"
+city.project_reason.no_resource: "{0} has no {1} for {2}"
+city.project_reason.turn_cap: "No more than {0} map actions and city projects in one turn"
+# The toggle that folds a city's own projects on a stacked bar or a short window (owner ruling on #1150).
+city.projects_toggle: "City projects ({0})"
site.available: "A designated site for a new yishuv"
site.group: "halutz group {0}"
site.build: "Build a yishuv with {0}: {1}, {2}"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index c1943ead3..160d5ecbd 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -464,6 +464,19 @@ city.groups: "{0} קבוצות"
city.turns_one: "תור אחד"
city.turns: "{0} תורות"
city.cancel_ordered: "הביטול הוזמן"
+# City projects on the chosen hex (#1122). The kind names come from content/projects.yaml name_he, nouns ("מעברה"), so
+# every sentence takes them as nouns; "הקמת" keeps the order line's gender neutral. The resource id in no_resource has no
+# Hebrew name yet (no content kind requires one). For the native reviewer (#564).
+city.project_for: "מיזם עבור {0}"
+city.project_start: "הקמת {0}: {1}, {2}"
+city.project_ordered: "הוזמנה הקמת {0}"
+city.project_building: "{0} עבור {1}: עוד {2}"
+city.project_built: "{0} עבור {1}: הבנייה הושלמה ב־{2}"
+city.project_reason.no_resource: "ב־{0} אין {1} עבור {2}"
+city.project_reason.turn_cap: "אי אפשר להתחיל יותר מ־{0} פעולות מפה ומיזמים עירוניים בתור אחד"
+# The toggle that folds a city's own projects on a stacked bar or a short window (owner ruling on #1150), {0} the
+# number of kinds. For the native reviewer (#564).
+city.projects_toggle: "מיזמי העיר ({0})"
site.available: "אתר ייעודי ליישוב חדש"
site.group: "קבוצת חלוצים {0}"
site.build: "הקמת יישוב עם {0}: {1}, {2}"