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 workshop's staffing line follows the queued order (Refs #2711) (#2926)
Berid93035ad3e19
diff --git a/changelog.d/2711-workshop-queued-staffing.md b/changelog.d/2711-workshop-queued-staffing.mdnew file mode 100644index 000000000..ab242da18--- /dev/null+++ b/changelog.d/2711-workshop-queued-staffing.md@@ -0,0 +1,5 @@+### Fixed++- Under the gdd-0.3 rules, with a workshop staffing order queued, each arms workshop's hex panel now says whether that+ order staffs it at End turn (the city's first workshops by id, R-ARMS-005), matching the count above it, instead of+ its current state (Refs #2711).diff --git a/sim/Statecraft.Sim/Workshops.cs b/sim/Statecraft.Sim/Workshops.csindex 080c6fcac..a899c7b87 100644--- a/sim/Statecraft.Sim/Workshops.cs+++ b/sim/Statecraft.Sim/Workshops.cs@@ -94,6 +94,12 @@ namespace Statecraft.Simpublic static int Staffed(GameState s, string city) =>s.Workshops.Values.Count(w => w.Staffed && s.CityProjects[w.Project].City == city);+ /// <summary>R-ARMS-005: whether AssignWorkers(its city, "workshop", <paramref name="count"/>) staffs the built workshop+ /// <paramref name="project"/>, one of its city's first count built workshops in ascending id (#2711: the UI's word for a+ /// queued order).</summary>+ public static bool Staffs(Content c, GameState s, CityProject project, int count) =>+ BuiltIn(c, s, project.City).FindIndex(p => p.Id == project.Id) is int i && i >= 0 && i < count;+// #2530: a count of 1 names the singular, as the UI's helper does.static string Groups(int n) => n == 1 ? "1 group" : FormattableString.Invariant($"{n} groups");diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csindex 65b33c387..6f7286d08 100644--- a/unity/Assets/Scripts/UI/GddHexPanel.cs+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -467,7 +467,8 @@ namespace Statecraft.Game.UI/// city's first n built workshops in ascending id, so the stepper is the city's count (Workshops.Staffed, or the queued/// order's) of Workshops.Built; stepping back to the current count withdraws the order. + is off where Workshops.Check,/// asked with this turn's queue, refuses one more, and while a workshop is left unstaffed that refusal shows in the UI's- /// language (SimBridge.ReasonText). This workshop: staffed or not (its Workshop record), its cycle under way (staffed+ /// language (SimBridge.ReasonText). This workshop: staffed or not (its Workshop record, or with an order queued what the+ /// order makes it, Workshops.Staffs), its cycle under way (staffed/// months of Workshops.CycleMonths and the Money paid) or, staffed before or not, the next cycle's price/// (Workshops.NextCyclePrice, what the production step would charge), the pause while the enemy holds its city/// (Cities.Held, R-CITY-010), and the last turn's pauses for its city as the Why screen words them@@ -489,7 +490,10 @@ namespace Statecraft.Game.UIif (refusal != null && target < built) Line(host, "city-workshops-reason", SimBridge.ReasonText(text, refusal, c, bridge.TownNamesHe));s.Workshops.TryGetValue(project.Id, out var w);- Line(host, "city-workshop-state", text[w?.Staffed == true ? "city.workshop_staffed" : "city.workshop_unstaffed"]);+ // #2711 item 1: with an order queued, the line follows it as the count above does (Workshops.Staffs), not the record.+ Line(host, "city-workshop-state", text[queued != null+ ? (Workshops.Staffs(c, s, project, target) ? "city.workshop_ordered_staffed" : "city.workshop_ordered_unstaffed")+ : w?.Staffed == true ? "city.workshop_staffed" : "city.workshop_unstaffed"]);if (w != null && w.PaidCost is decimal paid)Line(host, "city-workshop-cycle", text.Format("city.workshop_cycle", w.Progress, Workshops.CycleMonths(c)!.Value, PlayerText.Money(c, "treasury", (double)paid)));else if (Workshops.NextCyclePrice(c, s, project.Id) is decimal next)diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs b/unity/Assets/Tests/EditMode/CityProjectPanelTests.csindex 756863829..74a611df5 100644--- a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs@@ -864,6 +864,38 @@ public class WorkshopPanelTests}}+ // #2711 item 1 (R-ARMS-005): with a staffing order queued, each workshop's line follows the order, as the count above it+ // does, not the sim's current record. Two built, none staffed, one ordered: the first by id is staffed at End turn and+ // the second is not, and End turn agrees.+ [Test]+ public void WithAStaffingOrderQueuedEachWorkshopShowsWhatTheOrderMakesIt([Values] bool hebrew)+ {+ var t = hebrew ? He : En;+ var second = 0;+ var (bridge, first) = Game(C03, t, employed: 8, edit: (s, _) => second = SecondWorkshop(C03, s));+ using (var ui = new UiTestKit())+ {+ using var panel = Panel(ui, bridge, t);+ var (q, r) = Hex(C03);+ panel.Show(q, r);+ Assert.AreEqual(t["city.workshop_unstaffed"], ui.Q<Label>("city-workshop-state").text, "no order: the sim's record");+ ui.Press("city-workshops-more");+ Assert.AreEqual(1, Queued(bridge)!.Count);+ }+ foreach (var (id, key) in new[] { (first, "city.workshop_ordered_staffed"), (second, "city.workshop_ordered_unstaffed") })+ {+ using var ui = new UiTestKit();+ using var panel = Panel(ui, bridge, t);+ var hex = bridge.State.CityProjects[id];+ panel.Show(hex.Q, hex.R);+ Assert.AreEqual(t.Format("city.workshops_ordered", 1, 2), ui.Q<Label>("city-workshops").text);+ Assert.AreEqual(t[key], ui.Q<Label>("city-workshop-state").text, id == first ? "the first by id" : "past the order's count");+ }+ var turn = bridge.EndTurn();+ Assert.IsTrue(turn.State.Workshops[first].Staffed);+ Assert.IsFalse(turn.State.Workshops.TryGetValue(second, out var w) && w.Staffed);+ }+// R-ARMS-005 (#1722 review, C7): two built, one person free. + orders one; with that order queued, + is off and the// sim's refusal for a second shows (one of two ordered, so a workshop is still left unstaffed).[Test]diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 8127cd683..c07add4ae 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -846,6 +846,9 @@ city.workshops_staffed: "Arms workshops staffed: {0} of {1}"city.workshops_ordered: "Arms workshops staffed at End turn: {0} of {1}"city.workshop_staffed: "This workshop: staffed"city.workshop_unstaffed: "This workshop: not staffed, paused"+# #2711 item 1: with a staffing order queued, what the order makes this workshop (R-ARMS-005: the first n by id).+city.workshop_ordered_staffed: "This workshop: staffed at End turn"+city.workshop_ordered_unstaffed: "This workshop: not staffed at End turn, paused"city.workshop_cycle: "Cycle: {0} of {1} staffed months · paid {2}"city.workshop_next: "No cycle under way · next cycle: {0}"city.workshop_held: "Paused: the enemy holds {0}"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 658610872..b5a8b1000 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -1014,6 +1014,9 @@ city.workshops_staffed: "סדנאות נשק מאוישות: {0} מתוך {1}"city.workshops_ordered: "סדנאות נשק מאוישות בסיום התור: {0} מתוך {1}"city.workshop_staffed: "הסדנה הזאת: מאוישת"city.workshop_unstaffed: "הסדנה הזאת: לא מאוישת, בהמתנה"+# #2711 item 1, as in strings.en.yaml. Agent-drafted Hebrew, for the native reviewer (#564).+city.workshop_ordered_staffed: "הסדנה הזאת: מאוישת בסיום התור"+city.workshop_ordered_unstaffed: "הסדנה הזאת: לא מאוישת בסיום התור, בהמתנה"city.workshop_cycle: "חודשים מאוישים במחזור: {0} מתוך {1} · שולם: {2}"city.workshop_next: "אין מחזור עבודה פעיל · עלות המחזור הבא: {0}"city.workshop_held: "בהמתנה: {0} בשליטת האויב"