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.

Hex panel: a project being built shows its builder and the city's builder stepper (Fixes #2477) (#2874)

Beri373d726bcfbd
diff --git a/changelog.d/1700-builder-ui.md b/changelog.d/1700-builder-ui.md
new file mode 100644
index 000000000..f06614d83
--- /dev/null
+++ b/changelog.d/1700-builder-ui.md
@@ -0,0 +1,6 @@
+### Added
+
+- Under the gdd-0.3 rules, a city project being built now says in the hex panel whether it has a builder, and shows its
+ city's builder count with − and + to change it (R-CITY-011, Refs #2477). A housing repair being built shows on its
+ city's own hex. + is off where End turn would refuse one more builder with this turn's orders, or another of them,
+ and the reason shows in English or Hebrew.
diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.cs
index 227941913..cfc8bd149 100644
--- a/unity/Assets/Scripts/UI/GddHexPanel.cs
+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs
@@ -366,6 +366,7 @@ namespace Statecraft.Game.UI
var cancelled = bridge.QueuedLike(new CancelProject(project.Id)) != null;
OrderButton(host, bridge, "city-project-cancel", text[cancelled ? "city.cancel_ordered" : "city.cancel"],
!cancelled, () => bridge.Queue(new CancelProject(project.Id)));
+ BuilderPart(host, bridge, text, project);
}
// R-HOUSE-006 (#1700): the sim takes a gdd-0.3 housing repair on its city's own hex whatever that hex holds
// (Projects.CheckCityReason), so on a city's own hex the repair is still offered under the project; every other
@@ -373,6 +374,7 @@ namespace Statecraft.Game.UI
if (!cityHere) return;
kinds = c.ProjectKinds.Where(k => k.Id == Projects.HousingRepair).ToList();
}
+ if (cityHere) Repairs(host, bridge, text, q, r, townName);
var cities = Projects.CitiesFor(c, s, q, r);
if (cities.Count == 0 || kinds.Count == 0) return;
var queued = bridge.QueuedLike(new StartProject("", "", q, r)) as StartProject;
@@ -498,6 +500,76 @@ namespace Statecraft.Game.UI
for (int i = 0; i < paused.Count; i++) Line(host, "city-workshop-paused-" + i.ToString(CultureInfo.InvariantCulture), paused[i]);
}
+ /// <summary>R-CITY-011 (#1700, #2477), gdd-0.3 only: on a city project being built, whether it has a builder, and its
+ /// city's builder stepper. AssignWorkers(city, "build", n) sets how many of the city's projects being built have one
+ /// (Projects.AssignBuilders), so the stepper is the city's count (Projects.Builders, or the queued order's) of its
+ /// projects being built; stepping back to the current count withdraws the order. + asks End turn's own order runner
+ /// (Simulation.Preview, as Train does) whether n + 1 in the order's slot would be refused, or would make it refuse an
+ /// order of the queue it accepts now, so the queue's job, training, workshop, start and builder orders all count
+ /// whichever runs first. While a project is left without one, that refusal shows in the UI's language. A repair's line
+ /// is <paramref name="line"/>; <paramref name="stepper"/> off leaves the stepper to another project of the hex (Repairs).</summary>
+ static void BuilderPart(VisualElement host, SimBridge bridge, UiText text, CityProject project, string line = "city-project-builder", bool stepper = true)
+ {
+ var c = bridge.Content; var s = bridge.State;
+ if (c.Ruleset != SaveGame.Gdd03Ruleset) return;
+ var city = project.City;
+ Line(host, line, text[project.Builder ? "city.project_builder" : "city.project_no_builder"]);
+ if (!stepper) return;
+ var building = s.CityProjects.Values.Count(p => p.City == city && p.BuiltOn == null);
+ var builders = Projects.Builders(s, city);
+ var queued = bridge.QueuedLike(new AssignWorkers(city, Projects.BuildRole, 0)) as AssignWorkers;
+ var target = queued?.Count ?? builders;
+ string? refusal = null;
+ var accepted = true;
+ // A finished game's preview refuses every order: OrderButton already disables + there (#2669), with no reason line.
+ if (s.GameOver == null && target < building)
+ {
+ var press = new AssignWorkers(city, Projects.BuildRole, target + 1);
+ var queue = bridge.Queued.ToList();
+ var slot = queued == null ? -1 : queue.IndexOf(queued);
+ if (slot >= 0) queue[slot] = press; else queue.Add(press);
+ var current = Simulation.Preview(c, bridge.TurnStart, bridge.Session.Committed.Concat(bridge.Queued).ToList());
+ var preview = Simulation.Preview(c, bridge.TurnStart, bridge.Session.Committed.Concat(queue).ToList());
+ refusal = preview.Rejected.FirstOrDefault(x => ReferenceEquals(x.Command, press))?.Reason;
+ // Nor may the press make End turn refuse a queued order it accepts now (a Train or a workshop's worker); then
+ // that order's refusal is the reason line (#2477 review), so a greyed + always says why.
+ var broken = refusal != null ? null : preview.Rejected.FirstOrDefault(r => !ReferenceEquals(r.Command, press)
+ && queue.Any(x => ReferenceEquals(x, r.Command)) && !current.Rejected.Any(k => ReferenceEquals(k.Command, r.Command)));
+ accepted = refusal == null && broken == null;
+ refusal ??= broken?.Reason;
+ }
+ var row = Row(host, "city-builders-row");
+ OrderButton(row, bridge, "city-builders-less", "−", target > 0, () => Build(bridge, city, builders, target - 1));
+ Line(row, "city-builders", text.Format(queued == null ? "city.builders" : "city.builders_ordered", target, building));
+ OrderButton(row, bridge, "city-builders-more", "+", target < building && accepted, () => Build(bridge, city, builders, target + 1));
+ if (refusal != null) Line(host, "city-builders-reason", SimBridge.ReasonText(text, refusal, c, bridge.TownNamesHe));
+ }
+
+ /// <summary>R-HOUSE-006 with R-CITY-011 (#2477 review): a housing repair being built has no hex of its own
+ /// (Projects.CityProjectAt skips it), so it shows on its city's own hex, where it is offered: its line and whether it
+ /// has a builder. Its city's builder stepper shows once on the hex: under the hex's own project being built when that
+ /// is the same city's, else under the city's first repair, so a city whose only project being built is a repair has
+ /// one too.</summary>
+ static void Repairs(VisualElement host, SimBridge bridge, UiText text, int q, int r, Func<string, string> townName)
+ {
+ var c = bridge.Content; var s = bridge.State;
+ var stepped = new System.Collections.Generic.HashSet<string>();
+ if (Projects.CityProjectAt(s, q, r) is CityProject { BuiltOn: null } here) stepped.Add(here.City);
+ foreach (var repair in s.CityProjects.Values.Where(p => p.Kind == Projects.HousingRepair && p.Q == q && p.R == r && p.BuiltOn == null).OrderBy(p => p.Id))
+ {
+ var kind = PlayerText.Capitalised(ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == repair.Kind)));
+ Line(host, "city-repair-state", text.Format("city.project_building", kind, townName(repair.City),
+ Turns(text, Projects.CityTurnsToBuild(c, s, repair.Kind, repair.TurnsLeft, repair.Progress))));
+ BuilderPart(host, bridge, text, repair, "city-repair-builder", stepped.Add(repair.City));
+ }
+ }
+
+ static void Build(SimBridge bridge, string city, int current, int count)
+ {
+ if (count != current) { bridge.Queue(new AssignWorkers(city, Projects.BuildRole, count)); return; }
+ if (bridge.QueuedLike(new AssignWorkers(city, Projects.BuildRole, 0)) is Command order) bridge.Withdraw(order);
+ }
+
static void Staff(SimBridge bridge, string city, int current, int count)
{
if (count != current) { bridge.Queue(new AssignWorkers(city, Workshops.Role, count)); return; }
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index f066c4231..7fbd66e72 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -299,6 +299,9 @@ namespace Statecraft.Game.UI
(Workshops.RefusedBuilt, "workshop.refused_built"),
(Workshops.RefusedPeople, "workshop.refused_people"),
(Workshops.RefusedPeopleNoJob, "workshop.refused_people_no_job"),
+ // R-CITY-011 (#2477): a builder order past the city's projects being built (Projects.AssignBuilders).
+ (Projects.RefusedBeingBuiltOne, "builder.refused_being_built_one"),
+ (Projects.RefusedBeingBuilt, "builder.refused_being_built"),
// R-PROJ-001 under gdd-0.3 (#1700 slice B): a second city project start in one city in one turn.
(Projects.RefusedCityCap, "city.project_reason.city_cap"),
}.Select(x => (new Regex("^" + string.Join("(.+?)", Regex.Split(x.format, @"\{\d+\}").Select(Regex.Escape)) + "$"), x.key)).ToArray();
diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
index 540b7f8dc..39641bd23 100644
--- a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
@@ -880,4 +880,242 @@ public class WorkshopPanelTests
Assert.IsEmpty(turn.Rejected, "the sim accepts the order the panel queued");
Assert.IsTrue(turn.State.Workshops[first].Staffed && turn.State.Workshops[second].Staffed);
}
+
+ // R-CITY-011 (#2477): under gdd-0.3 a project being built says whether it has a builder, and shows its city's builder
+ // stepper (AssignWorkers(city, "build", n): how many of the city's projects being built have one). Not on a built
+ // project, and not under gdd-0.1, which has no builders.
+ [Test]
+ public void AProjectBeingBuiltShowsItsBuilderAndTheCitysBuilderStepper_RCity011([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ foreach (var (c, turns, builder, shown) in new[] { (C03, 2, false, true), (C03, 2, true, true), (C03, 0, false, false), (C01, 2, false, false) })
+ {
+ var (q, r) = Hex(c);
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(c, t, "housing", turnsLeft: turns, edit: (s, id) => { if (builder) s.CityProjects[id] = s.CityProjects[id].WithBuilder(true); });
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ var at = $"{c.Ruleset} turns {turns} builder {builder}";
+ Assert.IsNotNull(ui.Root.Q("city-project-state"), at + ": precondition, the project's part shows");
+ Assert.AreEqual(shown, ui.Root.Q("city-builders-row") != null, at);
+ Assert.AreEqual(shown, ui.Root.Q("city-project-builder") != null, at);
+ if (!shown) continue;
+ Assert.AreEqual(t[builder ? "city.project_builder" : "city.project_no_builder"], ui.Q<Label>("city-project-builder").text, at);
+ Assert.AreEqual(t.Format("city.builders", builder ? 1 : 0, 1), ui.Q<Label>("city-builders").text, at);
+ Assert.AreEqual(builder, ui.Q<Button>("city-builders-less").enabledSelf, at);
+ Assert.AreEqual(!builder, ui.Q<Button>("city-builders-more").enabledSelf, at + ": 4 people without a job, 1 project");
+ Assert.IsNull(ui.Root.Q("city-builders-reason"), at);
+ }
+ }
+
+ // R-CITY-011 (#2477): + queues AssignWorkers(city, "build", n + 1), the line reads the ordered count, and - back to the
+ // current count withdraws the order. The sim accepts the queued order and the project gets its builder.
+ [Test]
+ public void TheBuilderStepperQueuesTheBuildRoleAndStepsBackToNoOrder_RCity011()
+ {
+ using var ui = new UiTestKit();
+ var (bridge, id) = Game(C03, En, "housing", turnsLeft: 2);
+ using var panel = Panel(ui, bridge, En);
+ var (q, r) = Hex(C03);
+ panel.Show(q, r);
+ ui.Press("city-builders-more");
+ var order = bridge.QueuedLike(new AssignWorkers(City, Projects.BuildRole, 0)) as AssignWorkers;
+ Assert.IsNotNull(order, "the stepper queues an AssignWorkers order");
+ Assert.AreEqual((City, Projects.BuildRole, 1), (order!.City, order.Role, order.Count));
+ Assert.AreEqual(En.Format("city.builders_ordered", 1, 1), ui.Q<Label>("city-builders").text);
+ Assert.IsFalse(ui.Q<Button>("city-builders-more").enabledSelf, "its one project is ordered a builder");
+ Assert.IsNull(ui.Root.Q("city-builders-reason"), "every project has one: no refusal to explain");
+ Assert.IsNull(bridge.QueuedLike(new AssignWorkers(City, "job", 0)), "the jobs order's slot is its own");
+ ui.Press("city-builders-less");
+ Assert.IsNull(bridge.QueuedLike(new AssignWorkers(City, Projects.BuildRole, 0)), "back at the current count: no order is left queued");
+ Assert.AreEqual(En.Format("city.builders", 0, 1), ui.Q<Label>("city-builders").text);
+ ui.Press("city-builders-more");
+ var turn = bridge.EndTurn();
+ Assert.IsEmpty(turn.Rejected, "the sim accepts the order the panel queued");
+ Assert.IsTrue(turn.State.CityProjects[id].Builder);
+ }
+
+ // R-CITY-011 (#2477): two projects being built, neither with a builder. The stepper counts both, + steps 1 then 2 and is
+ // then off, - from 2 queues 1, and End turn puts the one builder on the lower id (Projects.AssignBuilders).
+ [Test]
+ public void TwoProjectsBeingBuiltStepOneAtATime_RCity011()
+ {
+ using var ui = new UiTestKit();
+ var second = 0;
+ var (bridge, first) = Game(C03, En, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ var hex = C03.Hexes.Where(h => h.Land && (h.Q, h.R) != Hex(C03) && Projects.CitiesFor(C03, s, h.Q, h.R).Contains(City)).OrderBy(h => h.Q).ThenBy(h => h.R).First();
+ second = s.NextId++;
+ s.CityProjects.Add(second, new CityProject(second, "housing", City, hex.Q, hex.R, 2));
+ });
+ using var panel = Panel(ui, bridge, En);
+ var (q, r) = Hex(C03);
+ panel.Show(q, r);
+ Assert.AreEqual(En["city.project_no_builder"], ui.Q<Label>("city-project-builder").text);
+ Assert.AreEqual(En.Format("city.builders", 0, 2), ui.Q<Label>("city-builders").text);
+ ui.Press("city-builders-more");
+ Assert.AreEqual(En.Format("city.builders_ordered", 1, 2), ui.Q<Label>("city-builders").text);
+ Assert.IsTrue(ui.Q<Button>("city-builders-more").enabledSelf, "4 free, 1 of 2 ordered: a second may still be put on");
+ ui.Press("city-builders-more");
+ Assert.AreEqual(En.Format("city.builders_ordered", 2, 2), ui.Q<Label>("city-builders").text);
+ Assert.IsFalse(ui.Q<Button>("city-builders-more").enabledSelf, "both projects ordered a builder");
+ Assert.IsNull(ui.Root.Q("city-builders-reason"));
+ ui.Press("city-builders-less");
+ Assert.AreEqual(1, ((AssignWorkers)bridge.QueuedLike(new AssignWorkers(City, Projects.BuildRole, 0))!).Count, "- from 2 queues 1, not no order");
+ var turn = bridge.EndTurn();
+ Assert.IsEmpty(turn.Rejected);
+ Assert.IsTrue(turn.State.CityProjects[Math.Min(first, second)].Builder, "a rise puts the builder on the lower id");
+ Assert.IsFalse(turn.State.CityProjects[Math.Max(first, second)].Builder);
+ }
+
+ // R-CITY-011 (#2477): + is off where End turn would refuse one more builder, counting this turn's queue (a jobs order,
+ // an arms workshop's worker, or a Train, that takes the last free person), and the sim's refusal shows in the UI's language.
+ [Test]
+ public void PlusFollowsTheSimWithTheQueueAndShowsItsRefusal_RCity011([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = Hex(C03);
+ foreach (var pending in new[] { "none", "job", "workshop", "train" })
+ {
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(C03, t, "housing", employed: pending == "none" ? 10 : 9, turnsLeft: 2, edit: (s, _) =>
+ {
+ if (pending == "workshop") SecondWorkshop(C03, s);
+ // Haifa has no training facility of its own: a built industry project lets it train craftsmen (Training.HasFacility).
+ if (pending == "train") { var w = SecondWorkshop(C03, s); var x = s.CityProjects[w]; s.CityProjects[w] = new CityProject(w, Training.Industry, City, x.Q, x.R, 0).Built(s.Date); }
+ });
+ if (pending == "job") Assert.IsNull(bridge.Queue(new AssignWorkers(City, "job", 10)));
+ if (pending == "workshop") Assert.IsNull(bridge.Queue(new AssignWorkers(City, Workshops.Role, 1)));
+ if (pending == "train") Assert.IsNull(bridge.Queue(new Train(City, "craftsman", 1)), "precondition: the Train takes the one free person");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ var press = new AssignWorkers(City, Projects.BuildRole, 1);
+ var preview = Simulation.Preview(C03, bridge.TurnStart, bridge.Session.Committed.Concat(bridge.Queued).Append(press).ToList());
+ var rejected = preview.Rejected.SingleOrDefault(x => ReferenceEquals(x.Command, press));
+ Assert.IsNotNull(rejected, pending + ": precondition, End turn refuses one more builder");
+ Assert.IsFalse(ui.Q<Button>("city-builders-more").enabledSelf, pending);
+ Assert.AreEqual(SimBridge.ReasonText(t, rejected!.Reason, C03, TownsHe), ui.Q<Label>("city-builders-reason").text, pending);
+ if (hebrew) Assert.AreNotEqual(rejected.Reason, ui.Q<Label>("city-builders-reason").text, pending + ": the Hebrew string, not the sim's English");
+ }
+ }
+
+ // R-CITY-011 (#2477): a project that is finished, or cancelled, no longer shows the builder control.
+ [Test]
+ public void AFinishedOrCancelledProjectShowsNoBuilderControl_RCity011()
+ {
+ var (q, r) = Hex(C03);
+ foreach (var cancel in new[] { false, true })
+ {
+ using var ui = new UiTestKit();
+ var (bridge, id) = Game(C03, En, "housing", turnsLeft: 1, edit: (s, p) => s.CityProjects[p] = s.CityProjects[p].WithBuilder(true));
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(q, r);
+ Assert.IsNotNull(ui.Root.Q("city-builders-row"), "precondition: shown while it is built");
+ if (cancel) ui.Press("city-project-cancel");
+ var turn = bridge.EndTurn();
+ Assert.IsEmpty(turn.Rejected, cancel ? "cancelled" : "finished");
+ Assert.AreEqual(cancel, !turn.State.CityProjects.ContainsKey(id), "precondition: cancelled projects leave the state");
+ // The Labour minister's housing multiplier can stretch one turn of work over more (R-MIN-002): End turn until done.
+ for (var i = 0; !cancel && turn.State.CityProjects[id].BuiltOn == null && i < 6; i++) turn = bridge.EndTurn();
+ if (!cancel) Assert.IsNotNull(turn.State.CityProjects[id].BuiltOn, "precondition: with its builder it is finished");
+ panel.Show(q, r);
+ Assert.IsNull(ui.Root.Q("city-builders-row"), cancel ? "cancelled" : "finished");
+ Assert.IsNull(ui.Root.Q("city-project-builder"), cancel ? "cancelled" : "finished");
+ }
+ }
+
+ // R-CITY-011 (#2477): a build order past the city's projects being built (the end of turn's toast) reads in Hebrew.
+ [Test]
+ public void TheBeingBuiltRefusalsReadInHebrew_RCity011()
+ {
+ var inv = System.Globalization.CultureInfo.InvariantCulture;
+ var one = SimBridge.ReasonText(He, string.Format(inv, Projects.RefusedBeingBuiltOne, "Haifa"), C03, TownsHe);
+ Assert.IsTrue(string.Equals(TownsHe[City] + ": יש רק מיזם עירוני אחד בבנייה", one, StringComparison.Ordinal), one);
+ var two = SimBridge.ReasonText(He, string.Format(inv, Projects.RefusedBeingBuilt, "Haifa", 2), C03, TownsHe);
+ Assert.IsTrue(two.StartsWith(TownsHe[City] + ": מיזמים עירוניים בבנייה: ", StringComparison.Ordinal) && two.Contains("2"), two);
+ }
+
+ // R-CITY-011 with R-HOUSE-006 (#2477 review): a housing repair being built has no hex of its own, so it shows on its city's
+ // own hex, where it is offered: its line, whether it has a builder, and its city's stepper, also when it is the city's only
+ // project being built. + there queues the build order and End turn gives the repair its builder.
+ [Test]
+ public void ARepairBeingBuiltShowsItsBuilderOnItsCitysOwnHex_RCity011([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var home = C03.SettlementHexes.First(x => x.Id == City);
+ var repair = 0;
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, id) =>
+ {
+ s.CityProjects.Remove(id);
+ repair = s.NextId++;
+ s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, home.Q, home.R, 2));
+ });
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(home.Q, home.R);
+ var kind = PlayerText.Capitalised(ContentNames.Of(t, C03.ProjectKinds.First(k => k.Id == Projects.HousingRepair)));
+ Assert.AreEqual(t.Format("city.project_building", kind, (hebrew ? TownsHe : Towns)[City],
+ GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C03, bridge.State, Projects.HousingRepair, 2, 0))), ui.Q<Label>("city-repair-state").text);
+ Assert.AreEqual(t["city.project_no_builder"], ui.Q<Label>("city-repair-builder").text);
+ Assert.AreEqual(t.Format("city.builders", 0, 1), ui.Q<Label>("city-builders").text, "the repair is the one project the count counts");
+ Assert.IsTrue(ui.Q<Button>("city-builders-more").enabledSelf, "4 people without a job, 1 project");
+ ui.Press("city-builders-more");
+ var turn = bridge.EndTurn();
+ Assert.IsEmpty(turn.Rejected, "the sim accepts the order the panel queued");
+ Assert.IsTrue(turn.State.CityProjects[repair].Builder);
+ panel.Show(home.Q, home.R);
+ Assert.AreEqual(t["city.project_builder"], ui.Q<Label>("city-repair-builder").text);
+ }
+
+ // R-CITY-011 (#2477 review): a city's own hex with its project being built and a repair being built shows both builder
+ // lines and one stepper for the city, whose count is the two projects on screen.
+ [Test]
+ public void ACitysOwnHexWithAProjectAndARepairShowsOneStepper_RCity011()
+ {
+ var home = C03.SettlementHexes.First(x => x.Id == City);
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(C03, En, "housing", turnsLeft: 2, edit: (s, id) =>
+ {
+ s.CityProjects[id] = new CityProject(id, "housing", City, home.Q, home.R, 2);
+ var repair = s.NextId++;
+ s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, home.Q, home.R, 2).WithBuilder(true));
+ });
+ using var panel = Panel(ui, bridge, En);
+ panel.Show(home.Q, home.R);
+ Assert.AreEqual(En["city.project_no_builder"], ui.Q<Label>("city-project-builder").text);
+ Assert.AreEqual(En["city.project_builder"], ui.Q<Label>("city-repair-builder").text);
+ Assert.AreEqual(1, ui.Root.Query("city-builders-row").ToList().Count, "one stepper for the city");
+ Assert.AreEqual(En.Format("city.builders", 1, 2), ui.Q<Label>("city-builders").text);
+ }
+
+ // R-CITY-011 (#2477 review): + off only because the press would make End turn refuse another queued order (here a jobs
+ // order queued after the build order, which the raised count leaves short of people) shows that order's refusal.
+ [Test]
+ public void PlusOffForAnotherQueuedOrderSaysWhy_RCity011([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ var hex = C03.Hexes.Where(h => h.Land && (h.Q, h.R) != Hex(C03) && Projects.CitiesFor(C03, s, h.Q, h.R).Contains(City)).OrderBy(h => h.Q).ThenBy(h => h.R).First();
+ var second = s.NextId++;
+ s.CityProjects.Add(second, new CityProject(second, "housing", City, hex.Q, hex.R, 2));
+ });
+ using var panel = Panel(ui, bridge, t);
+ var (q, r) = Hex(C03);
+ panel.Show(q, r);
+ ui.Press("city-builders-more");
+ var jobs = new AssignWorkers(City, "job", 9);
+ Assert.IsNull(bridge.Queue(jobs), "precondition: 10 people, 1 ordered a builder, 9 in jobs");
+ panel.Show(q, r);
+ var press = new AssignWorkers(City, Projects.BuildRole, 2);
+ var queue = bridge.Queued.Select(x => x is AssignWorkers { Role: Projects.BuildRole } ? press : x).ToList();
+ var preview = Simulation.Preview(C03, bridge.TurnStart, bridge.Session.Committed.Concat(queue).ToList());
+ Assert.IsFalse(preview.Rejected.Any(x => ReferenceEquals(x.Command, press)), "precondition: the press itself is accepted");
+ var broken = preview.Rejected.SingleOrDefault(x => ReferenceEquals(x.Command, jobs));
+ Assert.IsNotNull(broken, "precondition: the jobs order after it is refused");
+ Assert.IsFalse(ui.Q<Button>("city-builders-more").enabledSelf);
+ Assert.AreEqual(SimBridge.ReasonText(t, broken!.Reason, C03, TownsHe), ui.Q<Label>("city-builders-reason").text);
+ if (hebrew) Assert.AreNotEqual(broken.Reason, ui.Q<Label>("city-builders-reason").text, "the Hebrew string, not the sim's English");
+ }
}
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index 31f0c1976..05eae182b 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -273,6 +273,43 @@ public class InfoPanelLayoutTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+ /// <summary>R-CITY-011 (#2477 review): a housing repair being built shows on its city's own hex, outside the folded
+ /// project list (GddHexPanel.Repairs), with its line, its builder line and the city's stepper. Under gdd-0.3, at every
+ /// window size (the stacked bars and the short windows included) 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 lies inside the panel (or the panel scrolls to
+ /// it) with its text fitting its box, as TheGddCityAndSitePanelsFitEveryWindow asks of the city's own hex.</summary>
+ [UnityTest]
+ public IEnumerator ACityHexWithARepairBeingBuiltFitsEveryWindow_RCity011()
+ {
+ var c = WorkshopPanelTests.Load03();
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ var city = c.SettlementHexes.Single(s => s.Id == "haifa");
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in Windows)
+ {
+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);
+ var id = g.State.NextId++;
+ g.State.CityProjects.Add(id, new CityProject(id, Projects.HousingRepair, city.Id, city.Q, city.R, 2));
+ var at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ yield return Rendered(w, h, g, (root, info) => info.Show(city.Q, city.R), root =>
+ {
+ var panel = root.Q("info-panel"); var window = root.worldBound;
+ foreach (var name in new[] { "city-repair-state", "city-repair-builder", "city-builders" })
+ if (root.Q(name) is not { } e || !Shown(e)) { problems.Add($"{at}: precondition: {name} shows"); return; }
+ 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}");
+ foreach (var l in panel.Query<TextElement>().ToList().Where(l => !string.IsNullOrEmpty(l.text) && Shown(l)))
+ {
+ if (!InsideOrScrollsTo(l.worldBound, root.Q<ScrollView>("info-panel"))) problems.Add($"{at}: '{l.text}' {l.worldBound} leaves the panel {panel.worldBound}");
+ if (!TextFits(l)) problems.Add($"{at}: '{l.text}' does not fit its box {l.contentRect} ({l.name})");
+ }
+ }, hebrew ? he : Text, hebrew);
+ }
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
/// <summary>GDD Phase 5 PR 15, slices 1 to 3 (#754): Golani's card at the start with its Move, Fortify and Hold buttons,
/// as it is, picking a Move's hex (the pick line under the card's lines, there from the selection too), with Fortify queued (its line), after the
/// armistices with Send home offered (#1309: its button) and queued (its line, and no other order: #1527's follow-up), on the turn
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index fc4f841fb..e3a724871 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -854,6 +854,16 @@ workshop.refused_built_one: "{0} has 1 arms workshop"
workshop.refused_built: "{0} has {1} arms workshops"
workshop.refused_people: "{0} has {1}" # the count names its noun (SimBridge.CountNoun, #2530)
workshop.refused_people_no_job: "{0} has {1}" # the count names its noun (SimBridge.CountNoun, #2530)
+# R-CITY-011 (#1700, #2477), gdd-0.3 only: a city project being built, whether it has a builder, and its city's builder
+# stepper: {0} the city's projects with a builder (or the ordered count), {1} its projects being built. The refusals are
+# the sim's own English (Projects.RefusedBeingBuilt*), {0} the city, {1} a count; past its free people the build order
+# reads as workshop.refused_people*.
+city.project_builder: "This project: has a builder"
+city.project_no_builder: "This project: no builder, waiting"
+city.builders: "Projects with a builder: {0} of {1}"
+city.builders_ordered: "Projects with a builder at End turn: {0} of {1}"
+builder.refused_being_built_one: "{0} has 1 city project being built"
+builder.refused_being_built: "{0} has {1} city projects being built"
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 d746c2c46..c335a5cb3 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -1024,6 +1024,14 @@ workshop.refused_built: "{0}: סדנאות נשק בנויות: {1}"
# issuecomment-6610635087).
workshop.refused_people: "{0}: אין די אזרחים ובעלי מלאכה (יש\u00A0{1})"
workshop.refused_people_no_job: "{0}: אין די אזרחים ובעלי מלאכה ללא משרה (יש\u00A0{1})"
+# R-CITY-011 (#1700, #2477), gdd-0.3 only: a city project being built and its city's builder stepper, as in
+# strings.en.yaml. Counts as "Label: N" (HE-04), as city.workshops_*. Agent-drafted Hebrew, for the native reviewer (#564).
+city.project_builder: "המיזם הזה: יש בונה"
+city.project_no_builder: "המיזם הזה: אין בונה, בהמתנה"
+city.builders: "מיזמים בבנייה עם בונה: {0} מתוך {1}"
+city.builders_ordered: "מיזמים בבנייה עם בונה בסיום התור: {0} מתוך {1}"
+builder.refused_being_built_one: "{0}: יש רק מיזם עירוני אחד בבנייה"
+builder.refused_being_built: "{0}: מיזמים עירוניים בבנייה: {1}"
# Agent-drafted Hebrew; native review pending (#564).
site.available: "אתר ייעודי ליישוב חדש"
site.group: "קבוצת חלוצים {0}"