A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: the GDD city and site panel, the site layer and the built site's pill (GDD Phase 1 PR 8, refs #381) (#869)
Eyal Golan55780c2a3d81
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 56979d087..9a1bd0566 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -289,6 +289,17 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBsensitivity review (owner, 17 October 2026), so no token, spot or kit clearing changes. `UnitData` reads `strength`,`echelon` and the sides `ala` and `local_arab_forces` (Q-START-4). At the first truce the Egyptian row stands atboth its forward base, Isdud, and its rear base, Majdal (owner, 17 October 2026, on #860). The rows are drafts.+- The GDD loop's city and site panels (GDD Phase 1 PR 8, refs #381). On a city hex the info panel shows the housing+ (`Cities.Housed`, R-HOUSE-003: civilians, recruits and groups in training) against capacity, the housing condition+ (R-HOUSE-001), jobs, refugees waiting and recruits, and each training cohort with its turns left, with an Assign+ stepper, Train recruits and Train halutzim (where `Training.HasFacility` says the city has the camp or Hakhshara, a built camp site+ included) and Cancel. On the designated site's hex it shows+ the site's state, Build with each idle pioneer group (halutz or veteran) at the rules' cost and that group's own turns,+ and Stop while it is built. Every number is the sim's, and every order goes through the queue. The limits come from+ new public sim helpers that the rules call too, so nothing is repeated in the UI: `Cities.MaxWorkers` (R-CITY-001),+ `Training.Idle` and `Training.Available` (R-TRAIN-001, counting both tracks' and the Assign order in the queue),+ `Projects.TurnsToBuild` (R-SITE-003, R-VET-002) and `Projects.IsYishuvSite`. They change no rule, so the goldens do not+ move. A new `SiteLayer` draws a site being built as a timber scaffold and a built site as a rural kit on its hex.- A Settings screen, opened from a gear at the foot of the left column (refs #40, first slice). Its first option turnsthe tilt-shift blur off and on, at once; the choice is kept per browser in `/idbfs/statecraft-settings/settings.txt`(a fixed folder, as the autosave's), never in the sim or the save, so the goldens do not move. `?notiltshift` stilldiff --git a/README.he.md b/README.he.mdindex 5e5831502..c2deffac4 100644--- a/README.he.md+++ b/README.he.md@@ -85,7 +85,7 @@ flowchart RL| שלב | מה הוא מוסיף | מצב | Issue ||---|---|---|---|| 0 | החלטות הבעלים בסעיפים הפתוחים ב־GDD | בתהליך: ההחלטות של שלב 1 התקבלו | [#375](https://github.com/eyalgolan/statecraft-israel/issues/375) |-| 1 | פרוסה ראשונה מאחורי מתג: עיר אחת (תל אביב), אימון, יישוב חדש אחד וכרטיס יעד אחד | בתהליך: 7 מתוך 8 PRs מוזגו | [#374](https://github.com/eyalgolan/statecraft-israel/issues/374) |+| 1 | פרוסה ראשונה מאחורי מתג: עיר אחת (תל אביב), אימון, יישוב חדש אחד וכרטיס יעד אחד | בתהליך: 8 מתוך 8 PRs מוזגו | [#374](https://github.com/eyalgolan/statecraft-israel/issues/374) || 2 | תורות חודשיים במשחק האמיתי, וחמשת המשאבים | בתהליך: התורות החודשיים והכסף הושלמו | [#382](https://github.com/eyalgolan/statecraft-israel/issues/382) || 3 | כל הערים, עם דיור, תעסוקה וקליטת עלייה | בהמשך | [#383](https://github.com/eyalgolan/statecraft-israel/issues/383) || 4 | חלוצים, אתרי בנייה, כבישים ומסילות ברזל | בהמשך | [#384](https://github.com/eyalgolan/statecraft-israel/issues/384) |diff --git a/README.md b/README.mdindex 133fb8f53..733229d35 100644--- a/README.md+++ b/README.md@@ -104,7 +104,7 @@ flowchart LR| Phase | What it adds | Status | Issue ||---|---|---|---|| 0 | Owner decisions on the open GDD items | In progress: the Phase 1 decisions are made | [#375](https://github.com/eyalgolan/statecraft-israel/issues/375) |-| 1 | A first slice behind a switch: one city (Tel Aviv), training, one new settlement and one objective card | In progress: 7 of 8 PRs merged | [#374](https://github.com/eyalgolan/statecraft-israel/issues/374) |+| 1 | A first slice behind a switch: one city (Tel Aviv), training, one new settlement and one objective card | In progress: 8 of 8 PRs merged | [#374](https://github.com/eyalgolan/statecraft-israel/issues/374) || 2 | Monthly turns for the real game, and the five resources | In progress: monthly turns and Money are done | [#382](https://github.com/eyalgolan/statecraft-israel/issues/382) || 3 | Every city, with housing, jobs and immigrant absorption | Later | [#383](https://github.com/eyalgolan/statecraft-israel/issues/383) || 4 | Pioneers, building sites, roads and railways | Later | [#384](https://github.com/eyalgolan/statecraft-israel/issues/384) |diff --git a/sim/Statecraft.Sim.Tests/CitiesTests.cs b/sim/Statecraft.Sim.Tests/CitiesTests.csindex dbddb45ff..66504251e 100644--- a/sim/Statecraft.Sim.Tests/CitiesTests.cs+++ b/sim/Statecraft.Sim.Tests/CitiesTests.cs@@ -55,6 +55,40 @@ public class CitiesTestsAssert.Equal(Step(c, s).State.Hash(), r.State.Hash()); // as if the order had not been given: Attention refunded too}+ // R-CITY-001: MaxWorkers is the limit Assign applies, so the panel can ask it instead of repeating the rule (#869). Town A+ // has 20 jobs and 10 civilians; with 30 civilians the jobs are the limit.+ [Theory]+ [InlineData(10, 10)]+ [InlineData(30, 20)]+ public void MaxWorkersIsTheCountAssignAccepts(int civilians, int max)+ {+ var c = Town(Fixture.City("town_a", 40, 20, civilians, 6));+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ Assert.Equal(max, Cities.MaxWorkers(s.Cities["town_a"]));+ Assert.Empty(Step(c, s, new AssignWorkers("town_a", "job", max)).Rejected);+ Assert.Single(Step(c, s, new AssignWorkers("town_a", "job", max + 1)).Rejected);+ }++ // R-CITY-001 with R-TRAIN-001: the queue's Train orders take their civilians first, so an Assign up to MaxWorkers(s, city,+ // pending) and those orders are all accepted, in either order, and one more group is refused.+ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void MaxWorkersWithTheQueueCountsItsTrainOrders(bool assignFirst)+ {+ var c = Town(Fixture.City("town_a", 12, 20, 10, 6, "[military_camp, hakhshara]"));+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Attention = 100; // enough for three orders: Attention is not what this test is about+ var trains = new Command[] { new Train("town_a", "recruit", 2), new Train("town_a", "halutz", 1), new Train("elsewhere", "recruit", 5) };+ var max = Cities.MaxWorkers(s, "town_a", trains);+ Assert.Equal(7, max); // 10 civilians, 3 of them ordered to train; the other city's order does not count+ Command[] Orders(int n) => assignFirst+ ? new Command[] { new AssignWorkers("town_a", "job", n), trains[0], trains[1] }+ : new Command[] { trains[0], trains[1], new AssignWorkers("town_a", "job", n) };+ Assert.Empty(Step(c, s, Orders(max)).Rejected);+ Assert.Single(Step(c, s, Orders(max + 1)).Rejected);+ }+// R-CITY-001[Fact]public void TheLegacyLoopRefusesTheOrderAndRefundsAttention()diff --git a/sim/Statecraft.Sim.Tests/TrainingTests.cs b/sim/Statecraft.Sim.Tests/TrainingTests.csindex 30fa20afd..34d333829 100644--- a/sim/Statecraft.Sim.Tests/TrainingTests.cs+++ b/sim/Statecraft.Sim.Tests/TrainingTests.cs@@ -65,6 +65,41 @@ public class TrainingTestsAssert.Equal(Step(c, s).State.Hash(), r.State.Hash()); // as if the order had not been given: Attention refunded too}+ // R-TRAIN-001: Idle is the limit Train applies (Town A: 10 civilians, 6 employed), so the panel can ask it (#869).+ [Fact]+ public void IdleIsTheCountTrainAccepts()+ {+ var c = Town();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ Assert.Equal(4, Training.Idle(s.Cities["town_a"]));+ Assert.Empty(Step(c, s, new Train("town_a", "recruit", 4)).Rejected);+ Assert.Single(Step(c, s, new Train("town_a", "recruit", 5)).Rejected);+ }++ // R-TRAIN-001 with R-CITY-001: Available counts both tracks' Train orders and an Assign order's rise in jobs in the queue,+ // so orders up to it are all accepted, in either order, and one group more is refused (#869: recruits and halutzim were+ // each checked alone).+ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void AvailableCountsEveryTrackAndTheAssignOrder(bool assignFirst)+ {+ var c = Town();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Attention = 100; // enough for three orders: Attention is not what this test is about+ Assert.Equal(4, Training.Available(s, "town_a", new Command[0]));+ Assert.Equal(1, Training.Available(s, "town_a", new Command[] { new Train("town_a", "recruit", 2), new Train("town_a", "halutz", 1) }));+ Assert.Equal(4, Training.Available(s, "town_a", new Command[] { new Train("elsewhere", "recruit", 2) }));+ Assert.Equal(4, Training.Available(s, "town_a", new Command[] { new AssignWorkers("town_a", "job", 3) })); // fewer jobs free no one before the turn+ var assign = new AssignWorkers("town_a", "job", 7);+ Assert.Equal(2, Training.Available(s, "town_a", new Command[] { assign, new Train("town_a", "recruit", 1) })); // 10 civilians - 7 in jobs - 1 recruit+ Command[] Orders(int halutzim) => assignFirst+ ? new Command[] { assign, new Train("town_a", "recruit", 1), new Train("town_a", "halutz", halutzim) }+ : new Command[] { new Train("town_a", "recruit", 1), new Train("town_a", "halutz", halutzim), assign };+ Assert.Empty(Step(c, s, Orders(2)).Rejected);+ Assert.Single(Step(c, s, Orders(3)).Rejected);+ }+// R-TRAIN-001[Theory][InlineData("[military_camp]", "halutz", "Town A has no Hakhshara")]diff --git a/sim/Statecraft.Sim.Tests/VeteranTests.cs b/sim/Statecraft.Sim.Tests/VeteranTests.csindex beac6df65..14f35411f 100644--- a/sim/Statecraft.Sim.Tests/VeteranTests.cs+++ b/sim/Statecraft.Sim.Tests/VeteranTests.cs@@ -94,6 +94,29 @@ public class VeteranTestsAssert.Equal(3, TurnsToBuild("veteran_halutz")); // 6 turns of progress at 2 a turn}+ // R-SITE-003, R-VET-001, R-VET-002: TurnsToBuild is Advance's count, for a new build and for one under way, so the panel+ // can show it (#869: it showed build_yishuv_turns for every group). A halutz promoted during the build speeds up.+ [Theory]+ [InlineData("halutz", 0, "veteran_halutz_service: 4", 3)]+ [InlineData("veteran_halutz", 0, "veteran_halutz_service: 4", 2)] // 3 turns of progress at 2 a turn+ [InlineData("halutz", 0, "veteran_halutz_service: 1", 2)] // promoted after its first turn: 1, then 2+ [InlineData("halutz", 1, "veteran_halutz_service: 2", 2)] // service carried from an earlier build+ public void TurnsToBuildIsTheTurnsAdvanceTakes(string type, int service, string serviceRule, int expected)+ {+ var c = Town(("veteran_halutz_service: 4", serviceRule));+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ var id = s.NextId++;+ s.Units.Add(id, new Unit(id, type, 1, 0, service));+ Assert.Equal(expected, Projects.TurnsToBuild(c, s, id, c.Rules.Mvp!.BuildYishuvTurns));+ s = Step(c, s, Build(id)).State;+ for (int done = 1; ; done++)+ {+ if (s.Sites["site_a"].BuiltOn != null) { Assert.Equal(expected, done); break; }+ Assert.Equal(expected - done, Projects.TurnsToBuild(c, s, id, s.Sites["site_a"].TurnsLeft)); // the turns left under way+ s = Step(c, s).State;+ }+ }+// R-VET-001, R-VET-002: both values are required in the GDD loop and at least 1, so a missing key is never read as 0.[Theory][InlineData(" veteran_halutz_service: 4\n", "", "mvp.veteran_halutz_service", "required when eras.yaml systems.loop is gdd")]diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex 87be3605e..db26340b3 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -10,6 +10,19 @@ namespace Statecraft.Sim{public const string Kind = "assign_workers";+ /// <summary>R-CITY-001: the most of the city's civilians AssignWorkers accepts in jobs: its job slots, and no more than+ /// its civilians.</summary>+ public static int MaxWorkers(City city) => Math.Min(city.JobSlots, city.Civilians);++ /// <summary>R-CITY-001 with R-TRAIN-001: <see cref="MaxWorkers(City)"/> once the city's Train orders in+ /// <paramref name="pending"/> (this turn's queue) have taken their civilians, so a count up to it keeps every one of+ /// them accepted, whatever order they run in. Other orders do not count.</summary>+ public static int MaxWorkers(GameState s, string city, IEnumerable<Command> pending)+ {+ var x = s.Cities[city];+ return Math.Max(0, Math.Min(x.JobSlots, x.Civilians - Training.Ordered(city, pending)));+ }+/// <summary>R-CITY-007: a city's start people in units: the nearest unit (a half rounds up), and at least 1 for a city/// with people (Q-START-2, owner, 15 October 2026), so a small town is not left empty.</summary>public static int StartUnits(decimal people, int peoplePerUnit) => people > 0 ? Math.Max(1, NearestUnit(people, peoplePerUnit)) : 0;@@ -36,8 +49,10 @@ namespace Statecraft.Simif (!s.Cities.TryGetValue(city, out var x)) return "There is no such city";if (role != "job") return "There is no such role"; // craftsman: Phase 3 (D-D4)if (count < 0) return "The number of workers cannot be negative";- if (count > x.JobSlots) return FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.JobSlots} jobs");- if (count > x.Civilians) return FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.Civilians} civilians");+ if (count > MaxWorkers(x))+ return count > x.JobSlots+ ? FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.JobSlots} jobs")+ : FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.Civilians} civilians");s.Cities[city] = x.WithCounts(x.Civilians, count, x.Refugees);why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {count} groups in work")));return null;diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex 72aca8bfd..fcdfb3c7f 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -31,6 +31,35 @@ namespace Statecraft.Sim/// <summary>The kind of site a field may be plowed at (sites.yaml kinds). Built, a field site is plowed (R-FIELD-001).</summary>public const string FieldKind = "field";+ /// <summary>Whether a yishuv may be built at <paramref name="site"/>: its kinds name one (R-SITE-001, R-SITE-004). A hex may+ /// hold more than one site, as a yishuv hex holds a field one; the panel finds the yishuv by this, not by file order.</summary>+ public static bool IsYishuvSite(Site site) => site.Kinds.Contains(YishuvKind);++ /// <summary>The turns of progress <paramref name="unit"/>'s project gains in one turn: veteran_progress for a veteran,+ /// else 1 (R-SITE-003, R-VET-002).</summary>+ public static int Progress(MvpRules r, Unit unit) => unit.Type == VeteranType ? r.VeteranProgress!.Value : 1;++ /// <summary>The turns, this one included, in which <paramref name="unit"/> builds a site with <paramref name="left"/>+ /// turns of progress to go: Advance's count, a halutz promoted on the way (R-VET-001) building faster from the next turn+ /// (R-SITE-003, R-VET-002). With build_yishuv_turns it is how long a Build ordered now takes. Read with the rules of+ /// the current date, as Advance reads them; it changes no state.</summary>+ public static int TurnsToBuild(Content c, GameState s, int unit, int left)+ {+ var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop+ var u = s.Units[unit];+ for (int turns = 1; ; turns++)+ {+ var progress = Progress(r, u);+ if (left <= progress) return turns;+ left -= progress;+ if (u.Type == "halutz")+ {+ var service = u.Service + 1;+ u = new Unit(u.Id, service >= r.VeteranHalutzService!.Value ? VeteranType : u.Type, u.Q, u.R, service);+ }+ }+ }+/// <summary>Whether a site 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);@@ -52,7 +81,7 @@ namespace Statecraft.Simif (place == null) return "There is no such site";var camp = action == BuildCamp;var plow = action == PlowFields;- if (camp ? !IsCamp(place) : !place.Kinds.Contains(plow ? FieldKind : YishuvKind))+ if (camp ? !IsCamp(place) : plow ? !place.Kinds.Contains(FieldKind) : !IsYishuvSite(place))return camp ? $"{place.Name} is not a site for a training camp": plow ? $"{place.Name} is not a site for fields" : $"{place.Name} is not a site for a new yishuv";if (s.Sites.TryGetValue(site, out var work))@@ -107,7 +136,7 @@ namespace Statecraft.Simforeach (var w in s.Sites.Values.Where(x => x.BuiltOn == null).ToList()){var u = s.Units[w.Unit!.Value]; // a site being built always names its unit (SiteWork)- var progress = u.Type == VeteranType ? r.VeteranProgress!.Value : 1;+ var progress = Progress(r, u);if (w.TurnsLeft > progress) s.Sites[w.Site] = w.WithTurnsLeft(w.TurnsLeft - progress);else{diff --git a/sim/Statecraft.Sim/Training.cs b/sim/Statecraft.Sim/Training.csindex 0b639bb73..7d3986d28 100644--- a/sim/Statecraft.Sim/Training.cs+++ b/sim/Statecraft.Sim/Training.cs@@ -29,6 +29,25 @@ namespace Statecraft.Simc.Cities.First(k => k.Id == city).Facilities.Contains(facility)|| c.Sites.Any(x => x.City == city && x.Kinds.Contains(facility) && s.Sites.TryGetValue(x.Id, out var w) && w.BuiltOn != null);+ /// <summary>R-TRAIN-001: the city's civilians without work, the most a Train order there accepts.</summary>+ public static int Idle(City city) => city.Civilians - city.Employed;++ /// <summary>The groups the Train orders in <paramref name="pending"/> (this turn's queue) take from+ /// <paramref name="city"/>, every track together.</summary>+ public static int Ordered(string city, IEnumerable<Command> pending) => pending.OfType<Train>().Where(t => t.City == city).Sum(t => t.Count);++ /// <summary>R-TRAIN-001 with R-CITY-001: the groups still free to train in <paramref name="city"/> once the orders in+ /// <paramref name="pending"/> (this turn's queue) have run: <see cref="Idle"/>, less every track's Train order there,+ /// and less a pending AssignWorkers' rise in jobs. A count up to it keeps every one of those orders accepted, whatever+ /// order they run in. A pending CancelTraining is not counted, since it may run after the Train.</summary>+ public static int Available(GameState s, string city, IEnumerable<Command> pending)+ {+ var x = s.Cities[city];+ var list = pending as IReadOnlyCollection<Command> ?? pending.ToList();+ var employed = Math.Max(x.Employed, list.OfType<AssignWorkers>().Where(w => w.City == city).Select(w => w.Count).DefaultIfEmpty(0).Max());+ return Math.Max(0, x.Civilians - employed - Ordered(city, list));+ }+/// <summary>R-TRAIN-001: <paramref name="count"/> of the city's civilians without work start training as/// <paramref name="track"/>, a unit type with a facility. The Treasury pays count * training_cost now and borrows what it/// lacks. The trainees leave the civilians at once, and the cohort takes the next id. Refused, state untouched, when the@@ -42,7 +61,7 @@ namespace Statecraft.Simif (count < 1) return "Train at least one group";var name = PlayerText.Settlement(c, city);if (!HasFacility(c, s, city, type.Facility)) return $"{name} has no {Place(type.Facility)}";- var idle = x.Civilians - x.Employed;+ var idle = Idle(x);if (count > idle) return FormattableString.Invariant($"{name} has {idle} civilians without work");var cost = count * type.TrainingCost;// Owner decision "Allow borrowing" (2026-10-15, #468 question 1): a short Treasury borrows, as map actions do.diff --git a/unity/Assets/Scripts/Map/SettlementPlacer.cs b/unity/Assets/Scripts/Map/SettlementPlacer.csindex 0bac3d658..904df548f 100644--- a/unity/Assets/Scripts/Map/SettlementPlacer.cs+++ b/unity/Assets/Scripts/Map/SettlementPlacer.cs@@ -43,6 +43,8 @@ namespace Statecraft.Game.Map/// <summary>The marker box's edge (m) for a settlement type; the UI's label sits on its top.</summary>public static float MarkerHeightM(string type) => Marker[type].h;+ /// <summary>The marker box's colour for a settlement type (SiteLayer draws a built site's box with the kibbutz's).</summary>+ public static Color MarkerColour(string type) => Marker[type].c;static readonly int BaseColor = Shader.PropertyToID("_BaseColor");diff --git a/unity/Assets/Scripts/Map/SiteLayer.cs b/unity/Assets/Scripts/Map/SiteLayer.csnew file mode 100644index 000000000..1de1feb64--- /dev/null+++ b/unity/Assets/Scripts/Map/SiteLayer.cs@@ -0,0 +1,143 @@+#nullable enable+using System.Collections.Generic;+using System.Linq;+using Statecraft.Game.Map.Kits;+using Statecraft.Sim;+using UnityEngine;+using UnityEngine.Rendering;++namespace Statecraft.Game.Map+{+ /// <summary>GDD Phase 1 PR 8 (#381): the designated sites the player builds on (sites.yaml, State.Sites).+ /// <list type="bullet">+ /// <item>A built site is drawn as a rural kit on its hex (SettlementKits, as a kibbutz: the one archetype a new yishuv has+ /// in Phase 1), named <see cref="Prefix"/> + its id. With the map's "kits" toggle off, it is the kibbutz marker box, as the+ /// settlements are (KitLayer).</item>+ /// <item>A site being built is a scaffold marker: an open frame of raw timber on its hex, named Prefix + id ++ /// <see cref="ScaffoldSuffix"/>.</item>+ /// <item>An available site, with no record, draws nothing.</item>+ /// </list>+ /// Render replaces what it drew before, as PlacementLayer does, and keeps each kit's columns (<see cref="Columns"/>) for+ /// the map's name pills. Presentation only: what is built, and when, is the sim's (R-SITE-001 to R-SITE-003).</summary>+ public sealed class SiteLayer : MonoBehaviour+ {+ public const string Prefix = "site_", ScaffoldSuffix = "_scaffold";+ static readonly int BaseColor = Shader.PropertyToID("_BaseColor");+ /// <summary>The scaffold's light raw timber, and its size (a post's height, the frame's side and a post's thickness, m):+ /// an open frame as wide as a small kibbutz kit and thick enough to read at the play distance (the first captures+ /// showed 70 m posts as a speck), but open, so a site under way never reads as a founded place.</summary>+ static readonly Color Timber = new Color(0.86f, 0.72f, 0.48f);+ const float PostM = 450f, SideM = 1100f, PostThickM = 140f;++ readonly Dictionary<string, Bounds[]> columns = new Dictionary<string, Bounds[]>();+ /// <summary>Each built site's kit columns (KitMesh.Columns), by site id, as MapScene.TryKitColumns gives a town's.</summary>+ public IReadOnlyDictionary<string, Bounds[]> Columns => columns;+ readonly List<Settlement> places = new List<Settlement>();+ /// <summary>The built sites as places (Prefix + id, the site's name, a kibbutz on its hex), for their name pills+ /// (MapLabelsPresenter.SetSites).</summary>+ public IReadOnlyList<Settlement> Places => places;++ List<SiteWork>? lastSites; Content? lastContent; MapScene? lastMap; bool kitsShown;++ void LateUpdate()+ {+ // A flip of the "kits" toggle redraws (as PlacementLayer does), so a built site is its kit or its box, never both.+ if (lastSites != null && lastContent != null && lastMap != null && lastMap.KitsShown != kitsShown)+ Render(lastSites, lastContent, lastMap);+ }++ public void Render(IEnumerable<SiteWork> sites, Content content, MapScene map)+ {+ var cube = Resources.GetBuiltinResource<Mesh>("Cube.fbx");+ for (int i = transform.childCount - 1; i >= 0; i--)+ {+ var old = transform.GetChild(i).gameObject;+ var filter = old.GetComponent<MeshFilter>();+ var own = filter != null && filter.sharedMesh != cube ? filter.sharedMesh : null; // a kit's mesh is its own+ if (Application.isPlaying) { old.transform.SetParent(null); Destroy(old); if (own != null) Destroy(own); }+ else { DestroyImmediate(old); if (own != null) DestroyImmediate(own); }+ }+ columns.Clear(); places.Clear();+ var list = sites.ToList();+ lastSites = list; lastContent = content; lastMap = map; kitsShown = map.KitsShown;+ var block = new MaterialPropertyBlock();+ var built = new List<Settlement>();+ foreach (var w in list)+ {+ var site = content.Sites.FirstOrDefault(x => x.Id == w.Site);+ var hex = site == null ? null : content.HexAt(site.Q, site.R);+ if (site == null || hex == null) continue;+ var at = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);+ at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;+ if (w.BuiltOn == null) { Scaffold(Prefix + w.Site + ScaffoldSuffix, at, cube, map, block); continue; }+ built.Add(new Settlement { Id = Prefix + w.Site, Name = site.Name, NameHe = site.NameHe, Type = "kibbutz", Lon = hex.Lon, Lat = hex.Lat });+ }+ places.AddRange(built);+ var drawn = kitsShown && built.Count > 0 ? Kits(built, map) : new HashSet<string>();+ foreach (var s in built.Where(s => !drawn.Contains(s.Id)))+ {+ // No kit (toggle off, or no free ground): the kibbutz marker box, as SettlementPlacer draws the settlements.+ var at = map.Frame.ToWorld(s.Lon, s.Lat, 0);+ at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;+ var h = SettlementPlacer.MarkerHeightM(s.Type);+ var box = Part(s.Id, cube, map, block, SettlementPlacer.MarkerColour(s.Type));+ box.transform.position = at + Vector3.up * h / 2;+ box.transform.localScale = new Vector3(h, h, h);+ }+ }++ /// <summary>Draws the built sites as kits (one object each, Kit.mat), keeps their columns, and returns the ids drawn.</summary>+ HashSet<string> Kits(List<Settlement> built, MapScene map)+ {+ var kits = SettlementKits.Build(built, PlacementLayer.CampGround(map), out _, columns);+ var drawn = new HashSet<string>();+ foreach (var (s, mesh, _) in kits)+ {+ if (mesh == null) continue;+ var go = new GameObject(s.Id);+ go.transform.SetParent(transform, false);+ go.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); // the kit's vertices are in world space+ go.AddComponent<MeshFilter>().sharedMesh = mesh;+ var r = go.AddComponent<MeshRenderer>();+ r.sharedMaterial = map.KitMaterial;+ r.shadowCastingMode = ShadowCastingMode.On;+ drawn.Add(s.Id);+ }+ return drawn;+ }++ /// <summary>The scaffold: four timber posts at the corners of a square, under one parent named <paramref name="name"/>.</summary>+ void Scaffold(string name, Vector3 at, Mesh cube, MapScene map, MaterialPropertyBlock block)+ {+ var frame = new GameObject(name);+ frame.transform.SetParent(transform, false);+ frame.transform.position = at;+ foreach (var (dx, dz) in new[] { (-1, -1), (-1, 1), (1, -1), (1, 1) })+ {+ var post = Part(name + "_post", cube, map, block, Timber);+ post.transform.SetParent(frame.transform, false);+ post.transform.localPosition = new Vector3(dx * SideM / 2, PostM / 2, dz * SideM / 2);+ post.transform.localScale = new Vector3(PostThickM, PostM, PostThickM);+ }+ // a beam along each top edge, so it reads as a frame from any side+ foreach (var (x, z, alongX) in new[] { (0f, -SideM / 2, true), (0f, SideM / 2, true), (-SideM / 2, 0f, false), (SideM / 2, 0f, false) })+ {+ var beam = Part(name + "_beam", cube, map, block, Timber);+ beam.transform.SetParent(frame.transform, false);+ beam.transform.localPosition = new Vector3(x, PostM, z);+ beam.transform.localScale = alongX ? new Vector3(SideM + PostThickM, PostThickM, PostThickM) : new Vector3(PostThickM, PostThickM, SideM + PostThickM);+ }+ }++ GameObject Part(string name, Mesh cube, MapScene map, MaterialPropertyBlock block, Color colour)+ {+ var go = new GameObject(name);+ go.transform.SetParent(transform, false);+ go.AddComponent<MeshFilter>().sharedMesh = cube;+ var r = go.AddComponent<MeshRenderer>();+ r.sharedMaterial = map.MarkerMaterial;+ block.SetColor(BaseColor, colour); r.SetPropertyBlock(block);+ return go;+ }+ }+}diff --git a/unity/Assets/Scripts/Map/SiteLayer.cs.meta b/unity/Assets/Scripts/Map/SiteLayer.cs.metanew file mode 100644index 000000000..c8c282ec4--- /dev/null+++ b/unity/Assets/Scripts/Map/SiteLayer.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: c048539b3dcf5466982369cfbcfb1abb\ No newline at end of filediff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex a9907b806..453b7fb1e 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -59,6 +59,8 @@ namespace Statecraft.Game.UIOutcomePresenter? outcomes;CameraRig? rig;List<(string, int, int, DateTime)>? drawn;+ /// <summary>The designated sites on the map (#381), made on first use beside the placements; and their states as drawn.</summary>+ SiteLayer? siteLayer; List<string>? drawnSites;public SimBridge? Bridge { get; private set; }/// <summary>Where the autosave lives; null (the default) = SaveStore.ForPlatform(). Tests set a temporary folder.</summary>@@ -349,7 +351,7 @@ namespace Statecraft.Game.UIcameraController.Bounds = oldBounds;cameraController.Ground = oldGround; cameraController.GroundTop = oldTop;}));- drawn = null;+ drawn = null; drawnSites = null;RenderPlacementsIfChanged();SyncMinimap();// The start screen goes up in the same frame the loading state ends, so the HUD never flashes before it. While it@@ -429,7 +431,7 @@ namespace Statecraft.Game.UIif (card != null) { owned.Remove(card); card.Dispose(); }for (int i = owned.Count - 1; i >= 0; i--) owned[i].Dispose();owned.Clear();- minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; rig = null; drawn = null; units = null; Regions = null; logCamera = false;+ minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; rig = null; drawn = null; drawnSites = null; units = null; Regions = null; logCamera = false;// A ?profile run cut short (a stopped coroutine never reaches its restore line) must not leave the terrain at the// profile's pixel error (Task 24 review M1). Nothing else changes it, so restoring is always right.if (map != null && map.Terrain != null) map.Terrain.heightmapPixelError = MapBuilder.TerrainPixelError;@@ -443,12 +445,31 @@ namespace Statecraft.Game.UIStatecraft.Game.Map.Routes.RouteLayer.ShowAt(map, Bridge.State.Date); // dated routes (the Burma Road from June 1948)// MATKOT's whole-town models as overview landmarks, streamed after the first frame (#663); the ma'abara from its date.Statecraft.Game.Map.Collection.TownLandmarks.ShowAt(map, Bridge.State.Date, Bridge.State.Placements, Bridge.Content);+ RenderSitesIfChanged();var now = Bridge.State.Placements.Select(p => (p.Action, p.Q, p.R, p.Date)).ToList();if (drawn != null && drawn.SequenceEqual(now)) return;drawn = now;placements.Render(Bridge.State.Placements, Bridge.Content, map);}+ /// <summary>Draws the designated sites (#381) only when a site's state differs from what was drawn: being built, or+ /// built on its date.</summary>+ void RenderSitesIfChanged()+ {+ if (Bridge == null) return;+ var now = Bridge.State.Sites.Values.Select(w => w.Site + ":" + (w.BuiltOn?.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) ?? "building")).ToList();+ if (drawnSites != null && drawnSites.SequenceEqual(now)) return;+ drawnSites = now;+ if (siteLayer == null)+ {+ siteLayer = new GameObject("Sites").AddComponent<SiteLayer>();+ siteLayer.transform.SetParent(placements.transform.parent, false);+ }+ siteLayer.Render(Bridge.State.Sites.Values, Bridge.Content, map);+ // A built site's name is a map pill like a town's (#381), against its kit's columns.+ labels?.SetSites(siteLayer.Places.Select(p => (p, siteLayer.Columns.TryGetValue(p.Id, out var c) ? c : (Bounds[]?)null)).ToList());+ }+void SyncMinimap(){if (minimap == null || rig == null) return;diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csnew file mode 100644index 000000000..e8209c1f4--- /dev/null+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -0,0 +1,170 @@+#nullable enable+using System;+using System.Linq;+using Statecraft.Sim;+using UnityEngine.UIElements;++namespace Statecraft.Game.UI+{+ /// <summary>GDD Phase 1 PR 8 (#381): the info panel's part for the GDD loop (Content.IsGdd), built into the+ /// <see cref="HostName"/> element on every render.+ /// <para>On a city hex (State.Cities), its counts (housing, jobs, refugees waiting, recruits) and training cohorts with+ /// their turns left, the Assign stepper (R-CITY-001), Train for each facility the city has (R-TRAIN-001, R-CAMP-001) and Cancel+ /// (R-TRAIN-002). On a yishuv site's hex (sites.yaml, Projects.IsYishuvSite), 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>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";+ const string LineClass = "info-gdd-line", RowClass = "info-gdd-row";++ 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)+ {+ host.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 site = c.Sites.FirstOrDefault(x => x.Q == q && x.R == r && Projects.IsYishuvSite(x));+ if (site != null)+ {+ title = text["ui.lang"] == UiLanguage.Hebrew && !string.IsNullOrWhiteSpace(site.NameHe) ? site.NameHe : site.Name;+ Site(host, bridge, text, site);+ }+ }+ host.style.display = host.childCount > 0 ? DisplayStyle.Flex : DisplayStyle.None;+ return title;+ }++ static void City(VisualElement host, SimBridge bridge, UiText text, string id)+ {+ var c = bridge.Content; var s = bridge.State; var city = s.Cities[id];+ // R-HOUSE-003: the housed are the civilians, the recruits and the groups in training (Cities.Housed), against the+ // capacity; R-HOUSE-001: the city's housing condition, 0 to 1, through the one percent formatter, on the same line+ // so the panel is no taller (the GDD loop always has a condition; the plain form is for a city without one).+ var housed = Cities.Housed(s, city); var capacity = Groups(text, city.HousingCapacity);+ Line(host, "city-housing", city.Condition is double condition+ ? text.Format("city.housing_condition", housed, capacity, PlayerText.Percent(condition))+ : text.Format("city.housing", housed, capacity));+ Line(host, "city-jobs", text.Format("city.jobs", city.Employed, city.JobSlots));+ Line(host, "city-refugees", text.Format("city.refugees", Groups(text, city.Refugees)));+ Line(host, "city-recruits", text.Format("city.recruits", Groups(text, city.Recruits)));++ // The Assign stepper: the ordered count (or the current one), one group a press, within R-CITY-001's limits as+ // the sim gives them with this turn's Train orders; stepping back to the current count withdraws the order.+ var queued = bridge.QueuedLike(new AssignWorkers(id, "job", 0)) as AssignWorkers;+ var target = queued?.Count ?? city.Employed;+ var max = Cities.MaxWorkers(s, id, bridge.Queued);+ var workers = Row(host, "city-workers-row");+ Button(workers, "city-workers-less", "−", () => Workers(bridge, id, city.Employed, target - 1)).SetEnabled(target > 0);+ Line(workers, "city-workers", text.Format("city.workers", Groups(text, target)));+ Button(workers, "city-workers-more", "+", () => Workers(bridge, id, city.Employed, target + 1)).SetEnabled(target < max);++ // 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; R-TRAIN-001 takes only civilians without work, and the sim counts every track's+ // order and the Assign order in the queue against them.+ var free = Training.Available(s, id, bridge.Queued);+ foreach (var type in c.UnitTypes.Where(t => t.Facility != "" && Training.HasFacility(c, s, id, t.Facility)))+ {+ var ordered = (bridge.QueuedLike(new Train(id, type.Id, 1)) as Train)?.Count ?? 0;+ var row = Row(host, $"city-train-{type.Id}-row");+ Button(row, "city-train-" + type.Id, text.Format("city.train_" + type.Id, PlayerText.Money(c, "treasury", type.TrainingCost), Turns(text, type.TrainingTurns)),+ () => bridge.Queue(new Train(id, type.Id, ordered + 1))).SetEnabled(free >= 1);+ if (ordered > 0) Line(row, $"city-train-{type.Id}-ordered", text.Format("city.train_ordered", ordered));+ }++ foreach (var k in s.Cohorts.Values.Where(x => x.City == id))+ {+ var row = Row(host, $"city-cohort-{k.Id}-row");+ Line(row, $"city-cohort-{k.Id}", text.Format("city.cohort", text["city.track_" + k.Type], Groups(text, k.Count), Turns(text, k.TurnsLeft)));+ var cancelled = bridge.QueuedLike(new CancelTraining(k.Id)) != null;+ Button(row, $"city-cohort-{k.Id}-cancel", text[cancelled ? "city.cancel_ordered" : "city.cancel"],+ () => bridge.Queue(new CancelTraining(k.Id))).SetEnabled(!cancelled);+ }+ }++ static void Workers(SimBridge bridge, string city, int current, int count)+ {+ if (count != current) { bridge.Queue(new AssignWorkers(city, "job", count)); return; }+ if (bridge.QueuedLike(new AssignWorkers(city, "job", 0)) is Command order) bridge.Withdraw(order);+ }++ static void Site(VisualElement host, SimBridge bridge, UiText text, Statecraft.Sim.Site site)+ {+ var c = bridge.Content; var s = bridge.State;+ s.Sites.TryGetValue(site.Id, out var work);+ if (work == null)+ {+ Line(host, "site-state", text["site.available"]);+ var rules = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop+ var idle = s.Units.Values.Where(u => Projects.IsPioneer(u.Type) && !Projects.IsBusy(s, u.Id)).ToList();+ if (idle.Count == 0) Line(host, "site-no-halutz", text["site.no_halutz"]);+ // One unit builds a site (question 15): once a group is ordered here, the others' Build is off, as the sim+ // would refuse the second order ("already being built").+ var taken = bridge.Queued.OfType<PioneerWork>().Any(w => w.Site == site.Id);+ foreach (var u in idle)+ {+ // PioneerWork and StopWork share the unit's key: an order for this unit at this site is this button's.+ var ordered = bridge.QueuedLike(new PioneerWork(u.Id, Projects.BuildYishuv, site.Id)) is PioneerWork p && p.Site == site.Id;+ Button(host, $"site-build-{u.Id}", ordered ? text["site.ordered"]+ : text.Format("site.build", Group(text, s, u.Id), PlayerText.Money(c, "treasury", rules.BuildYishuvCost),+ Turns(text, Projects.TurnsToBuild(c, s, u.Id, rules.BuildYishuvTurns))),+ () => bridge.Queue(new PioneerWork(u.Id, Projects.BuildYishuv, site.Id))).SetEnabled(!ordered && !taken);+ }+ }+ else if (work.BuiltOn == null)+ {+ var unit = work.Unit!.Value; // a site being built names its unit (SiteWork)+ Line(host, "site-state", text.Format("site.building", Group(text, s, unit), Turns(text, Projects.TurnsToBuild(c, s, unit, work.TurnsLeft))));+ var stopping = bridge.QueuedLike(new StopWork(unit)) is StopWork;+ Button(host, "site-stop", text[stopping ? "site.ordered" : "site.stop"], () => bridge.Queue(new StopWork(unit))).SetEnabled(!stopping);+ }+ else Line(host, "site-state", text.Format("site.built", Date(text, work.BuiltOn.Value)));+ }++ /// <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>+ public static string Turns(UiText t, int n) => n == 1 ? t["city.turns_one"] : t.Format("city.turns", n);+ /// <summary>A pioneer group's name for the player: "halutz group n", numbered from 1 among the pioneer units (halutz and+ /// veteran, Projects.IsPioneer) in id order, so a group keeps its number when it becomes a veteran (unit ids are shared+ /// with cohorts and start at 0, so they are no names).</summary>+ public static string Group(UiText t, GameState s, int unit) =>+ t.Format("site.group", 1 + s.Units.Values.Where(u => Projects.IsPioneer(u.Type)).Select(u => u.Id).TakeWhile(id => id != unit).Count());++ /// <summary>A date in the UI's language, as the event card writes it (EventCardPresenter.ObjectiveLine).</summary>+ static string Date(UiText t, DateTime d) => t.Format("date.day_month_year", d.Day, t["date.month_" + d.Month], d.Year);++ static Label Line(VisualElement parent, string name, string value)+ {+ var l = new Label(value) { name = name };+ l.AddToClassList("wrap"); l.AddToClassList(LineClass);+ parent.Add(l);+ return l;+ }++ static VisualElement Row(VisualElement parent, string name)+ {+ var row = new VisualElement { name = name };+ row.AddToClassList("row"); row.AddToClassList(RowClass);+ parent.Add(row);+ return row;+ }++ static Button Button(VisualElement parent, string name, string label, Action onClick)+ {+ var b = new Button(onClick) { name = name, text = label };+ parent.Add(b);+ return b;+ }+ }+}diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs.meta b/unity/Assets/Scripts/UI/GddHexPanel.cs.metanew file mode 100644index 000000000..d3b0a9044--- /dev/null+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 2e6bb4c07b47843a7abb14dacca5365f\ No newline at end of filediff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex e29152d20..122fa4d10 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -20,6 +20,8 @@ namespace Statecraft.Game.UIpublic const string RowClass = "info-row";/// <summary>On the panel while it shows a unit's card: the rows keep their lines but drop the hex signs (Statecraft.uss).</summary>public const string UnitClass = "info-unit";+ /// <summary>On the panel while it shows the GDD loop's city or site part (#381): a second column (Statecraft.uss).</summary>+ public const string GddClass = "info-gdd-shown";readonly List<(VisualElement row, Label line)> rows = new List<(VisualElement, Label)>();readonly VisualElement panel; readonly SimBridge bridge; readonly UiText text;@@ -29,6 +31,8 @@ namespace Statecraft.Game.UIreadonly Label title, subtitle, region, settlements, localitiesLabel, placement, reason;readonly System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt;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;readonly IReadOnlyDictionary<string, string> settlementNames;readonly MapRegions? regions;readonly System.Func<string, (int q, int r)>? townHex;@@ -59,6 +63,7 @@ namespace Statecraft.Game.UIlocalitiesLabel = panel.Q<Label>("info-localities");placement = panel.Q<Label>("info-placement"); reason = panel.Q<Label>("info-reason");thumb = panel.Q<UiIcon>("info-thumb");+ gdd = panel.Q<VisualElement>(GddHexPanel.HostName);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);@@ -210,6 +215,7 @@ namespace Statecraft.Game.UIpublic void Render(){RenderLines();+ panel.EnableInClassList(GddClass, gdd.style.display.value == DisplayStyle.Flex);// A fact row shows only when its line has something to say (an empty row would leave a lone sign).foreach (var (row, line) in rows)row.style.display = string.IsNullOrEmpty(line.text) ? DisplayStyle.None : DisplayStyle.Flex;@@ -232,6 +238,7 @@ namespace Statecraft.Game.UIplacement.text = card.Footer; reason.text = card.Note;camp.style.display = DisplayStyle.None; housing.style.display = DisplayStyle.None;ShowThumb(null);+ GddHexPanel.Hide(gdd);return;}panel.EnableInClassList("info-empty", Selected == null);@@ -242,6 +249,7 @@ namespace Statecraft.Game.UIShowLocalities("");camp.style.display = DisplayStyle.None; housing.style.display = DisplayStyle.None;ShowThumb(null);+ GddHexPanel.Hide(gdd);return;}var (q, r) = Selected.Value;@@ -249,6 +257,9 @@ namespace Statecraft.Game.UIShowThumb(hex?.Biome);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);+ 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// hex, each with its agreement (true lines drawn to the nearest hex edge: the owner's ruling).diff --git a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs b/unity/Assets/Scripts/UI/MapLabelsPresenter.csindex 4effa7495..894fb4720 100644--- a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs+++ b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs@@ -280,6 +280,35 @@ namespace Statecraft.Game.UIpublic static Bounds[] KitBounds(MapScene map, Settlement s, Vector3 markerTop) =>map.TryKitColumns(s.Id, out var columns) ? columns : MarkerBox(s, markerTop);+ readonly List<Item> siteItems = new List<Item>();++ /// <summary>GDD Phase 1 PR 8 (#381): the built sites' pills (SiteLayer.Places), replacing the last ones given. Each is+ /// placed like a kibbutz's: after the game settlements and before the 1948 localities, against its kit's columns+ /// (SiteLayer.Columns) or, with none, its marker box, under the same declutter and clearance rules as every pill.</summary>+ public void SetSites(IReadOnlyList<(Settlement place, Bounds[]? columns)> sites)+ {+ foreach (var it in siteItems) { it.Slot.RemoveFromHierarchy(); items.Remove(it); settlementOrder.Remove(it); }+ siteItems.Clear();+ var at = items.FindIndex(x => x.IsLocality); // the sites go before the localities+ if (at < 0) at = items.Count;+ foreach (var (s, columns) in sites)+ {+ var slot = new VisualElement { name = "slot-" + s.Id, pickingMode = PickingMode.Ignore };+ slot.AddToClassList(SlotClass);+ var label = new Label(s.Name) { name = "label-" + s.Id, pickingMode = PickingMode.Ignore };+ label.AddToClassList(LabelClass); label.AddToClassList("map-label-" + s.Type); label.AddToClassList(Centre);+ slot.Add(label);+ container.Insert(System.Math.Max(0, container.IndexOf(Tooltip)), slot); // under the tooltip, as the others+ var top = MarkerTop(map, s);+ var it = new Item { Settlement = s, MarkerTop = top, Kit = columns ?? MarkerBox(s, top), Marker = MarkerBox(s, top), Slot = slot, Label = label, First = Spot.AboveCentre };+ items.Insert(at++, it); settlementOrder.Add(it); siteItems.Add(it);+ }+ geometryDirty = true;+ }++ /// <summary>The built sites' pills (SetSites), in the order given.</summary>+ public IReadOnlyList<Label> SiteLabels { get { var l = new List<Label>(); foreach (var x in siteItems) l.Add(x.Label); return l; } }+/// <summary>A settlement's marker box (what is drawn while the "kits" toggle is off).</summary>public static Bounds[] MarkerBox(Settlement s, Vector3 markerTop){@@ -607,6 +636,8 @@ namespace Statecraft.Game.UIoccluders.Clear();foreach (var slot in Slots) slot.RemoveFromHierarchy();foreach (var slot in LocalitySlots) slot.RemoveFromHierarchy();+ foreach (var it in siteItems) it.Slot.RemoveFromHierarchy();+ siteItems.Clear();Tooltip.RemoveFromHierarchy();items.Clear(); settlementOrder.Clear();}diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.csnew file mode 100644index 000000000..480a53a54--- /dev/null+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs@@ -0,0 +1,515 @@+#nullable enable+using System;+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>GDD Phase 1 PR 8 (#381): the info panel on a city hex (housing, jobs, refugees, recruits, training cohorts; the+/// Assign stepper, Train recruit, Train halutz and Cancel) and on the designated site's hex (its state; Build with each idle+/// halutz group, with the cost and turns from the rules; Stop while it is built). Every number is the sim's; every order goes+/// through the bridge's queue, which the sim then rules on. The legacy loop shows none of it.</summary>+public class CityPanelTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ static readonly System.Collections.Generic.List<Settlement> Towns =+ SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", SettlementPlacer.DefaultFileName)));+ 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");+ const string City = "tel_aviv", Site = "mefalsim";++ static (int q, int r) CityHex => C.SettlementHexes.Where(x => x.Id == City).Select(x => (x.Q, x.R)).Single();+ static Statecraft.Sim.Site SiteDef => C.Sites.Single(x => x.Id == Site);++ /// <summary>A GDD game at the start, changed by <paramref name="edit"/> before the bridge sees it.</summary>+ 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.ToDictionary(t => t.Id, t => t.Name));++ static int AddHalutz(GameState s, string type = "halutz")+ {+ var id = s.NextId++;+ s.Units.Add(id, new Unit(id, type, CityHex.q, CityHex.r));+ return id;+ }++ /// <summary>Tel Aviv with <paramref name="civilians"/> civilians, <paramref name="employed"/> of them in jobs.</summary>+ static Action<GameState> Counts(int civilians, int employed) =>+ s => s.Cities[City] = s.Cities[City].WithCounts(civilians, employed, s.Cities[City].Refugees);++ static VisualElement Host(UiTestKit ui) => ui.Q<VisualElement>(GddHexPanel.HostName);++ [Test]+ public void TheCityHexShowsItsCountsFromTheSim()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var city = bridge.State.Cities[City];+ Assert.AreEqual((0, 0), (city.Refugees, city.Recruits), "precondition: no refugees or recruits at the start (the plural forms below)");+ Assert.AreEqual(DisplayStyle.Flex, Host(ui).style.display.value, "the GDD part of the panel shows");+ Assert.AreEqual(En.Format("city.housing_condition", Cities.Housed(bridge.State, city), En.Format("city.groups", city.HousingCapacity), PlayerText.Percent(city.Condition!.Value)), ui.Q<Label>("city-housing").text);+ Assert.AreEqual(En.Format("city.jobs", city.Employed, city.JobSlots), ui.Q<Label>("city-jobs").text);+ Assert.AreEqual(En.Format("city.refugees", En.Format("city.groups", city.Refugees)), ui.Q<Label>("city-refugees").text);+ Assert.AreEqual(En.Format("city.recruits", En.Format("city.groups", city.Recruits)), ui.Q<Label>("city-recruits").text);+ Assert.AreEqual(En.Format("city.workers", En.Format("city.groups", city.Employed)), ui.Q<Label>("city-workers").text);+ }++ [Test]+ public void TheHousingLineCountsRecruitsAndGroupsInTraining()+ {+ // R-HOUSE-003: the people who take a city's housing are its civilians, its recruits and its groups in training+ // (Cities.Housed), not its civilians alone. 10 civilians, 3 recruits and a cohort of 2 are 15 housed.+ using var ui = new UiTestKit();+ var bridge = Bridge(En, s =>+ {+ s.Cities[City] = s.Cities[City].WithCounts(10, 0, 0).WithRecruits(3);+ var id = s.NextId++;+ s.Cohorts.Add(id, new Cohort(id, "halutz", City, 2, 3));+ });+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var city = bridge.State.Cities[City];+ Assert.AreEqual(15, Cities.Housed(bridge.State, city), "precondition: the sim houses the recruits and the trainees too");+ Assert.AreEqual(En.Format("city.housing_condition", 15, En.Format("city.groups", city.HousingCapacity), PlayerText.Percent(city.Condition!.Value)), ui.Q<Label>("city-housing").text);+ }++ [Test]+ public void TheCityHexShowsItsHousingConditionFromTheSim()+ {+ // R-HOUSE-001: each city's housing condition, 0 to 1, on the Housing line (so the panel is no taller), shown with the+ // one percent formatter.+ using var ui = new UiTestKit();+ var bridge = Bridge(En, s => s.Cities[City] = s.Cities[City].WithCondition(0.42));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var city = bridge.State.Cities[City];+ Assert.AreEqual(En.Format("city.housing_condition", Cities.Housed(bridge.State, city), En.Format("city.groups", city.HousingCapacity), "42%"), ui.Q<Label>("city-housing").text);+ Assert.AreEqual("42%", PlayerText.Percent(0.42), "precondition: the formatter's reading");+ }++ [Test]+ public void ACityWithoutAConditionShowsThePlainHousingLine()+ {+ // City.Condition is null only on a hand-built record; the line then shows the count without a made-up condition.+ using var ui = new UiTestKit();+ var bridge = Bridge(En, s => { var x = s.Cities[City]; s.Cities[City] = new Statecraft.Sim.City(x.Id, x.HousingCapacity, x.JobSlots, 10, 0, 0, 3); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var city = bridge.State.Cities[City];+ Assert.IsNull(city.Condition, "precondition: no condition");+ Assert.AreEqual(En.Format("city.housing", 13, En.Format("city.groups", city.HousingCapacity)), ui.Q<Label>("city-housing").text);+ }++ [Test]+ public void TheWorkersStepperQueuesAssignWorkersAndStepsBackToNoOrder()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var employed = bridge.State.Cities[City].Employed;+ UiTestKit.Press(ui.Q<Button>("city-workers-less"));+ var order = bridge.QueuedLike(new AssignWorkers(City, "job", 0)) as AssignWorkers;+ Assert.IsNotNull(order, "the stepper queues an AssignWorkers order");+ Assert.AreEqual(employed - 1, order!.Count);+ Assert.AreEqual(En.Format("city.workers", En.Format("city.groups", employed - 1)), ui.Q<Label>("city-workers").text, "the stepper shows the ordered count");+ UiTestKit.Press(ui.Q<Button>("city-workers-more"));+ Assert.IsNull(bridge.QueuedLike(new AssignWorkers(City, "job", 0)), "back at the current count: no order is left queued");+ }++ [Test]+ public void TheStepperStopsAtTheSimsLimits()+ {+ using var ui = new UiTestKit();+ // R-CITY-001: at most the job slots and the civilians; never below 0.+ var bridge = Bridge(En, s => s.Cities[City] = s.Cities[City].WithCounts(s.Cities[City].Civilians, 0, s.Cities[City].Refugees));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsFalse(ui.Q<Button>("city-workers-less").enabledSelf, "no fewer than 0 workers");+ var full = Math.Min(bridge.State.Cities[City].JobSlots, bridge.State.Cities[City].Civilians);+ var bridge2 = Bridge(En, s => s.Cities[City] = s.Cities[City].WithCounts(s.Cities[City].Civilians, full, s.Cities[City].Refugees));+ using var ui2 = new UiTestKit();+ using var panel2 = Panel(ui2, bridge2, En);+ panel2.Show(CityHex.q, CityHex.r);+ Assert.IsFalse(ui2.Q<Button>("city-workers-more").enabledSelf, "no more than the job slots and the civilians");+ }++ [Test]+ public void TheStepperStopsAtTheCiviliansWhenThereAreMoreJobs()+ {+ // R-CITY-001's other limit: Tel Aviv's 248 civilians are above its 106 jobs at the start, so give it fewer.+ using var ui = new UiTestKit();+ var bridge = Bridge(En, Counts(50, 50));+ Assert.Greater(bridge.State.Cities[City].JobSlots, 50, "precondition: jobs are not the limit");+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsFalse(ui.Q<Button>("city-workers-more").enabledSelf, "no more workers than civilians");+ }++ [Test]+ public void AQueuedTrainOrderTakesItsCiviliansFromTheStepper()+ {+ // 50 civilians, 49 in jobs: one more worker, or one trainee, but not both (Cities.MaxWorkers with the queue).+ using var ui = new UiTestKit();+ var bridge = Bridge(En, Counts(50, 49));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsTrue(ui.Q<Button>("city-workers-more").enabledSelf, "precondition: one more worker fits");+ UiTestKit.Press(ui.Q<Button>("city-train-recruit"));+ Assert.IsNotNull(bridge.QueuedLike(new Train(City, "recruit", 1)));+ Assert.IsFalse(ui.Q<Button>("city-workers-more").enabledSelf, "the trainee takes the last civilian without work");+ }++ [Test]+ public void EachTrainPressQueuesOneMoreGroupAtTheRulesCost()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ foreach (var track in new[] { "recruit", "halutz" })+ {+ var type = C.UnitTypes.Single(t => t.Id == track);+ var button = ui.Q<Button>("city-train-" + track);+ Assert.AreEqual(En.Format("city.train_" + track, PlayerText.Money(C, "treasury", type.TrainingCost), En.Format("city.turns", type.TrainingTurns)), button.text);+ UiTestKit.Press(button); UiTestKit.Press(ui.Q<Button>("city-train-" + track));+ var order = bridge.QueuedLike(new Train(City, track, 1)) as Train;+ Assert.IsNotNull(order, track);+ Assert.AreEqual(2, order!.Count, $"{track}: two presses, two groups");+ Assert.AreEqual(En.Format("city.train_ordered", 2), ui.Q<Label>("city-train-" + track + "-ordered").text, track);+ }+ }++ [Test]+ public void TrainIsDisabledWithNoCivilianWithoutWork()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En, Counts(50, 50));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsFalse(ui.Q<Button>("city-train-recruit").enabledSelf, "R-TRAIN-001: every civilian is in work");+ Assert.IsFalse(ui.Q<Button>("city-train-halutz").enabledSelf);+ }++ [Test]+ public void TrainingAcrossBothTracksStopsAtTheIdleCivilianLimit()+ {+ // One civilian without work: once recruits take it, halutzim cannot (Training.Available counts every track).+ using var ui = new UiTestKit();+ var bridge = Bridge(En, Counts(50, 49));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsTrue(ui.Q<Button>("city-train-halutz").enabledSelf, "precondition: one group can train");+ UiTestKit.Press(ui.Q<Button>("city-train-recruit"));+ Assert.IsFalse(ui.Q<Button>("city-train-recruit").enabledSelf, "the recruit order took the last civilian without work");+ Assert.IsFalse(ui.Q<Button>("city-train-halutz").enabledSelf, "the other track counts that recruit order too");+ }++ [Test]+ public void AQueuedAssignOrderTakesItsCiviliansFromTraining()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En, Counts(50, 49));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ UiTestKit.Press(ui.Q<Button>("city-workers-more"));+ Assert.AreEqual(50, (bridge.QueuedLike(new AssignWorkers(City, "job", 0)) as AssignWorkers)?.Count);+ Assert.IsFalse(ui.Q<Button>("city-train-recruit").enabledSelf, "the worker order took the last civilian without work");+ }++ [Test]+ public void ACityWithoutTheFacilityOffersNoSuchTraining()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ var haifa = C.SettlementHexes.Single(x => x.Id == "haifa");+ Assert.IsFalse(C.Cities.Single(x => x.Id == "haifa").Facilities.Any(), "precondition: Haifa has no training facility");+ panel.Show(haifa.Q, haifa.R);+ Assert.IsNull(ui.Root.Q<Button>("city-train-recruit"));+ Assert.IsNull(ui.Root.Q<Button>("city-train-halutz"));+ Assert.IsNotNull(ui.Root.Q<Label>("city-housing"), "the counts still show");+ }++ [Test]+ public void ABuiltCampGivesItsCityTheTrainButton()+ {+ // R-CAMP-001 (Training.HasFacility): a city gains a facility from a built camp site, not only from cities.yaml.+ var camp = C.Sites.First(x => Projects.IsCamp(x) && x.City != "" && x.Kinds.Contains("military_camp"));+ Assert.IsFalse(C.Cities.Single(x => x.Id == camp.City).Facilities.Contains("military_camp"), "precondition: the city starts without a camp");+ var hex = C.SettlementHexes.First(x => x.Id == camp.City);+ foreach (var built in new[] { false, true })+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En, s => s.Sites[camp.Id] = built ? SiteWork.Built(camp.Id, s.Date) : new SiteWork(camp.Id, AddHalutz(s), 2, null));+ using var panel = Panel(ui, bridge, En);+ panel.Show(hex.Q, hex.R);+ Assert.AreEqual(built, ui.Root.Q<Button>("city-train-recruit") != null, built ? "a built camp trains recruits" : "a camp being built does not count yet");+ }+ }++ [Test]+ public void ACohortShowsItsTurnsLeftAndCancelQueuesCancelTraining()+ {+ using var ui = new UiTestKit();+ int id = -1;+ var bridge = Bridge(En, s => { id = s.NextId++; s.Cohorts.Add(id, new Cohort(id, "halutz", City, 2, 3)); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ var row = ui.Q<Label>($"city-cohort-{id}");+ Assert.AreEqual(En.Format("city.cohort", En["city.track_halutz"], En.Format("city.groups", 2), En.Format("city.turns", 3)), row.text);+ UiTestKit.Press(ui.Q<Button>($"city-cohort-{id}-cancel"));+ Assert.IsNotNull(bridge.QueuedLike(new CancelTraining(id)), "Cancel queues CancelTraining");+ Assert.IsFalse(ui.Q<Button>($"city-cohort-{id}-cancel").enabledSelf, "Cancel is disabled once ordered");+ Assert.AreEqual(En["city.cancel_ordered"], ui.Q<Button>($"city-cohort-{id}-cancel").text);+ }++ [Test]+ public void OneGroupAndOneTurnAreSingular()+ {+ using var ui = new UiTestKit();+ int id = -1;+ var bridge = Bridge(En, s => { id = s.NextId++; s.Cohorts.Add(id, new Cohort(id, "halutz", City, 1, 1)); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.AreEqual("Halutzim: 1 group in training, 1 turn left", ui.Q<Label>($"city-cohort-{id}").text);+ }++ [Test]+ public void TheSiteHexOffersBuildToEachIdleHalutzGroup()+ {+ using var ui = new UiTestKit();+ int a = -1, b = -1;+ var bridge = Bridge(En, s => { a = AddHalutz(s); b = AddHalutz(s); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(SiteDef.Name, ui.Q<Label>("info-title").text, "the site's name is the title");+ Assert.AreEqual(En["site.available"], ui.Q<Label>("site-state").text);+ var r = C.RulesAt(bridge.State.Date).Mvp!;+ var first = ui.Q<Button>($"site-build-{a}");+ Assert.AreEqual(En.Format("site.build", En.Format("site.group", 1), PlayerText.Money(C, "treasury", r.BuildYishuvCost), En.Format("city.turns", r.BuildYishuvTurns)), first.text);+ StringAssert.Contains(En.Format("site.group", 2), ui.Q<Button>($"site-build-{b}").text, "every idle group has its button, numbered from 1");+ UiTestKit.Press(first);+ var order = bridge.QueuedLike(new PioneerWork(a, Projects.BuildYishuv, Site)) as PioneerWork;+ Assert.IsNotNull(order); Assert.AreEqual(Site, order!.Site);+ }++ [Test]+ public void EachBuildButtonOrdersItsOwnGroupAndOneGroupASite()+ {+ using var ui = new UiTestKit();+ int a = -1, b = -1;+ var bridge = Bridge(En, s => { a = AddHalutz(s); b = AddHalutz(s); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ UiTestKit.Press(ui.Q<Button>($"site-build-{b}"));+ var orders = bridge.Queued.OfType<PioneerWork>().ToList();+ Assert.AreEqual(1, orders.Count, "one order");+ Assert.AreEqual((b, Site), (orders[0].Unit, orders[0].Site), "the second group's button orders the second group");+ Assert.IsFalse(ui.Q<Button>($"site-build-{b}").enabledSelf, "Build is disabled once ordered");+ Assert.AreEqual(En["site.ordered"], ui.Q<Button>($"site-build-{b}").text);+ Assert.IsFalse(ui.Q<Button>($"site-build-{a}").enabledSelf, "one group builds a site: the sim would refuse a second order");+ }++ [Test]+ public void AGroupBuildingElsewhereIsNotOffered()+ {+ using var ui = new UiTestKit();+ int busy = -1, idle = -1;+ var other = C.Sites.First(x => Projects.IsYishuvSite(x) && x.Id != Site).Id;+ var bridge = Bridge(En, s => { busy = AddHalutz(s); idle = AddHalutz(s); s.Sites[other] = new SiteWork(other, busy, 3, null); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.IsNull(ui.Root.Q<Button>($"site-build-{busy}"), "a group with a project is not idle (D-D6)");+ Assert.IsNotNull(ui.Root.Q<Button>($"site-build-{idle}"));+ }++ [Test]+ public void AVeteranGroupIsOfferedBuildWithItsOwnTurns()+ {+ // R-VET-002: a veteran builds at veteran_progress a turn, so the label's turns are the sim's for that unit.+ using var ui = new UiTestKit();+ int vet = -1;+ var bridge = Bridge(En, s => vet = AddHalutz(s, Projects.VeteranType));+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ var r = C.RulesAt(bridge.State.Date).Mvp!;+ var turns = Projects.TurnsToBuild(C, bridge.State, vet, r.BuildYishuvTurns);+ Assert.Less(turns, r.BuildYishuvTurns, "precondition: a veteran builds faster in the real content");+ var button = ui.Q<Button>($"site-build-{vet}");+ Assert.IsNotNull(button, "a veteran group has a Build button");+ Assert.AreEqual(En.Format("site.build", En.Format("site.group", 1), PlayerText.Money(C, "treasury", r.BuildYishuvCost), En.Format("city.turns", turns)), button.text);+ UiTestKit.Press(button);+ Assert.IsNotNull(bridge.QueuedLike(new PioneerWork(vet, Projects.BuildYishuv, Site)));+ }++ [Test]+ public void AVeteransSiteShowsTheTurnsItReallyHasLeft()+ {+ using var ui = new UiTestKit();+ int vet = -1;+ var bridge = Bridge(En, s => { vet = AddHalutz(s, Projects.VeteranType); s.Sites[Site] = new SiteWork(Site, vet, 4, null); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ var turns = Projects.TurnsToBuild(C, bridge.State, vet, 4);+ Assert.AreEqual(2, turns, "precondition: 4 turns of progress at the real content's 2 a turn");+ Assert.AreEqual(En.Format("site.building", En.Format("site.group", 1), En.Format("city.turns", turns)), ui.Q<Label>("site-state").text);+ }++ [Test]+ public void TheYishuvSiteIsFoundByItsKindNotItsPlaceInTheFile()+ {+ // Since #866 a yishuv hex also holds a field site; list one first and the panel still shows the yishuv.+ var field = new Statecraft.Sim.Site { Id = "a_field_listed_first", Name = "A field", Q = SiteDef.Q, R = SiteDef.R, Kinds = new System.Collections.Generic.List<string> { "field" } };+ C.Sites.Insert(0, field);+ try+ {+ using var ui = new UiTestKit();+ int a = -1;+ var bridge = Bridge(En, s => a = AddHalutz(s));+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(SiteDef.Name, ui.Q<Label>("info-title").text);+ Assert.AreEqual(En["site.available"], ui.Q<Label>("site-state").text);+ UiTestKit.Press(ui.Q<Button>($"site-build-{a}"));+ Assert.AreEqual(Site, (bridge.QueuedLike(new PioneerWork(a, Projects.BuildYishuv, Site)) as PioneerWork)?.Site);+ }+ finally { C.Sites.Remove(field); }+ }++ [Test]+ public void AHexWithOnlyAFieldSiteOffersNoBuild()+ {+ var field = new Statecraft.Sim.Site { Id = "a_lone_field", Name = "A lone field", Q = CityHex.q, R = CityHex.r, Kinds = new System.Collections.Generic.List<string> { "field" } };+ C.Sites.Add(field);+ try+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En, s => AddHalutz(s));+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.IsNull(ui.Root.Q<Label>("site-state"), "Projects.Start refuses a yishuv on a field site");+ Assert.IsFalse(ui.Root.Query<Button>().ToList().Any(x => x.name.StartsWith("site-build-")));+ }+ finally { C.Sites.Remove(field); }+ }++ [Test]+ public void WithNoIdleHalutzTheSiteSaysHowToGetOne()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(En["site.no_halutz"], ui.Q<Label>("site-no-halutz").text);+ Assert.IsFalse(ui.Root.Query<Button>().ToList().Any(x => x.name.StartsWith("site-build-")), "no Build button without a group");+ }++ [Test]+ public void ASiteBeingBuiltShowsItsTurnsAndStopQueuesStopWork()+ {+ using var ui = new UiTestKit();+ int a = -1;+ var bridge = Bridge(En, s => { a = AddHalutz(s); s.Sites[Site] = new SiteWork(Site, a, 4, null); });+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(En.Format("site.building", En.Format("site.group", 1), En.Format("city.turns", 4)), ui.Q<Label>("site-state").text);+ UiTestKit.Press(ui.Q<Button>("site-stop"));+ Assert.IsNotNull(bridge.QueuedLike(new StopWork(a)), "Stop queues StopWork");+ }++ [Test]+ public void ABuiltSiteSaysWhenItWasFounded()+ {+ using var ui = new UiTestKit();+ var on = new DateTime(1949, 6, 30);+ var bridge = Bridge(En, s => s.Sites[Site] = SiteWork.Built(Site, on));+ using var panel = Panel(ui, bridge, En);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(En.Format("site.built", PlayerText.Date(on)), ui.Q<Label>("site-state").text);+ Assert.IsNull(ui.Root.Q<Button>("site-stop"));+ }++ [Test]+ public void TheHebrewPanelNamesTheSiteInHebrew()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(He);+ using var panel = Panel(ui, bridge, He);+ panel.Show(SiteDef.Q, SiteDef.R);+ Assert.AreEqual(SiteDef.NameHe, ui.Q<Label>("info-title").text);+ Assert.AreEqual(He["site.available"], ui.Q<Label>("site-state").text);+ panel.Show(CityHex.q, CityHex.r);+ var city = bridge.State.Cities[City];+ Assert.AreEqual(He.Format("city.housing_condition", Cities.Housed(bridge.State, city), He.Format("city.groups", city.HousingCapacity), PlayerText.Percent(city.Condition!.Value)), ui.Q<Label>("city-housing").text);+ }++ [Test]+ public void TheLegacyLoopShowsNoCityPanel()+ {+ using var ui = new UiTestKit();+ var bridge = new SimBridge(GameSession.New(SimBridgeGddTests.Legacy, GoldenRun.Seed, Mode.Historical), En);+ using var panel = Panel(ui, bridge, En);+ panel.Show(CityHex.q, CityHex.r);+ Assert.AreEqual(DisplayStyle.None, Host(ui).style.display.value);+ Assert.IsNull(ui.Root.Q<Label>("city-housing"));+ }++ /// <summary>The Done-when playthrough (#381) through the panel's own buttons, on the real content from a new game: on+ /// Tel Aviv's hex, Train halutzim (pressed again on a later turn when the Attention left refuses it); when the group has+ /// trained, on the site's hex, Build with it; End Turn until the first new yishuv's objective card is pending, then answer+ /// the cards before it with their first option until the event card shows it, with its objective line. Cards are left to+ /// their ministers otherwise, as the smoke run does with the cards the Attention cannot pay for.</summary>+ [Test]+ public void APlaythroughThroughThePanelReachesTheObjectiveCard()+ {+ using var ui = new UiTestKit();+ var bridge = Bridge(En);+ using var panel = Panel(ui, bridge, En);+ using var card = new EventCardPresenter(ui.Root, bridge, En, null);+ DateTime? trainedOn = null, buildOn = null;+ for (int turn = 0; turn < 60 && bridge.State.GameOver == null && !bridge.State.PendingEvents.Contains("first_new_yishuv"); turn++)+ {+ if (trainedOn == null)+ {+ panel.Show(CityHex.q, CityHex.r);+ UiTestKit.Press(ui.Q<Button>("city-train-halutz"));+ if (bridge.QueuedLike(new Train(City, "halutz", 1)) != null) trainedOn = bridge.State.Date;+ }+ else if (buildOn == null && bridge.State.Units.Values.Any(u => u.Type == "halutz"))+ {+ panel.Show(SiteDef.Q, SiteDef.R);+ var build = ui.Root.Query<Button>().ToList().FirstOrDefault(b => b.name.StartsWith("site-build-"));+ Assert.IsNotNull(build, $"{bridge.State.Date:yyyy-MM-dd}: the trained group has its Build button");+ UiTestKit.Press(build!);+ if (bridge.Queued.Any(x => x is PioneerWork)) buildOn = bridge.State.Date;+ }+ var r = bridge.EndTurn();+ Assert.IsEmpty(r.Rejected.Where(x => x.Command is Train || x.Command is PioneerWork).Select(x => x.Reason).ToList(), $"{bridge.State.Date:yyyy-MM-dd}: the panel's orders are taken");+ }+ Assert.IsNotNull(trainedOn, "Train halutzim was taken");+ Assert.IsNotNull(buildOn, "Build was taken");+ Assert.IsTrue(bridge.State.Sites.TryGetValue(Site, out var work) && work.BuiltOn != null, $"the site is built (by {bridge.State.Date:yyyy-MM-dd})");+ Assert.IsTrue(bridge.State.PendingEvents.Contains("first_new_yishuv"), "the objective card is pending");+ for (int guard = 0; card.Shown != null && card.Shown.Id != "first_new_yishuv" && guard < 20; guard++)+ UiTestKit.Press(ui.Root.Q<VisualElement>("event-options").Q<Button>());+ Assert.AreEqual("first_new_yishuv", card.Shown?.Id, "the event card shows the objective card");+ Assert.AreEqual(DisplayStyle.Flex, ui.Q<Label>("event-objective").style.display.value, "with its objective line");+ Assert.IsNotEmpty(ui.Q<Label>("event-objective").text);+ }+}diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs.meta b/unity/Assets/Tests/EditMode/CityPanelTests.cs.metanew file mode 100644index 000000000..750f4692c--- /dev/null+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 908ff769aa77744a1bb6d2611e385d34\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.csindex 8ca1c5ca7..038f9f933 100644--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs@@ -33,8 +33,10 @@ public class InfoPanelLayoutTests/// <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)+ static IEnumerator Rendered(int w, int h, GameSession g, System.Action<VisualElement, InfoPanelPresenter> act, System.Action<VisualElement> check,+ UiText? text = null, bool hebrew = false){+ var t = text ?? Text;var rt = new RenderTexture(w, h, 0);var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));ps.targetTexture = rt;@@ -46,10 +48,11 @@ public class InfoPanelLayoutTestsgo.SetActive(true);var root = doc.rootVisualElement;root.Q("root").RemoveFromClassList("loading");- var bridge = new SimBridge(g, Text);- var hud = new HudPresenter(root, bridge, Text);- var card = new EventCardPresenter(root, bridge, Text, null);- var info = new InfoPanelPresenter(root, bridge, Text, Names(), regions: Regions());+ if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ var bridge = new SimBridge(g, t);+ var hud = new HudPresenter(root, bridge, t);+ var card = new EventCardPresenter(root, bridge, t, null);+ var info = new InfoPanelPresenter(root, bridge, t, Names(), regions: Regions());try{act(root, info);@@ -129,6 +132,43 @@ public class InfoPanelLayoutTestsAssert.IsEmpty(problems, string.Join("\n", problems));}+ /// <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:+ /// 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]+ public IEnumerator TheGddCityAndSitePanelsFitEveryWindow()+ {+ 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 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) })+ {+ 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)); }+ 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; }+ 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 (!Inside(l.worldBound, panel.worldBound)) 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>Before a hex is chosen the panel is a one-line hint (the promo shows no panel until a tile is chosen): no/// terrain sign, no rows, and no taller than the hint's line and the panel's padding.</summary>[UnityTest]diff --git a/unity/Assets/Tests/EditMode/SiteLabelTests.cs b/unity/Assets/Tests/EditMode/SiteLabelTests.csnew file mode 100644index 000000000..6ee1f0363--- /dev/null+++ b/unity/Assets/Tests/EditMode/SiteLabelTests.cs@@ -0,0 +1,62 @@+#nullable enable+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.UIElements;++/// <summary>GDD Phase 1 PR 8 (#381): a built site's name is a map pill like a town's (MapLabelsPresenter.SetSites): placed and+/// decluttered by the same rules, clear of every other pill and of the panels, and gone when the site is no longer built.</summary>+public class SiteLabelTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ MapScene map = null!;+ Camera cam = null!;++ [SetUp]+ public void Open()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ cam = Camera.main;+ }++ [TearDown]+ public void Close() { cam.targetTexture = null; EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }++ static Settlement Mefalsim()+ {+ var site = C.Sites.Single(s => s.Id == "mefalsim");+ var hex = C.HexAt(site.Q, site.R)!;+ return new Settlement { Id = SiteLayer.Prefix + site.Id, Name = site.Name, NameHe = site.NameHe, Type = "kibbutz", Lon = hex.Lon, Lat = hex.Lat };+ }++ static bool Shown(VisualElement slot) => slot.style.visibility.value == Visibility.Visible;++ [Test]+ public void ABuiltSitesNameIsAPillClearOfTheOthersAndGoesWithIt()+ {+ using var ui = new UiTestKit();+ using var labels = new MapLabelsPresenter(ui.Root, map, cam);+ var site = Mefalsim();+ var rig = cam.GetComponent<CameraRig>();+ rig.LookAt = map.Frame.ToWorld(site.Lon, site.Lat, 0); rig.Distance = 40000f; rig.Yaw = 0; rig.TopInset = 0; rig.Apply();++ labels.SetSites(new[] { (site, (Bounds[]?)null) });+ labels.Refresh(force: true);+ var slot = ui.Root.Q<VisualElement>("slot-" + site.Id);+ Assert.IsNotNull(slot, "the site has a pill");+ Assert.AreEqual("Mefalsim", slot.Q<Label>().text);+ Assert.IsTrue(Shown(slot), "close over the site, its pill shows");+ var rect = slot.Q<Label>().worldBound;+ foreach (var other in ui.Root.Query<VisualElement>(className: MapLabelsPresenter.SlotClass).ToList().Where(s => s != slot && Shown(s)))+ Assert.IsFalse(rect.Overlaps(other.Q<Label>().worldBound), $"the site's pill {rect} overlaps {other.name} {other.Q<Label>().worldBound}");++ labels.SetSites(System.Array.Empty<(Settlement, Bounds[]?)>());+ Assert.IsNull(ui.Root.Q<VisualElement>("slot-" + site.Id), "no pill once the site is not built");+ }+}diff --git a/unity/Assets/Tests/EditMode/SiteLabelTests.cs.meta b/unity/Assets/Tests/EditMode/SiteLabelTests.cs.metanew file mode 100644index 000000000..19590f6d0--- /dev/null+++ b/unity/Assets/Tests/EditMode/SiteLabelTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 20bae39d873b44f9a9ab02f3f7e9e9fe\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/SiteLayerTests.cs b/unity/Assets/Tests/EditMode/SiteLayerTests.csnew file mode 100644index 000000000..86267f840--- /dev/null+++ b/unity/Assets/Tests/EditMode/SiteLayerTests.cs@@ -0,0 +1,71 @@+#nullable enable+using System;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Map;+using Statecraft.Sim;+using UnityEditor;+using UnityEditor.SceneManagement;+using UnityEngine;++/// <summary>GDD Phase 1 PR 8 (#381): SiteLayer draws a site being built as a scaffold on its hex, a built site as a rural+/// kit (or the kibbutz marker box with the kits off) on its hex, an available site as nothing, and replaces what it drew.</summary>+public class SiteLayerTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ const string Id = "mefalsim";++ static MapScene Map()+ {+ new GameObject("TestMainCamera") { tag = "MainCamera" }.AddComponent<Camera>();+ var map = new GameObject("MapScene").AddComponent<MapScene>();+ map.Configure(AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/Terrain.mat"),+ AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/SettlementMarker.mat"),+ AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/HexSelection.mat"),+ AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/Sea.mat"),+ AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/MapFrame.mat"));+ map.Build();+ return map;+ }++ static (int q, int r) SiteHex => C.Sites.Where(x => x.Id == Id).Select(x => (x.Q, x.R)).Single();++ [Test]+ public void EachSiteStateIsDrawnOnItsHexAndRenderReplacesIt()+ {+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ try+ {+ var map = Map();+ var layer = new GameObject("Sites").AddComponent<SiteLayer>();+ var hex = C.HexAt(SiteHex.q, SiteHex.r)!;+ var centre = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);++ layer.Render(Array.Empty<SiteWork>(), C, map);+ Assert.AreEqual(0, layer.transform.childCount, "an available site draws nothing");++ layer.Render(new[] { new SiteWork(Id, 1, 4, null) }, C, map);+ Assert.AreEqual(1, layer.transform.childCount, "one scaffold");+ var scaffold = layer.transform.GetChild(0);+ Assert.AreEqual(SiteLayer.Prefix + Id + SiteLayer.ScaffoldSuffix, scaffold.name);+ Assert.AreEqual(centre.x, scaffold.position.x, 1f); Assert.AreEqual(centre.z, scaffold.position.z, 1f);+ Assert.AreEqual(SiteHex, MapPointer.Pick(map, scaffold.position), "the scaffold stands on the site's hex");+ Assert.IsEmpty(layer.Columns, "no kit while it is built");++ layer.Render(new[] { SiteWork.Built(Id, new DateTime(1949, 6, 30)) }, C, map);+ Assert.AreEqual(1, layer.transform.childCount, "Render replaced the scaffold");+ var place = layer.transform.GetChild(0);+ Assert.AreEqual(SiteLayer.Prefix + Id, place.name);+ var bounds = place.GetComponent<MeshRenderer>().bounds;+ Assert.AreEqual(SiteHex, MapPointer.Pick(map, new Vector3(bounds.center.x, centre.y, bounds.center.z)), "the place stands on the site's hex");+ if (map.KitsShown)+ {+ Assert.AreNotEqual("Cube", place.GetComponent<MeshFilter>().sharedMesh.name, "a rural kit, not the marker box");+ Assert.IsTrue(layer.Columns.ContainsKey(SiteLayer.Prefix + Id), "its columns are kept for the name pill");+ }+ else Assert.AreEqual("Cube", place.GetComponent<MeshFilter>().sharedMesh.name, "with the kits off, the kibbutz marker box");+ }+ finally { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); }+ }+}diff --git a/unity/Assets/Tests/EditMode/SiteLayerTests.cs.meta b/unity/Assets/Tests/EditMode/SiteLayerTests.cs.metanew file mode 100644index 000000000..f25431bb3--- /dev/null+++ b/unity/Assets/Tests/EditMode/SiteLayerTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 0a79b48c2359b48d0ba0499c42ae6e26\ No newline at end of filediff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex c19a6699d..04beb0c1d 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -138,6 +138,9 @@</ui:VisualElement><ui:Label name="info-reason" class="reason" /></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). -->+ <ui:VisualElement name="info-gdd" class="info-gdd" /><Statecraft.Game.UI.UiFrame filigree="true" /></ui:VisualElement><!-- The decision layer under the top bar (decision cards, 2026-10-13): while an event is open a dim backdrop blocks thediff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 703247c78..2b43cb3ac 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -300,6 +300,15 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.info-body { flex-grow: 1; flex-shrink: 1; min-width: 0; }.info-body > .row { flex-wrap: wrap; }.info-body > .row Button { margin-right: 6px; font-size: 18px; }+/* The GDD loop's part (GddHexPanel, #381): a city's counts, its Assign stepper, Train and Cancel; a site's state and+ Build/Stop. A second column beside the hex's facts, so the panel stays under the left column on a short window+ (InfoPanelLayoutTests.TheGddCityAndSitePanelsFitEveryWindow): the panel widens to hold it. Its rows wrap their buttons,+ a long button label wraps, and a row mirrors in Hebrew (.lang-he .row). */+.info-panel.info-gdd-shown { width: 920px; }+.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; }/* Before a hex is chosen only the hint shows (InfoPanelPresenter sets info-empty): a one-line chip that hugs its text, asthe promo shows no panel until a tile is chosen (HUD round 1, #398). */.info-panel.info-empty { min-height: 0; width: auto; padding: 8px 16px; }@@ -738,3 +747,11 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.lang-he .end-turn { padding: 4px 40px 4px 14px; }/* A bar fills from the right: the whole bar is flipped, so its fill and its mark (placed from the left in code) follow. */.lang-he .ui-bar { scale: -1 1; }++/* #381: in Hebrew the GDD column's rule and margins mirror; on the two- and three-row HUD (narrower windows, taller) the+ 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; }+.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.yamlindex 6b00bc097..483c35bbf 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -300,3 +300,31 @@ save.warning.replay_differs: "The game was restored, but not exactly as it was sboot.failed: "Statecraft could not start: {0}. Reload the page."boot.reason_other: "its files failed to load"save.write_failed: "Your game could not be saved."+# The info panel in the GDD loop (GddHexPanel, #381): a city's counts and orders, in population groups (D-A1), and the+# designated site's state and Build/Stop. {0}, {1}: numbers from the sim (State.Cities, unit_types.yaml, rules.yaml mvp).+city.housing: "Housing: {0} of {1}"+city.housing_condition: "Housing: {0} of {1}, condition {2}"+city.jobs: "Jobs: {0} of {1} filled"+city.refugees: "Refugees waiting: {0}"+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_ordered: "{0} ordered"+city.track_recruit: "Recruits"+city.track_halutz: "Halutzim"+city.cohort: "{0}: {1} in training, {2} left"+city.cancel: "Cancel"+city.groups_one: "1 group"+city.groups: "{0} groups"+city.turns_one: "1 turn"+city.turns: "{0} turns"+city.cancel_ordered: "Cancel ordered"+site.available: "A designated site for a new yishuv"+site.group: "halutz group {0}"+site.build: "Build a yishuv with {0}: {1}, {2}"+site.no_halutz: "No halutz group is free. Train one in a city with a Hakhshara."+site.building: "Being built by {0}: {1} left"+site.stop: "Stop building (the money spent is lost)"+site.built: "Founded on {0}"+site.ordered: "Ordered"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex d23fbf01a..47189af42 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -304,3 +304,30 @@ boot.failed: "לא ניתן היה להפעיל את Statecraft: {0}. יש לט# For the native reviewer (#564).boot.reason_other: "קבצי המשחק לא נטענו"save.write_failed: "לא ניתן היה לשמור את המשחק."+# The info panel in the GDD loop (GddHexPanel, #381); the GDD's Hebrew for Halutz (חלוץ) and Hakhshara (הכשרה).+city.housing: "דיור: {0} מתוך {1}"+city.housing_condition: "דיור: {0} מתוך {1}, מצב {2}"+city.jobs: "משרות: {0} מתוך {1} מאוישות"+city.refugees: "פליטים ממתינים: {0}"+city.recruits: "מגויסים: {0}"+city.workers: "בעבודה: {0}"+city.train_recruit: "אימון מגויסים: קבוצה אחת, {0}, {1}"+city.train_halutz: "הכשרת חלוצים: קבוצה אחת, {0}, {1}"+city.train_ordered: "הוזמנו {0}"+city.track_recruit: "מגויסים"+city.track_halutz: "חלוצים"+city.cohort: "{0}: {1} באימון, עוד {2}"+city.cancel: "ביטול"+city.groups_one: "קבוצה אחת"+city.groups: "{0} קבוצות"+city.turns_one: "תור אחד"+city.turns: "{0} תורות"+city.cancel_ordered: "הביטול הוזמן"+site.available: "אתר ייעודי ליישוב חדש"+site.group: "קבוצת חלוצים {0}"+site.build: "הקמת יישוב עם {0}: {1}, {2}"+site.no_halutz: "אין קבוצת חלוצים פנויה. אפשר להכשיר קבוצה בעיר שיש בה הכשרה."+site.building: "בבנייה בידי {0}: עוד {1}"+site.stop: "עצירת הבנייה (הכסף שהוצא לא יוחזר)"+site.built: "נוסד ב־{0}"+site.ordered: "הוזמן"