A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
City panel: the workers line also shows the Train order's Attention price (Fixes #2977) (#2998)
nikitaa00101-source997fb954de47
diff --git a/changelog.d/city-panel-train-attention-price.md b/changelog.d/city-panel-train-attention-price.mdnew file mode 100644index 000000000..653818123--- /dev/null+++ b/changelog.d/city-panel-train-attention-price.md@@ -0,0 +1,5 @@+### Fixed++- The city panel now shows what a Train order costs in Attention: the workers line reads "Workers change: 1.0 Attention ·+ Each Train order: 2.0 Attention" at security level 5. Before, its only price was the workers change's, just above the+ Train buttons, so a player with 1.0 Attention left saw "Order cost: 1.0" while every Train button was greyed out.diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csindex 6f7286d08..55ace7c40 100644--- a/unity/Assets/Scripts/UI/GddHexPanel.cs+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -129,9 +129,22 @@ namespace Statecraft.Game.UIOrderButton(workers, bridge, "city-workers-more", "+", target < max, () => Workers(bridge, id, city.Employed, target + 1));// The Assign order's Attention price (the queue's, at this turn's start) and when it applies (playtest B7): the// Jobs line stays the sim's actual count until End turn. Changing a queued target does not buy another order.- Line(host, "city-workers-cost", bridge.Content.UsesAttention+ // The line names the workers change, and where the city trains it adds the Train order's price: every Train order+ // costs the same, by its kind (AttentionSystem.Price), and at security level 5 it is 2.0 to the workers change's 1.0+ // (each kind's cost is R-GOV-002's; content/rules.yaml's rung_attention_step raises it by a quarter a level above+ // the first, AttentionSystem.Cost), so the one price no longer reads as Train's. On the existing line, as a new+ // line or a price on each Train button would push the city panel into the top bar in short windows+ // (InfoPanelLayoutTests). gdd-0.3 has no Attention.+ // The unit types the city can train (Training.HasFacility: its own facility, D-D5, or a built camp site's,+ // R-CAMP-001): the Train price shows where the Train buttons below show.+ var trainTypes = c.UnitTypes.Where(t => t.Facility != "" && Training.HasFacility(c, s, id, t.Facility)).ToList();+ var trainType = trainTypes.FirstOrDefault();+ var workersCost = bridge.Content.UsesAttention? text.Format("city.workers_cost", bridge.Price(new AssignWorkers(id, "job", target))!.Value)- : text.Format("city.workers_ordered", Groups(text, target)));+ : text.Format("city.workers_ordered", Groups(text, target));+ if (trainType != null && bridge.Price(new Train(id, trainType.Id, 1)) is double trainPrice)+ workersCost = text.Format("city.train_cost", workersCost, trainPrice);+ Line(host, "city-workers-cost", workersCost);// Train, for each facility the city has (Training.HasFacility: its own, D-D5, or a built camp site's, R-CAMP-001):// each press orders one more group. The exact preview below asks whether End turn would refuse that order, and@@ -143,7 +156,7 @@ namespace Statecraft.Game.UI// counts. The old order's own count is in the queue, so one more group needs one free.var current = Simulation.Preview(c, bridge.TurnStart, bridge.Session.Committed.Concat(bridge.Queued).ToList());var free = Training.Available(s, id, bridge.Queued.Where(x => !current.Rejected.Any(r => ReferenceEquals(r.Command, x))));- foreach (var type in c.UnitTypes.Where(t => t.Facility != "" && Training.HasFacility(c, s, id, t.Facility)))+ foreach (var type in trainTypes){var old = bridge.QueuedLike(new Train(id, type.Id, 1));var ordered = (old as Train)?.Count ?? 0;diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.csindex a4ecc655a..533b0c11a 100644--- a/unity/Assets/Tests/EditMode/CityPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs@@ -1550,7 +1550,9 @@ public class CityPanelTestsvar city = bridge.State.Cities["tel_aviv"]; int before = city.Employed;Assert.Greater(before, 0, "precondition: there is a worker to remove");Assert.IsNotNull(ui.Q<Label>("city-workers-cost"), "the order price and timing are visible, not only in a tooltip");- Assert.AreEqual(text.Format("city.workers_cost", bridge.Price(new AssignWorkers("tel_aviv", "job", before))!.Value), ui.Q<Label>("city-workers-cost").text);+ // Tel Aviv trains, so the line also carries the Train order's price (TheWorkersLineAlsoPricesATrainOrder).+ Assert.AreEqual(text.Format("city.train_cost", text.Format("city.workers_cost", bridge.Price(new AssignWorkers("tel_aviv", "job", before))!.Value),+ bridge.Price(new Train("tel_aviv", "recruit", 1))!.Value), ui.Q<Label>("city-workers-cost").text);UiTestKit.Press(ui.Q<Button>("city-workers-less"));Assert.AreEqual(before, city.Employed, "queued work does not pretend the simulation already ran");Assert.AreEqual(text.Format("city.workers_ordered", GddHexPanel.Groups(text, before - 1)), ui.Q<Label>("city-workers").text);@@ -1568,4 +1570,61 @@ public class CityPanelTestsAssert.AreEqual(text.Format("city.workers", GddHexPanel.Groups(text, before)), ui.Q<Label>("city-workers").text);}+ [Test]+ public void TheWorkersLineAlsoPricesATrainOrder([Values] bool hebrew)+ {+ // Playtest: at security level 5 the only price on the panel was the Assign order's (0.5 x 2 = 1.0), right above the+ // Train buttons, though a Train order costs 1 x 2 = 2.0 (R-GOV-002's cost of 1, doubled at level 5 by+ // content/rules.yaml's rung_attention_step through AttentionSystem.Cost): with 1.0 left the Train buttons were+ // disabled with nothing on the panel to say why. The workers line now names the change it prices and adds the Train order's+ // price, which every Train button shares. It stays one line of the panel, so the panel still fits short windows.+ var t = hebrew ? He : En; var bridge = Bridge(t);+ Assert.AreEqual(5, bridge.TurnStart.Rung, "precondition: the game starts at security level 5");+ using var ui = new UiTestKit(); using var panel = Panel(ui, bridge, t);+ panel.Show(CityHex.q, CityHex.r);+ var train = bridge.Price(new Train(City, "recruit", 1))!.Value;+ Assert.AreEqual(2.0, train, 1e-9, "precondition: train costs 1, doubled at level 5");+ foreach (var track in new[] { "halutz", "artillery", "armoured_car", "craftsman" })+ Assert.AreEqual(train, bridge.Price(new Train(City, track, 1))!.Value, 1e-9, "precondition: every Train order costs the same: " + track);+ var employed = bridge.State.Cities[City].Employed;+ var workers = bridge.Price(new AssignWorkers(City, "job", employed))!.Value;+ Assert.AreEqual(1.0, workers, 1e-9, "precondition: assign_workers costs 0.5, doubled at level 5");+ var line = t.Format("city.train_cost", t.Format("city.workers_cost", workers), train);+ Assert.AreEqual(line, ui.Q<Label>("city-workers-cost").text);+ Assert.IsNull(ui.Root.Q<Label>("city-train-cost"), "no extra line: the price is on the workers line");+ UiTestKit.Press(ui.Q<Button>("city-train-recruit"));+ Assert.AreEqual(line, ui.Q<Label>("city-workers-cost").text, "a queued Train order keeps the line");+ UiTestKit.Press(ui.Q<Button>("city-workers-less"));+ Assert.AreEqual(line, ui.Q<Label>("city-workers-cost").text, "a queued workers change keeps the line");+ }++ [Test]+ public void ACityThatCannotTrainShowsOnlyTheWorkersPrice([Values] bool hebrew)+ {+ // The Train price belongs where the panel offers Train: a city with no training facility shows the workers price alone.+ var t = hebrew ? He : En;+ var start = GameSession.New(C, GoldenRun.Seed, Mode.Historical).State;+ var hex = C.SettlementHexes.Where(h => start.Cities.ContainsKey(h.Id) && C.SettlementHexes.Count(x => x.Q == h.Q && x.R == h.R) == 1)+ .FirstOrDefault(h => !C.UnitTypes.Any(u => u.Facility != "" && Training.HasFacility(C, start, h.Id, u.Facility)));+ Assert.IsNotNull(hex, "precondition: some city alone on its hex has no training facility");+ var bridge = Bridge(t);+ using var ui = new UiTestKit(); using var panel = Panel(ui, bridge, t);+ panel.Show(hex!.Q, hex.R);+ Assert.IsNull(ui.Root.Query<Button>().Where(b => b.name.StartsWith("city-train-", StringComparison.Ordinal)).First(), "precondition: no Train button");+ var workers = bridge.Price(new AssignWorkers(hex.Id, "job", bridge.State.Cities[hex.Id].Employed))!.Value;+ Assert.AreEqual(t.Format("city.workers_cost", workers), ui.Q<Label>("city-workers-cost").text);+ }++ [Test]+ public void WithoutAttentionTheWorkersLineHasNoTrainPrice([Values] bool hebrew)+ {+ // gdd-0.3 has no Attention (#1688, #1750): the workers line keeps its timing only, with no price of either order.+ var t = hebrew ? He : En; var c = Gdd03Content();+ Assert.IsFalse(c.UsesAttention, "precondition: gdd-0.3 has no Attention");+ var bridge = new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), t);+ using var ui = new UiTestKit(); using var panel = Panel(ui, bridge, t);+ panel.Show(CityHex.q, CityHex.r);+ Assert.AreEqual(t.Format("city.workers_ordered", GddHexPanel.Groups(t, bridge.State.Cities[City].Employed)), ui.Q<Label>("city-workers-cost").text);+ }+}diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 6b6288bf9..5995be4c5 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -1073,7 +1073,9 @@ advisor.dayan.arms_out.cue.2: "Buying Arms with Money before the stock runs shor# Playtest B7: the jobs stepper's queued count and the Assign order's price and timing.city.workers_ordered: "At End turn: {0}"-city.workers_cost: "At End turn · Order cost: {0:0.0} Attention"+city.workers_cost: "At End turn · Workers change: {0:0.0} Attention"+# Where the city trains, the workers line {0} adds the Train order's Attention price (every Train order costs the same).+city.train_cost: "{0} · Each Train order: {1:0.0} Attention"share.site_picture: "Picture copied: paste it into the post"share.site_text: "Only the text was copied. Use Share or Download the picture."diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 84cbd1833..72606ffa4 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -1272,9 +1272,14 @@ advisor.dayan.arms_out.cue.1: "אימון צבאי דורש נשק, ונשק נadvisor.dayan.arms_out.cue.2: "קניית נשק בכסף לפני שהמלאי אוזל שומרת את האפשרויות האלה פתוחות."# Playtest B7: the jobs stepper's queued count and the Assign order's price and timing.-# Approved: owner, 25 Oct 2026 (recommendations page, item 5); the price in one decimal, as the HUD and the cards show Attention.+# Approved: owner, 25 Oct 2026 (recommendations page, item 5), for city.workers_ordered and city.workers_cost's earlier wording+# ("עלות ההוראה"), not its rewording below; the price in one decimal, as the HUD and the cards show Attention.city.workers_ordered: "בסיום התור: {0}"-city.workers_cost: "בסיום התור · עלות ההוראה: {0:0.0} תשומת לב"+# city.workers_cost reworded to name the workers change: agent-drafted Hebrew, native-review-pending (#564).+city.workers_cost: "בסיום התור · שינוי מספר העובדים: {0:0.0} תשומת לב"+# Where the city trains, the workers line {0} adds the Train order's Attention price (every Train order costs the same).+# It names both words the Train buttons use, אימון and הכשרה. Agent-drafted Hebrew, native-review-pending (#564).+city.train_cost: "{0} · כל הוראת אימון או הכשרה: {1:0.0} תשומת לב"# #1653 Hebrew drafts (#564), review state per key.# Agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved as drafted).