A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(ui): the city panel opens for a city with an industry project (craftsman strings; fixes #1353, #1357) (#1359)
Eyal Golane1ec8edc6493
diff --git a/changelog.d/craftsman-panel-1357.md b/changelog.d/craftsman-panel-1357.mdnew file mode 100644index 000000000..1c542e556--- /dev/null+++ b/changelog.d/craftsman-panel-1357.md@@ -0,0 +1,5 @@+### Fixed++- A city that has finished an industry project opens its panel again. The panel now offers Train craftsmen there and shows+ the craftsmen in training, in English and Hebrew; before, the panel came up empty (fixes #1353 and #1357; reported by+ Beri in #1353, found while testing #1346).diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.csindex de9f30f2c..f66754a60 100644--- a/unity/Assets/Tests/EditMode/CityPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs@@ -268,6 +268,46 @@ public class CityPanelTests}}+ [Test]+ public void EveryTrainableTypeHasThePanelsStringsInBothLanguages()+ {+ // #1357: the panel words a Train button as city.train_<type> and a cohort as city.track_<type>, for every type with a+ // facility; a missing key throws (UiText) and the whole city panel fails to open. A new trainable type needs both.+ var trainable = C.UnitTypes.Where(t => t.Facility != "").Select(t => t.Id).ToList();+ CollectionAssert.Contains(trainable, Training.Craftsman, "precondition: the craftsman trains at a facility (R-CRAFT-001)");+ var missing = (from strings in new[] { ("strings.en.yaml", En), ("strings.he.yaml", He) }+ from id in trainable+ from key in new[] { "city.train_" + id, "city.track_" + id }+ where !strings.Item2.Has(key)+ select $"{strings.Item1}: {key}").ToList();+ Assert.IsEmpty(missing, string.Join(", ", missing));+ }++ [Test]+ public void ACityWithAFinishedIndustryProjectOffersCraftTraining([Values] bool hebrew)+ {+ // #1357, R-CRAFT-001: a completed industry project gives its city the craftsman's Train button and its cohorts' rows.+ var t = hebrew ? He : En;+ var type = C.UnitTypes.Single(x => x.Id == Training.Craftsman);+ Assert.IsFalse(C.Cities.Single(x => x.Id == City).Facilities.Contains(Training.Industry), "precondition: Tel Aviv's industry comes from the project");+ using var ui = new UiTestKit();+ int cohort = -1;+ var bridge = Bridge(t, s =>+ {+ var id = s.NextId++;+ s.CityProjects.Add(id, new CityProject(id, Training.Industry, City, CityHex.q, CityHex.r, 1).Built(s.Date));+ cohort = s.NextId++;+ s.Cohorts.Add(cohort, new Cohort(cohort, Training.Craftsman, City, 2, 3));+ });+ using var panel = Panel(ui, bridge, t);+ panel.Show(CityHex.q, CityHex.r);+ Assert.AreEqual(t.Format("city.train_craftsman", PlayerText.Money(C, "treasury", type.TrainingCost), GddHexPanel.Turns(t, type.TrainingTurns)),+ ui.Q<Button>("city-train-craftsman").text);+ Assert.AreEqual(t.Format("city.cohort", t["city.track_craftsman"], GddHexPanel.Groups(t, 2), GddHexPanel.Turns(t, 3)), ui.Q<Label>($"city-cohort-{cohort}").text);+ UiTestKit.Press(ui.Q<Button>("city-train-craftsman"));+ Assert.IsNotNull(bridge.QueuedLike(new Train(City, Training.Craftsman, 1)), "the press queues craft training");+ }+[Test]public void ACohortShowsItsTurnsLeftAndCancelQueuesCancelTraining(){diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 8bdf7f82a..c56aaf897 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -487,9 +487,11 @@ city.recruits: "Recruits: {0}"city.workers: "In work: {0}"city.train_recruit: "Train recruits: 1 group, {0}, {1}"city.train_halutz: "Train halutzim: 1 group, {0}, {1}"+city.train_craftsman: "Train craftsmen: 1 group, {0}, {1}"city.train_ordered: "{0} ordered"city.track_recruit: "Recruits"city.track_halutz: "Halutzim"+city.track_craftsman: "Craftsmen"city.cohort: "{0}: {1} in training, {2} left"city.cancel: "Cancel"city.groups_one: "1 group"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex f507aea78..10f3ed969 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -523,9 +523,13 @@ city.recruits: "מגויסים: {0}"city.workers: "בעבודה: {0}"city.train_recruit: "אימון מגויסים: קבוצה אחת, {0}, {1}"city.train_halutz: "הכשרת חלוצים: קבוצה אחת, {0}, {1}"+# Craft training (R-CRAFT-001, #1357), with city.craftsmen's approved בעל מלאכה in the plural. For the native reviewer (#564).+city.train_craftsman: "הכשרת בעלי מלאכה: קבוצה אחת, {0}, {1}"city.train_ordered: "הוזמנו {0}"city.track_recruit: "מגויסים"city.track_halutz: "חלוצים"+# For the native reviewer (#564).+city.track_craftsman: "בעלי מלאכה"city.cohort: "{0}: {1} באימון, עוד {2}"city.cancel: "ביטול"city.groups_one: "קבוצה אחת"