Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

feat(#1722): GDD 0.3 city panel lists the city's projects and shows its housing readout (#2969)

Eyal Golan220495fae140
diff --git a/changelog.d/c30-1722-city-panel-projects.md b/changelog.d/c30-1722-city-panel-projects.md
new file mode 100644
index 000000000..544562185
--- /dev/null
+++ b/changelog.d/c30-1722-city-panel-projects.md
@@ -0,0 +1,3 @@
+### Added
+
+- GDD 0.3 rules only: a city's panel now lists all of that city's projects, wherever they stand. A project being built shows its work done, its cost, whether it has a builder, and a Cancel button. On the city's own hex, a housing repair under way now shows once, as its row in this list, instead of also in the hex's project lines. A finished project shows the day it was finished and its cost. Under the housing line the panel shows the housing surcharge the city pays a turn as things stand now (or that there is none), how far overflow lowers the housing condition, and the Social cohesion lost each turn while the condition is below 25%. A figure too small to show at the panel's rounding gets no line. Each value is worked out by the simulation, in English and Hebrew (Refs #1722). The shipped GDD 0.1 game is unchanged.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 3c082fcae..6efd3bcbc 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -148,7 +148,7 @@ For R-HOUSE-003, the inactive gdd-0.3 helper takes independently supplied surcha
R-HOUSE-004: In the GDD loop the base of the national `housing` indicator is the people-weighted mean of the cities' housing condition, each city weighed by its housed people (R-HOUSE-003): `sum(condition * housed) / sum(housed)`. Policy effects, map actions and events still act on top, as on any indicator. Decided (owner, 17 Oct 2026, option (a) of Q-PR3-A, relayed on [#855 at 06:33Z](https://github.com/eyalgolan/statecraft-israel/pull/855#issuecomment-6230731177)): the national housing base is the people-weighted mean of city condition, with policy, map actions and events still applied on top. When no city houses anybody the mean is undefined, and the base is `model.yaml`'s. Capacity reaches the level through overflow and condition (R-HOUSE-002).
-R-HOUSE-005: Under `gdd-0.3` only (#1703, the MVP's per-city housing condition), the housing step after R-CITY-004 settles, in #1703's order ("Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once."), for every city with a condition, with R its housed people (R-HOUSE-003) and P all own population (every city's housed people and refugees plus the strength of every player unit, halutz units included; with an initialized Historical ledger, every city's housed and refugee records plus the active soldier records, so a record in no tracked city, such as a farmer at Nir Am or Nirim, is not in P, as the owner's 2 November 2026 answer "The 12 cities' people (Recommended)" keeps P to "only the cities whose housing is tracked"; #1725 PR 7): (1) a surcharge of `R * max(0, money_threshold - c) * money_slope` Money a turn from the condition c before this turn's deterioration, summed over the cities into one Money line (`housing_surcharge`) and borrowed when the Treasury is short (R-MONEY-003); `money_threshold` is 0.50 and `money_slope` is 0.1 Money per housed population unit (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start."), so the shipped census start charges 511 housed units x 0.15 x 0.1 = 7.665 Money on the opening turn; (2) overflow deterioration of `overflow_deterioration * max(0, R - housing_capacity) / R` percentage points (5 pp; owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)"), never below 0, in place of R-HOUSE-002's `overflow_condition_loss`; zero housed loses nothing; (3) a Social cohesion loss of `max_cohesion_loss * sum((R / P) * max(0, (cohesion_threshold - c') / cohesion_threshold))` displayed points (`max_cohesion_loss` 2, `cohesion_threshold` 0.25; owner, 2 November 2026: "Keep the 2-point loss (Recommended)") from the condition c' after deterioration, applied once to `morale` through its permanent shift with one cause line (`housing_cohesion`); zero own population loses nothing. The legacy `homes_lift_morale` link from `housing` into `morale` adds nothing under `gdd-0.3`, so housing lowers Social cohesion only through (3) (#1703 Done-when, with #1715; the Food term stays #1715's). There is no housing upkeep (27M-17, IL 0m), so no unpaid-upkeep deterioration. Values: `content/gdd03-balance.yaml` (`housing.*`), read by `Gdd03HousingFormula`; code: `Cities.UpdateCondition` and `Cities.SettleGdd03`, `EffectsSystem.RetiredGdd03Link`; tests: `Gdd03HousingConditionTests`, `Gdd03MoneyLedgerTests`. The issue's three rules run under `gdd-0.3`: the 5 pp overflow (owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)") and the cohesion term (owner, 2 November 2026: "Keep the 2-point loss (Recommended)"; the option read: "As issue #1703 specifies, GDD 0.3 only."). P is the 12 cities' people as built, plus the player units (owner, 2 November 2026: "The 12 cities' people (Recommended)"; the option read: "As built: only the cities whose housing is tracked."). R is counted after the step's housing arrivals (owner, 2 November 2026: "After housing arrivals (Recommended)"; 27M-15). Formations are not housed (owner, 3 November 2026: "Yes, formations not housed (Recommended)", #1703); repairs are R-HOUSE-006. On an initialized Historical ledger (the dark start, #1725 PR 7) the step runs as above, with R and P counted from the ledger's records (R-HOUSE-003), and changes no record; a synthetic or Open ledger is still refused (R-POP-002). The halutz-unit case is not handled yet on a ledger game (R-HOUSE-003, R-HOUSE-005): no record is a halutz unit at the dark start, and the ledger counts have no halutz rule, so a later halutz-unit record would be counted only by its status and city, not as a halutz unit.
+R-HOUSE-005: Under `gdd-0.3` only (#1703, the MVP's per-city housing condition), the housing step after R-CITY-004 settles, in #1703's order ("Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once."), for every city with a condition, with R its housed people (R-HOUSE-003) and P all own population (every city's housed people and refugees plus the strength of every player unit, halutz units included; with an initialized Historical ledger, every city's housed and refugee records plus the active soldier records, so a record in no tracked city, such as a farmer at Nir Am or Nirim, is not in P, as the owner's 2 November 2026 answer "The 12 cities' people (Recommended)" keeps P to "only the cities whose housing is tracked"; #1725 PR 7): (1) a surcharge of `R * max(0, money_threshold - c) * money_slope` Money a turn from the condition c before this turn's deterioration, summed over the cities into one Money line (`housing_surcharge`) and borrowed when the Treasury is short (R-MONEY-003); `money_threshold` is 0.50 and `money_slope` is 0.1 Money per housed population unit (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start."), so the shipped census start charges 511 housed units x 0.15 x 0.1 = 7.665 Money on the opening turn; (2) overflow deterioration of `overflow_deterioration * max(0, R - housing_capacity) / R` percentage points (5 pp; owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)"), never below 0, in place of R-HOUSE-002's `overflow_condition_loss`; zero housed loses nothing; (3) a Social cohesion loss of `max_cohesion_loss * sum((R / P) * max(0, (cohesion_threshold - c') / cohesion_threshold))` displayed points (`max_cohesion_loss` 2, `cohesion_threshold` 0.25; owner, 2 November 2026: "Keep the 2-point loss (Recommended)") from the condition c' after deterioration, applied once to `morale` through its permanent shift with one cause line (`housing_cohesion`); zero own population loses nothing. The legacy `homes_lift_morale` link from `housing` into `morale` adds nothing under `gdd-0.3`, so housing lowers Social cohesion only through (3) (#1703 Done-when, with #1715; the Food term stays #1715's). There is no housing upkeep (27M-17, IL 0m), so no unpaid-upkeep deterioration. Values: `content/gdd03-balance.yaml` (`housing.*`), read by `Gdd03HousingFormula`; code: `Cities.UpdateCondition` and `Cities.SettleGdd03`, `EffectsSystem.RetiredGdd03Link`; tests: `Gdd03HousingConditionTests`, `Gdd03MoneyLedgerTests`. The issue's three rules run under `gdd-0.3`: the 5 pp overflow (owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)") and the cohesion term (owner, 2 November 2026: "Keep the 2-point loss (Recommended)"; the option read: "As issue #1703 specifies, GDD 0.3 only."). P is the 12 cities' people as built, plus the player units (owner, 2 November 2026: "The 12 cities' people (Recommended)"; the option read: "As built: only the cities whose housing is tracked."). R is counted after the step's housing arrivals (owner, 2 November 2026: "After housing arrivals (Recommended)"; 27M-15). Formations are not housed (owner, 3 November 2026: "Yes, formations not housed (Recommended)", #1703); repairs are R-HOUSE-006. On an initialized Historical ledger (the dark start, #1725 PR 7) the step runs as above, with R and P counted from the ledger's records (R-HOUSE-003), and changes no record; a synthetic or Open ledger is still refused (R-POP-002). The halutz-unit case is not handled yet on a ledger game (R-HOUSE-003, R-HOUSE-005): no record is a halutz unit at the dark start, and the ledger counts have no halutz rule, so a later halutz-unit record would be counted only by its status and city, not as a halutz unit. The city panel shows each city's terms on the state as it is now (`Cities.HousingOutlook`, #1722): the same formula, with that city's R and the current P and condition, changing nothing; the turn's own step can differ, as the step's arrivals and finished repairs come first.
R-HOUSE-006: Under `gdd-0.3` only (#1700, #1703), a housing repair is the city project `housing_repair` (`content/projects.yaml`): "A repair costs 0.5 Money and 1 work and raises the city's housing condition by 10 percentage points" (`docs/GDD.md`, "Housing repair price"; owner, 1 November 2026: "Fixed price 0.5 Money + 1 work"; labelled design values). Its row matches `content/gdd03-balance.yaml` `housing_repair`, which the loader checks: `cost` 0.5, `work` 1 as `turns: 1` (maintainer call (not an owner ruling): one turn of a builder's work, as `arms_workshop`'s work 3 is its 3 turns), `condition_pp` 10 as `condition: 0.1`, and no capacity or job slots. It is started, paid, built and cancelled as any city project (R-PROJ-001 to R-PROJ-003, R-CITY-010, R-CITY-011): the Treasury pays 0.5 at the start and borrows what it lacks (R-MONEY-003), it uses the turn's city start (one per city, plus `map_actions_per_turn` 2 nationally), it needs a builder to gain its turn of work, the `housing_construction` multiplier (the Labour minister's, `content/rules.yaml`) scales that work as for every housing build (R-MIN-002; maintainer call (not an owner ruling): a repair counts as a Housing build, so with a weak minister it can take more than one turn), and its builder is freed when it is done or cancelled. When done it adds 10 percentage points to its city's condition, never above 1. A repair is done on the city itself and has no hex of its own (owner, 3 November 2026: "No hex needed (Recommended)"; the option read: "Repairs are done on the city itself; they fix existing housing." [#1700](https://github.com/eyalgolan/statecraft-israel/issues/1700#issuecomment-6610259201)). This departs from Q-PROJ-2 for repairs only: a repair is ordered on its city's settlement hex and nowhere else (refused elsewhere as "A housing repair is done on Town A's own hex"), whatever placement or city project that hex holds, and takes the hex from no other project; once done its record leaves the state, so it leaves no building and the hex still shows its own project. Every other kind keeps Q-PROJ-2's free hex. The repair lands on step 5, before R-HOUSE-005's deterioration on the housing step, so a city with overflow can gain less than 10 points in that turn. `gdd-0.1` and legacy have no repair: the loader keeps the row out of them.
diff --git a/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs b/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs
index 352bf9016..99738e575 100644
--- a/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs
+++ b/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs
@@ -258,4 +258,87 @@ public class Gdd03HousingConditionTests
Assert.Empty(UpdateCondition(Real01, low));
Assert.Equal((t, m), (low.Treasury, low.Indicators["morale"]));
}
+
+ // R-HOUSE-005, #1722 (the city panel's housing readout): Cities.HousingOutlook reads, without changing the state, what
+ // UpdateCondition would settle for one city on the same state: the surcharge priced before deterioration, the condition
+ // after the 5 pp overflow and the cohesion shift on morale. 10 housed in no housing at 0.27: 0.23 Money, 0.22, -0.0024.
+ [Fact]
+ public void HousingOutlookReadsWhatUpdateConditionSettles()
+ {
+ var s = OneCity(Real03, civilians: 10, capacity: 0, condition: 0.27);
+ s.Treasury = 100;
+ var id = s.Cities.Keys.Single();
+ var hash = s.Hash();
+ var o = Cities.HousingOutlook(Real03, s, id)!.Value;
+ Assert.Equal(hash, s.Hash()); // a read: no state change
+ var why = UpdateCondition(Real03, s);
+ Assert.Equal(-Assert.Single(why, w => w.Key == CauseKeys.HousingSurcharge).Delta, o.Surcharge, 12);
+ Assert.Equal(s.Cities[id].Condition!.Value, o.ConditionAfter, 12);
+ Assert.Equal(Assert.Single(why, w => w.Key == CauseKeys.HousingCohesion).Delta, o.CohesionShift, 12);
+ Assert.Equal((0.50, 0.25), (o.MoneyThreshold, o.CohesionThreshold)); // content/gdd03-balance.yaml housing.*
+ }
+
+ // R-HOUSE-005: at or above both thresholds with no overflow there is nothing to read but the condition itself.
+ [Fact]
+ public void HousingOutlookIsZeroForAWellHousedCity()
+ {
+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.60);
+ var o = Cities.HousingOutlook(Real03, s, s.Cities.Keys.Single())!.Value;
+ Assert.Equal((0.0, 0.60, 0.0), (o.Surcharge, o.ConditionAfter, o.CohesionShift));
+ }
+
+ // gdd-0.1 has no surcharge or cohesion term (R-HOUSE-005 is gdd-0.3 only), and an unknown city or one with no condition
+ // has no readout.
+ [Fact]
+ public void HousingOutlookIsNullOutsideGdd03AndForACityWithNoCondition()
+ {
+ var legacy = OneCity(Real01, civilians: 10, capacity: 10, condition: 0.10);
+ Assert.Null(Cities.HousingOutlook(Real01, legacy, legacy.Cities.Keys.Single()));
+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.10);
+ Assert.Null(Cities.HousingOutlook(Real03, s, "no_such_city"));
+ var id = s.Cities.Keys.Single();
+ s.Cities[id] = new City(id, 10, 0, 10, 0, 0);
+ Assert.Null(Cities.HousingOutlook(Real03, s, id));
+ }
+ // R-HOUSE-003, R-HOUSE-005 (#1722 review S3): on the dark start (an initialized Historical ledger) R and P come from the
+ // ledger's records, and the readout is still what UpdateCondition settles: every city's condition after the step, the
+ // Treasury's fall by the cities' surcharges and Social cohesion's by their shifts. Haifa is put in no housing at 0.22
+ // (TEST-ONLY SYNTHETIC values) so that all three terms are live.
+ [Fact]
+ public void HousingOutlookOnTheDarkStartReadsWhatUpdateConditionSettles()
+ {
+ var c = HistoricalPopulationTests.Real(true);
+ var s = Simulation.NewGame(c, 1, Mode.Historical, darkStart: true);
+ Assert.True(s.PopulationLedger.IsInitialized && s.PopulationLedger.IsHistorical, "precondition: the dark start's ledger");
+ var x = s.Cities["haifa"];
+ s.Cities["haifa"] = new City(x.Id, 0, x.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits, 0.22, x.Craftsmen, x.JobsDefault, x.Qualified);
+ s.Treasury = 1000; s.Debt = 0;
+ var hash = s.Hash();
+ var outlook = s.Cities.Values.Where(y => y.Condition != null).OrderBy(y => y.Id, StringComparer.Ordinal)
+ .Select(y => (y.Id, O: Cities.HousingOutlook(c, s, y.Id)!.Value)).ToList();
+ Assert.Equal(hash, s.Hash());
+ var haifa = outlook.Single(o => o.Id == "haifa").O;
+ Assert.True(haifa.Surcharge > 0 && haifa.ConditionAfter < 0.22 && haifa.CohesionShift < 0, "precondition: all three terms are live");
+ var t = s.Treasury; var m = s.Indicators[Cities.CohesionIndicator];
+ UpdateCondition(c, s);
+ foreach (var (id, o) in outlook) Assert.Equal(s.Cities[id].Condition!.Value, o.ConditionAfter, 12);
+ Assert.Equal(t - outlook.Sum(o => o.O.Surcharge), s.Treasury, 9);
+ Assert.Equal(m + outlook.Sum(o => o.O.CohesionShift), s.Indicators[Cities.CohesionIndicator], 9);
+ }
+
+ // R-POP-002 (#1722 review S3): on an initialized ledger that is not Historical (here an Open one) UpdateCondition refuses
+ // to run, so the readout is null; the same city on a game with no ledger has one.
+ [Fact]
+ public void HousingOutlookIsNullOnALedgerThatIsNotHistorical()
+ {
+ var plain = OneCity(Real03, civilians: 10, capacity: 0, condition: 0.22);
+ var id = plain.Cities.Keys.Single();
+ Assert.NotNull(Cities.HousingOutlook(Real03, plain, id));
+ var open = PopulationLedger.CreateFixture(Real03, PopulationLedgerTests.Bindings(),
+ new[] { new PopulationInventoryRow("fixture", 0, PopulationLedgerTests.Person()) }, mode: Mode.Open);
+ Assert.Equal((true, false), (open.PopulationLedger.IsInitialized, open.PopulationLedger.IsHistorical));
+ open.Cities[id] = plain.Cities[id];
+ Assert.Throws<NotSupportedException>(() => UpdateCondition(Real03, open));
+ Assert.Null(Cities.HousingOutlook(Real03, open, id));
+ }
}
diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.cs
index bc9ddcfa4..24b341582 100644
--- a/sim/Statecraft.Sim/Cities.cs
+++ b/sim/Statecraft.Sim/Cities.cs
@@ -350,6 +350,39 @@ namespace Statecraft.Sim
}
}
+ /// <summary>#1722 (the city panel's housing readout): what <see cref="UpdateCondition"/> would settle for
+ /// <paramref name="city"/> on the state as it is now, under gdd-0.3 (R-HOUSE-005): the surcharge priced from the
+ /// current condition, the condition after the overflow deterioration and the cohesion shift on <c>morale</c>
+ /// (<c>-points / 100</c>, before the indicator's bounds), with the catalogue's two thresholds. It changes no state. The
+ /// turn's own housing step may differ: arrivals and finished repairs change R and the condition before it runs (step
+ /// order, R-HOUSE-005), and the cohesion term is settled once for all cities. Null outside gdd-0.3, for a city not in
+ /// the state or with no condition, and on a population-ledger state that is not Historical (UpdateCondition refuses
+ /// those).</summary>
+ public static HousingReadout? HousingOutlook(Content c, GameState s, string city)
+ {
+ if (c.Ruleset != SaveGame.Gdd03Ruleset || !s.Cities.TryGetValue(city, out var x) || !(x.Condition is double was)) return null;
+ if (s.PopulationLedger.IsInitialized && !s.PopulationLedger.IsHistorical) return null;
+ var gdd03 = Gdd03HousingFormula.FromCatalogue(c.Gdd03Balance!);
+ var h = gdd03.EvaluateTurn(Housed(s, x), OwnPopulation(s), x.HousingCapacity, was);
+ return new HousingReadout(h.Surcharge, h.ConditionAfter, -h.Cohesion / 100.0, gdd03.MoneyThreshold, gdd03.CohesionThreshold);
+ }
+
+ /// <summary><see cref="HousingOutlook"/>'s values: Surcharge in Money (Target treasury), ConditionAfter on the 0 to 1
+ /// scale, CohesionShift as a change of the <c>morale</c> indicator, and the two thresholds on the condition's scale.</summary>
+ public readonly struct HousingReadout
+ {
+ public double Surcharge { get; }
+ public double ConditionAfter { get; }
+ public double CohesionShift { get; }
+ public double MoneyThreshold { get; }
+ public double CohesionThreshold { get; }
+ public HousingReadout(double surcharge, double conditionAfter, double cohesionShift, double moneyThreshold, double cohesionThreshold)
+ {
+ Surcharge = surcharge; ConditionAfter = conditionAfter; CohesionShift = cohesionShift;
+ MoneyThreshold = moneyThreshold; CohesionThreshold = cohesionThreshold;
+ }
+ }
+
/// <summary>Social cohesion's indicator id (R-NAT-001), which the gdd-0.3 housing cohesion term moves (R-HOUSE-005).</summary>
public const string CohesionIndicator = "morale";
diff --git a/sim/Statecraft.Sim/Gdd03HousingFormula.cs b/sim/Statecraft.Sim/Gdd03HousingFormula.cs
index bc6601ad1..cffc14320 100644
--- a/sim/Statecraft.Sim/Gdd03HousingFormula.cs
+++ b/sim/Statecraft.Sim/Gdd03HousingFormula.cs
@@ -10,6 +10,10 @@ namespace Statecraft.Sim
readonly decimal conditionMax, moneyThreshold, moneySlope, cohesionThreshold;
readonly decimal maxCohesionLoss, overflowPp, repairPp;
internal string OverflowBasis { get; }
+ /// <summary>The condition below which the surcharge is charged and below which cohesion is lost (R-HOUSE-005), for
+ /// <see cref="Cities.HousingOutlook"/>'s readout.</summary>
+ internal double MoneyThreshold => (double)moneyThreshold;
+ internal double CohesionThreshold => (double)cohesionThreshold;
Gdd03HousingFormula(Gdd03BalanceCatalogue c)
{
diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.cs
index 480128d99..d9a33da82 100644
--- a/unity/Assets/Scripts/UI/GddHexPanel.cs
+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs
@@ -19,7 +19,8 @@ namespace Statecraft.Game.UI
/// can), and Build for each content project kind with its cost and turns (Projects.CityTurnsToBuild), disabled with the sim's own refusal
/// (Projects.CheckCityReason) worded in the UI's language; or the project there, with its turns left and Cancel, or the
/// day it was finished (R-PROJ-001 to R-PROJ-003); under gdd-0.3, on a built arms workshop, its staffing and cycle (#1722,
- /// R-ARMS-005 to R-ARMS-007).</para>
+ /// R-ARMS-005 to R-ARMS-007). Under gdd-0.3 the city's block also has its housing readout (Cities.HousingOutlook,
+ /// R-HOUSE-005) and the list of all its projects with their work done, cost, builder and Cancel (#1722).</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, Workshops.Check) and
/// Simulation.Preview, asked with the exact queue a press would leave; a button is disabled only where the sim would refuse that
@@ -101,6 +102,7 @@ namespace Statecraft.Game.UI
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));
+ HousingLines(host, bridge, text, id);
// #1121: the craftsmen (R-CRAFT-001) beside Jobs, as they fill ordinary jobs (R-CRAFT-002), and the overflow
// (R-HOUSE-002, Cities.Overflow) beside the refugees waiting, the other people without housing. Each pair shares a
// row (the labels keep their width and the row wraps only when they do not fit, Statecraft.uss), so on a short
@@ -235,8 +237,59 @@ namespace Statecraft.Game.UI
var hex = c.SettlementHexes.First(h => h.Id == id); // every settlement has one
foreach (var u in s.Units.Values.Where(u => Projects.IsPioneer(u.Type) && u.Q == hex.Q && u.R == hex.R))
PioneerReturn(host, bridge, text, u.Id);
+ ProjectList(host, bridge, text, id);
}
+ /// <summary>#1722 (R-HOUSE-005), gdd-0.3 only: the city's housing readout under its housing line, Cities.HousingOutlook
+ /// on the state as it is now: the surcharge a turn and the threshold it is charged below, or that there is none; the
+ /// condition the overflow lowers it to, when it does; Social cohesion's change a turn and its threshold, when there is
+ /// one. Every value and threshold is the sim's; nothing is computed here.</summary>
+ static void HousingLines(VisualElement host, SimBridge bridge, UiText text, string id)
+ {
+ if (!(Cities.HousingOutlook(bridge.Content, bridge.State, id) is Cities.HousingReadout o)) return;
+ var c = bridge.Content; var condition = bridge.State.Cities[id].Condition!.Value;
+ // #1722 review S2: a term shows only when its figure, rounded as shown, says something. A surcharge under the
+ // smallest amount shown has no line ("IL 0.0m a turn" says nothing, and "none" would not be true).
+ var surcharge = PlayerText.Money(c, "treasury", o.Surcharge);
+ if (o.Surcharge <= 0) Line(host, "city-surcharge", text.Format("city.housing_no_surcharge", PlayerText.Percent(o.MoneyThreshold)));
+ else if (surcharge != PlayerText.Money(c, "treasury", 0))
+ Line(host, "city-surcharge", text.Format("city.housing_surcharge", surcharge, PlayerText.Percent(o.MoneyThreshold)));
+ if (o.ConditionAfter < condition && PlayerText.Percent(o.ConditionAfter) != PlayerText.Percent(condition))
+ Line(host, "city-housing-falls", text.Format("city.housing_falls", PlayerText.Percent(o.ConditionAfter)));
+ if (o.CohesionShift < 0 && PlayerText.PercentChange(o.CohesionShift) != PlayerText.PercentChange(0))
+ Line(host, "city-housing-cohesion", text.Format("city.housing_cohesion", PlayerText.PercentChange(o.CohesionShift), PlayerText.Percent(o.CohesionThreshold)));
+ }
+
+ /// <summary>#1722 (R-PROJ-001 to R-PROJ-003, R-CITY-011, R-HOUSE-006), gdd-0.3 only: every project of the city in id
+ /// order, wherever it stands (a repair has no hex of its own): for one being built its whole turns of work done of
+ /// the kind's turns (the kind's turns less the record's TurnsLeft, which step 5 counts down, R-PROJ-003), the kind's
+ /// cost, which its start paid in full (Projects.StartCity, R-PROJ-001), whether it has a builder (R-CITY-011) and Cancel
+ /// (R-PROJ-002); for a built one the day it was finished and its cost. There is no upkeep column: upkeep is IL 0m in
+ /// the MVP (27M-17).</summary>
+ static void ProjectList(VisualElement host, SimBridge bridge, UiText text, string id)
+ {
+ var c = bridge.Content; var s = bridge.State;
+ if (!Listed(c, s, id)) return;
+ var mine = s.CityProjects.Values.Where(p => p.City == id).OrderBy(p => p.Id).ToList();
+ Line(host, "city-list-header", text.Format("city.list_header", mine.Count));
+ foreach (var p in mine)
+ {
+ var k = c.ProjectKinds.First(x => x.Id == p.Kind);
+ var name = "city-list-project-" + p.Id.ToString(CultureInfo.InvariantCulture);
+ var kind = PlayerText.Capitalised(ContentNames.Of(text, k));
+ var cost = PlayerText.Money(c, "treasury", k.Cost);
+ if (p.BuiltOn is DateTime built) { Line(host, name, text.Format("city.list_built", kind, Date(text, built), cost)); continue; }
+ var row = Row(host, name + "-row");
+ Line(row, name, text.Format("city.list_building", kind, k.Turns - p.TurnsLeft, k.Turns, cost, text[p.Builder ? "city.list_builder" : "city.list_no_builder"]));
+ var cancelled = bridge.QueuedLike(new CancelProject(p.Id)) != null;
+ OrderButton(row, bridge, name + "-cancel", text[cancelled ? "city.cancel_ordered" : "city.cancel"],
+ !cancelled, () => bridge.Queue(new CancelProject(p.Id)));
+ }
+ }
+
+ /// <summary>Whether the city's block lists its projects (ProjectList): gdd-0.3, and the city has one.</summary>
+ static bool Listed(Content c, GameState s, string city) => c.Ruleset == SaveGame.Gdd03Ruleset && s.CityProjects.Values.Any(p => p.City == city);
+
/// <summary>A pioneer group's Return (R-QUAL-003; #1511): the sim's unit order return_civilian, offered where
/// Qualification.CheckReturn takes the group (not one at work). It sits beside the places that list the group; the
/// pioneer card (#1549) offers the same order through <see cref="PioneerReturnOrder"/>. A unit order, it takes
@@ -537,13 +590,14 @@ namespace Statecraft.Game.UI
/// (Simulation.Preview, as Train does) whether n + 1 in the order's slot would be refused, or would make it refuse an
/// order of the queue it accepts now, so the queue's job, training, workshop, start and builder orders all count
/// whichever runs first. While a project is left without one, that refusal shows in the UI's language. A repair's line
- /// is <paramref name="line"/>; <paramref name="stepper"/> off leaves the stepper to another project of the hex (Repairs).</summary>
- static void BuilderPart(VisualElement host, SimBridge bridge, UiText text, CityProject project, string line = "city-project-builder", bool stepper = true)
+ /// is <paramref name="line"/>, and none when it is null (its row in the city's list says it, Repairs); <paramref name="stepper"/>
+ /// off leaves the stepper to another project of the hex (Repairs).</summary>
+ static void BuilderPart(VisualElement host, SimBridge bridge, UiText text, CityProject project, string? line = "city-project-builder", bool stepper = true)
{
var c = bridge.Content; var s = bridge.State;
if (c.Ruleset != SaveGame.Gdd03Ruleset) return;
var city = project.City;
- Line(host, line, text[project.Builder ? "city.project_builder" : "city.project_no_builder"]);
+ if (line != null) Line(host, line, text[project.Builder ? "city.project_builder" : "city.project_no_builder"]);
if (!stepper) return;
var building = s.CityProjects.Values.Count(p => p.City == city && p.BuiltOn == null);
var builders = Projects.Builders(s, city);
@@ -579,7 +633,9 @@ namespace Statecraft.Game.UI
/// (Projects.CityProjectAt skips it), so it shows on its city's own hex, where it is offered: its line and whether it
/// has a builder. Its city's builder stepper shows once on the hex: under the hex's own project being built when that
/// is the same city's, else under the city's first repair, so a city whose only project being built is a repair has
- /// one too.</summary>
+ /// one too. Where the repair's city has its block on this hex and so its project list (ProjectList, #1722), the list's
+ /// row is the repair's line and its builder, so only the stepper shows here (owner, 8 November 2026: "Drop the old lines
+ /// here (Recommended)": each repair shows once).</summary>
static void Repairs(VisualElement host, SimBridge bridge, UiText text, int q, int r, Func<string, string> townName)
{
var c = bridge.Content; var s = bridge.State;
@@ -587,6 +643,11 @@ namespace Statecraft.Game.UI
if (Projects.CityProjectAt(s, q, r) is CityProject { BuiltOn: null } here) stepped.Add(here.City);
foreach (var repair in s.CityProjects.Values.Where(p => p.Kind == Projects.HousingRepair && p.Q == q && p.R == r && p.BuiltOn == null).OrderBy(p => p.Id))
{
+ if (Listed(c, s, repair.City) && c.SettlementHexes.Any(x => x.Id == repair.City && x.Q == q && x.R == r))
+ {
+ BuilderPart(host, bridge, text, repair, null, stepped.Add(repair.City));
+ continue;
+ }
var kind = PlayerText.Capitalised(ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == repair.Kind)));
Line(host, "city-repair-state", text.Format("city.project_building", kind, townName(repair.City),
Turns(text, Projects.CityTurnsToBuild(c, s, repair.Kind, repair.TurnsLeft, repair.Progress))));
diff --git a/unity/Assets/Tests/EditMode/CityPanelShots.cs b/unity/Assets/Tests/EditMode/CityPanelShots.cs
new file mode 100644
index 000000000..ddcb135c1
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/CityPanelShots.cs
@@ -0,0 +1,255 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.Globalization;
+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 UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>Writes the before and after stills for #1722 (the gdd-0.3 city panel's project list and housing readout), in
+/// English and Hebrew, at 1024x768 and 1366x768, to `.superpowers/shots-1722/&lt;SHOTS_TAG&gt;/` at the repository root (local,
+/// not committed): Assets/Map.unity with its UI drawn through a copy of its PanelSettings into a transparent texture laid over
+/// the main camera's frame, as PanelPreviewShots does. Each game is a golden-seed Historical one on fresh inputs, and every
+/// state is a fixture (TEST-ONLY SYNTHETIC values), set before the root draws the game; the info panel then shows Haifa's
+/// own hex. The gdd-0.3 games are the real content loaded under gdd-0.3 (WorkshopPanelTests.Load03), so the loader keeps
+/// that ruleset's project kinds (housing_repair, content/projects.yaml). Each still asserts the panel lines it is meant to
+/// show (after writing it, so the run fails instead of passing silently on a wrong still).
+///
+/// Shots (`{lang}` is `en` or `he`, `{w}x{h}` the window), each once at the top of the info panel and once scrolled to its
+/// last line (`-end`):
+/// - `projects-{lang}-{w}x{h}`: gdd-0.3, Haifa with no homes for its 10 people and a housing condition of 22% (a surcharge,
+/// the overflow and the cohesion loss), a housing project being built on its own hex with a builder (2 turns left), a
+/// housing repair being built with none, and an industry project built on another hex.
+/// - `housed-{lang}-{w}x{h}`: gdd-0.3, Haifa well housed (100000 homes at a condition of 60%, above the 50% surcharge
+/// threshold), with no project: "Housing surcharge now: none", no overflow or cohesion line.
+/// - `gdd01-{lang}-{w}x{h}`: the shipped gdd-0.1 rules with the first state's housing project, which #1722 leaves unchanged.
+///
+/// Run (Unity closed on the project; the same file, unchanged, on both trees):
+/// AFTER, on the PR head: SHOTS_TAG=after &lt;Unity&gt; -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter CityPanelShots
+/// BEFORE, with this file and its .meta copied onto main: SHOTS_TAG=before (the same command).
+/// Uses only APIs that exist on main as well. On main the list and readout do not exist, so the gdd-0.3 tests fail there by
+/// design after writing their stills; the gdd-0.1 tests pass on both trees. Explicit, so CI and the gates never run it.</summary>
+[Explicit("writes stills for a pull request, not a check")]
+public class CityPanelShots
+{
+ const string City = "haifa";
+ string saveDir = "", shotDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+ VisualElement ui = null!;
+ GameRoot root = null!;
+
+ [SetUp]
+ public void Prepare()
+ {
+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");
+ shotDir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-1722",
+ string.IsNullOrEmpty(tag) ? "untagged" : tag));
+ Directory.CreateDirectory(shotDir);
+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-city-panel-shots-" + Guid.NewGuid().ToString("N"));
+ }
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ if (ps != null) Object.DestroyImmediate(ps);
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ rt = null; ps = null;
+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
+ }
+
+ static IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }
+ static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);
+
+ /// <summary>Boots the scene at <paramref name="w"/> by <paramref name="h"/> on a golden-seed game of fresh inputs (under
+ /// gdd-0.3 when <paramref name="gdd03"/>), shaped by <paramref name="shape"/> before the root draws it, and shows Haifa's
+ /// own hex in the info panel.</summary>
+ IEnumerator Boot(bool hebrew, bool gdd03, int w, int h, Action<Content, GameState> shape)
+ {
+ var inputs = Statecraft.Game.Boot.GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);
+ // The ruleset at load time: set after the load, the loader would already have dropped gdd-0.3's kinds (housing_repair).
+ if (gdd03) inputs.Content = WorkshopPanelTests.Load03();
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ ShotCamera.Configure(Camera.main, w, h);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ if (ps != null) Object.DestroyImmediate(ps);
+ rt = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.clear;
+ doc.panelSettings = ps;
+ Object.FindFirstObjectByType<MapScene>().Build(inputs.Map);
+ root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ if (hebrew) root.Language = UiLanguage.Hebrew;
+ var g = GameSession.New(inputs.Content, GoldenRun.Seed, Mode.Historical);
+ g.State.PendingEvents.Clear(); // no event card over the panel
+ shape(inputs.Content, g.State);
+ root.Begin(inputs, 0, keep: new SimBridge(g, Text(hebrew)));
+ ui = doc.rootVisualElement;
+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;
+ yield return Frames(5);
+ var hide = ui.Q<Button>("event-hide");
+ if (hide != null && hide.resolvedStyle.display != DisplayStyle.None && hide.enabledInHierarchy) UiTestKit.Press(hide);
+ root.Card?.Collapse(takeFocus: false);
+ if (root.Advisor != null && root.Advisor.IsOpen) UiTestKit.Press(ui.Q<Button>("advisor-close"));
+ Assert.AreEqual(gdd03 ? SaveGame.Gdd03Ruleset : root.Bridge!.Content.Ruleset, root.Bridge!.Content.Ruleset);
+ var home = inputs.Content.SettlementHexes.Single(x => x.Id == City);
+ ShotCamera.Configure(Camera.main, w, h);
+ root.Info!.Show(home.Q, home.R);
+ yield return Frames(8);
+ }
+
+ /// <summary>The first state: no homes at 22%, a housing project on Haifa's own hex with a builder, a repair with none and a
+ /// built industry project on another hex Haifa reaches (gdd-0.1 has no repair kind: only the projects its content has).</summary>
+ static void Projects3(Content c, GameState s)
+ {
+ var x = s.Cities[City];
+ s.Cities[City] = new City(x.Id, 0, x.JobSlots, 10, x.Employed, x.Refugees, x.Recruits, x.Condition is double ? 0.22 : x.Condition, x.Craftsmen, x.JobsDefault, x.Qualified);
+ var home = c.SettlementHexes.Single(h => h.Id == City);
+ var id = s.NextId++;
+ s.CityProjects.Add(id, new CityProject(id, "housing", City, home.Q, home.R, 2).WithBuilder(c.Ruleset == SaveGame.Gdd03Ruleset));
+ if (c.ProjectKinds.Any(k => k.Id == Projects.HousingRepair))
+ {
+ id = s.NextId++;
+ s.CityProjects.Add(id, new CityProject(id, Projects.HousingRepair, City, home.Q, home.R, 1));
+ }
+ var other = c.Hexes.Where(h => h.Land && (h.Q, h.R) != (home.Q, home.R) && Projects.CitiesFor(c, s, h.Q, h.R).Contains(City)).OrderBy(h => h.Q).ThenBy(h => h.R).First();
+ id = s.NextId++;
+ s.CityProjects.Add(id, new CityProject(id, "industry", City, other.Q, other.R, 0).Built(s.Date));
+ }
+
+ /// <summary>The well-housed state (as WorkshopPanelTests.AWellHousedCityHasNoSurchargeAndGdd01HasNoReadout_RHouse005):
+ /// Haifa in 100000 homes at a housing condition of 0.60, above the surcharge threshold; its other counts as they are.</summary>
+ static void Well(Content c, GameState s)
+ {
+ var x = s.Cities[City];
+ s.Cities[City] = new City(x.Id, 100000, x.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits, 0.60, x.Craftsmen, x.JobsDefault, x.Qualified);
+ }
+
+ /// <summary>The projects still's lines: the list header, a row per project of Haifa's, Cancel on the two being built and
+ /// none on the built one, and the three housing terms.</summary>
+ void ProjectLines()
+ {
+ var s = root.Bridge!.State;
+ var mine = s.CityProjects.Values.Where(p => p.City == City).OrderBy(p => p.Id).ToList();
+ Assert.AreEqual(3, mine.Count, "precondition: the housing project, the repair and the built industry project");
+ Assert.IsTrue(mine.Any(p => p.Kind == Projects.HousingRepair), "precondition: the repair, a gdd-0.3 kind at load time");
+ Assert.AreEqual(2, mine.Count(p => p.BuiltOn == null), "precondition: two projects being built");
+ Assert.IsNotNull(ui.Q("city-list-header"), "the list header");
+ foreach (var p in mine)
+ {
+ var name = "city-list-project-" + p.Id.ToString(CultureInfo.InvariantCulture);
+ Assert.IsNotNull(ui.Q(name), $"the row of project {p.Id} ({p.Kind})");
+ if (p.BuiltOn is DateTime) Assert.IsNull(ui.Q(name + "-cancel"), $"no Cancel on the built project {p.Id} ({p.Kind})");
+ else Assert.IsNotNull(ui.Q<Button>(name + "-cancel"), $"Cancel on project {p.Id} ({p.Kind}), being built");
+ }
+ Assert.IsNotNull(ui.Q("city-housing"), "the housing line");
+ Assert.IsNotNull(ui.Q("city-surcharge"), "the surcharge line");
+ Assert.IsNotNull(ui.Q("city-housing-falls"), "the overflow line");
+ Assert.IsNotNull(ui.Q("city-housing-cohesion"), "the cohesion line");
+ }
+
+ /// <summary>The housed still's lines: "no surcharge", no overflow or cohesion line, and no list (no project).</summary>
+ void HousedLines()
+ {
+ var s = root.Bridge!.State;
+ Assert.IsFalse(s.CityProjects.Values.Any(p => p.City == City), "precondition: Haifa has no project");
+ Assert.IsNotNull(ui.Q("city-housing"), "the housing line");
+ Assert.IsNotNull(ui.Q("city-surcharge"), "the no-surcharge line");
+ Assert.IsNull(ui.Q("city-housing-falls"), "no overflow line");
+ Assert.IsNull(ui.Q("city-housing-cohesion"), "no cohesion line");
+ Assert.IsNull(ui.Q("city-list-header"), "no list");
+ }
+
+ /// <summary>The gdd-0.1 still's lines: the city's block, with no list and no housing readout, as on main.</summary>
+ void Gdd01Lines()
+ {
+ Assert.IsNotNull(ui.Q("city-housing"), "precondition: the city's block shows");
+ Assert.IsNull(ui.Q("city-list-header"), "gdd-0.1 has no list");
+ Assert.IsNull(ui.Q("city-surcharge"), "gdd-0.1 has no surcharge");
+ }
+
+ static Color[] Read(RenderTexture from)
+ {
+ var prev = RenderTexture.active;
+ RenderTexture.active = from;
+ var tex = new Texture2D(from.width, from.height, TextureFormat.RGBA32, false);
+ tex.ReadPixels(new Rect(0, 0, from.width, from.height), 0, 0);
+ tex.Apply();
+ RenderTexture.active = prev;
+ var px = tex.GetPixels();
+ Object.DestroyImmediate(tex);
+ return px;
+ }
+
+ /// <summary>PanelPreviewShots.Shot at this boot's size: the map camera's frame with the UI texture over it (the UI's
+ /// pixels are premultiplied by their alpha).</summary>
+ void Shot(string name)
+ {
+ int w = rt!.width, h = rt.height;
+ var cam = Camera.main;
+ ShotCamera.Require(cam, w, h);
+ var frame = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
+ var before = cam.targetTexture;
+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;
+ var map = Read(frame); var over = Read(rt);
+ frame.Release(); Object.DestroyImmediate(frame);
+ var outPx = new Color[map.Length];
+ for (int i = 0; i < map.Length; i++)
+ {
+ var u = over[i]; var m = map[i];
+ outPx[i] = new Color(u.r + m.r * (1f - u.a), u.g + m.g * (1f - u.a), u.b + m.b * (1f - u.a), 1f);
+ }
+ var tex = new Texture2D(w, h, TextureFormat.RGB24, false);
+ tex.SetPixels(outPx); tex.Apply();
+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());
+ Object.DestroyImmediate(tex);
+ var labels = ui.Q("info-panel")?.Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.name) && (l.name.StartsWith("city-", StringComparison.Ordinal))).Select(l => l.name) ?? Enumerable.Empty<string>();
+ Debug.Log($"SHOT {name} -> {shotDir}; city labels: {string.Join(", ", labels)}");
+ }
+
+ /// <summary>A shot at the top of the info panel, and one scrolled to its last line.</summary>
+ IEnumerator Both(string name)
+ {
+ var scroll = ui.Q<ScrollView>("info-panel");
+ if (scroll != null) scroll.scrollOffset = Vector2.zero;
+ yield return Frames(3);
+ Shot(name);
+ var last = scroll?.contentContainer.Query<VisualElement>().ToList().LastOrDefault(e => e.resolvedStyle.display != DisplayStyle.None && e.worldBound.height > 0);
+ if (last != null) scroll!.ScrollTo(last);
+ yield return Frames(3);
+ Shot(name + "-end");
+ }
+
+ IEnumerator Run(string state, bool gdd03, Action<Content, GameState> shape, Action check, bool hebrew)
+ {
+ var lang = hebrew ? "he" : "en";
+ Exception? fail = null; // every size is checked; the first failure is thrown after the last size's stills
+ foreach (var (w, h) in new[] { (1024, 768), (1366, 768) })
+ {
+ yield return Boot(hebrew, gdd03, w, h, shape);
+ yield return Both($"{state}-{lang}-{w}x{h}");
+ try { check(); } // after the stills, so a "before" run on main still writes them (its gdd-0.3 checks then fail by design)
+ catch (Exception e) { fail ??= e; }
+ }
+ if (fail != null) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(fail).Throw();
+ }
+
+ [UnityTest] public IEnumerator ProjectsEnglish() { yield return Run("projects", true, Projects3, ProjectLines, false); }
+ [UnityTest] public IEnumerator ProjectsHebrew() { yield return Run("projects", true, Projects3, ProjectLines, true); }
+ [UnityTest] public IEnumerator HousedEnglish() { yield return Run("housed", true, Well, HousedLines, false); }
+ [UnityTest] public IEnumerator HousedHebrew() { yield return Run("housed", true, Well, HousedLines, true); }
+ [UnityTest] public IEnumerator Gdd01English() { yield return Run("gdd01", false, Projects3, Gdd01Lines, false); }
+ [UnityTest] public IEnumerator Gdd01Hebrew() { yield return Run("gdd01", false, Projects3, Gdd01Lines, true); }
+}
diff --git a/unity/Assets/Tests/EditMode/CityPanelShots.cs.meta b/unity/Assets/Tests/EditMode/CityPanelShots.cs.meta
new file mode 100644
index 000000000..4c906dca5
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/CityPanelShots.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: e6de2c2fa3654ba3916ba508f4673fd1
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
index 74a611df5..8a0ee0ff1 100644
--- a/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
+++ b/unity/Assets/Tests/EditMode/CityProjectPanelTests.cs
@@ -1098,7 +1098,8 @@ public class WorkshopPanelTests
}
// R-CITY-011 with R-HOUSE-006 (#2477 review): a housing repair being built has no hex of its own, so it shows on its city's
- // own hex, where it is offered: its line, whether it has a builder, and its city's stepper, also when it is the city's only
+ // own hex, where it is offered: its line and whether it has a builder (since #1722, the city's project list's row: owner,
+ // 8 November 2026, "Drop the old lines here (Recommended)"), and its city's stepper, also when it is the city's only
// project being built. + there queues the build order and End turn gives the repair its builder.
[Test]
public void ARepairBeingBuiltShowsItsBuilderOnItsCitysOwnHex_RCity011([Values] bool hebrew)
@@ -1115,10 +1116,10 @@ public class WorkshopPanelTests
});
using var panel = Panel(ui, bridge, t);
panel.Show(home.Q, home.R);
- var kind = PlayerText.Capitalised(ContentNames.Of(t, C03.ProjectKinds.First(k => k.Id == Projects.HousingRepair)));
- Assert.AreEqual(t.Format("city.project_building", kind, (hebrew ? TownsHe : Towns)[City],
- GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C03, bridge.State, Projects.HousingRepair, 2, 0))), ui.Q<Label>("city-repair-state").text);
- Assert.AreEqual(t["city.project_no_builder"], ui.Q<Label>("city-repair-builder").text);
+ var k = C03.ProjectKinds.First(x => x.Id == Projects.HousingRepair);
+ var kind = PlayerText.Capitalised(ContentNames.Of(t, k));
+ string Row(bool builder) => t.Format("city.list_building", kind, k.Turns - 2, k.Turns, PlayerText.Money(C03, "treasury", k.Cost), t[builder ? "city.list_builder" : "city.list_no_builder"]);
+ Assert.AreEqual(Row(false), ui.Q<Label>($"city-list-project-{repair}").text);
Assert.AreEqual(t.Format("city.builders", 0, 1), ui.Q<Label>("city-builders").text, "the repair is the one project the count counts");
Assert.IsTrue(ui.Q<Button>("city-builders-more").enabledSelf, "4 people without a job, 1 project");
ui.Press("city-builders-more");
@@ -1126,26 +1127,75 @@ public class WorkshopPanelTests
Assert.IsEmpty(turn.Rejected, "the sim accepts the order the panel queued");
Assert.IsTrue(turn.State.CityProjects[repair].Builder);
panel.Show(home.Q, home.R);
- Assert.AreEqual(t["city.project_builder"], ui.Q<Label>("city-repair-builder").text);
+ var left = turn.State.CityProjects[repair].TurnsLeft;
+ Assert.AreEqual(t.Format("city.list_building", kind, k.Turns - left, k.Turns, PlayerText.Money(C03, "treasury", k.Cost), t["city.list_builder"]),
+ ui.Q<Label>($"city-list-project-{repair}").text);
+ }
+
+ // R-HOUSE-006 with #1722 (owner, 8 November 2026: "Drop the old lines here (Recommended)", on the repair that showed
+ // twice): on its city's own hex a repair being built shows once, as its row in the city's project list. The old repair
+ // line and its builder line (the projects part's Repairs) are gone there; the city's one builder stepper stays. On a hex
+ // that is not a city's, a project being built keeps its state line, its builder line and the stepper, as before.
+ [Test]
+ public void ARepairBeingBuiltShowsOnceOnItsCitysOwnHex_RHouse006([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (hq, hr) = Home(C03);
+ var repair = 0;
+ using var ui = new UiTestKit();
+ var (bridge, project) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ repair = s.NextId++;
+ s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, hq, hr, 1));
+ });
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(hq, hr);
+ var k = C03.ProjectKinds.First(x => x.Id == Projects.HousingRepair);
+ var kind = PlayerText.Capitalised(ContentNames.Of(t, k));
+ var oldLine = t.Format("city.project_building", kind, (hebrew ? TownsHe : Towns)[City],
+ GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C03, bridge.State, Projects.HousingRepair, 1, 0)));
+ var row = t.Format("city.list_building", kind, k.Turns - 1, k.Turns, PlayerText.Money(C03, "treasury", k.Cost), t["city.list_no_builder"]);
+ var labels = ui.Root.Query<Label>().ToList();
+ Assert.AreEqual(1, labels.Count(l => string.Equals(l.text, row, StringComparison.Ordinal)), "the list's row, once");
+ Assert.AreEqual(0, labels.Count(l => string.Equals(l.text, oldLine, StringComparison.Ordinal)), "no old repair line");
+ Assert.IsNull(ui.Root.Q("city-repair-state"));
+ Assert.IsNull(ui.Root.Q("city-repair-builder"));
+ Assert.AreEqual(1, ui.Root.Query("city-builders-row").ToList().Count, "the city's builder stepper stays, once");
+ Assert.AreEqual(t.Format("city.builders", 0, 2), ui.Q<Label>("city-builders").text);
+
+ // Not a city's hex: the housing project being built there shows as it did (city-project-state, its builder line, the stepper).
+ var (q, r) = Hex(C03);
+ panel.Show(q, r);
+ var housing = C03.ProjectKinds.First(x => x.Id == "housing");
+ Assert.AreEqual(t.Format("city.project_building", PlayerText.Capitalised(ContentNames.Of(t, housing)), (hebrew ? TownsHe : Towns)[City],
+ GddHexPanel.Turns(t, Projects.CityTurnsToBuild(C03, bridge.State, "housing", 2, 0))), ui.Q<Label>("city-project-state").text);
+ Assert.AreEqual(t["city.project_no_builder"], ui.Q<Label>("city-project-builder").text);
+ Assert.AreEqual(1, ui.Root.Query("city-builders-row").ToList().Count);
+ Assert.IsNull(ui.Root.Q("city-list-header"), "no city block, so no list, on a hex that is not a city's");
+ Assert.IsNull(ui.Root.Q("city-repair-state"));
+ Assert.AreEqual(project, Projects.CityProjectAt(bridge.State, q, r)?.Id, "precondition: the project is this hex's");
}
// R-CITY-011 (#2477 review): a city's own hex with its project being built and a repair being built shows both builder
- // lines and one stepper for the city, whose count is the two projects on screen.
+ // lines and one stepper for the city, whose count is the two projects on screen. Since #1722 the repair's builder is
+ // said in its row of the city's project list (owner, 8 November 2026: "Drop the old lines here (Recommended)").
[Test]
public void ACitysOwnHexWithAProjectAndARepairShowsOneStepper_RCity011()
{
var home = C03.SettlementHexes.First(x => x.Id == City);
+ var repair = 0;
using var ui = new UiTestKit();
var (bridge, _) = Game(C03, En, "housing", turnsLeft: 2, edit: (s, id) =>
{
s.CityProjects[id] = new CityProject(id, "housing", City, home.Q, home.R, 2);
- var repair = s.NextId++;
+ repair = s.NextId++;
s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, home.Q, home.R, 2).WithBuilder(true));
});
using var panel = Panel(ui, bridge, En);
panel.Show(home.Q, home.R);
Assert.AreEqual(En["city.project_no_builder"], ui.Q<Label>("city-project-builder").text);
- Assert.AreEqual(En["city.project_builder"], ui.Q<Label>("city-repair-builder").text);
+ StringAssert.EndsWith(En["city.list_builder"], ui.Q<Label>($"city-list-project-{repair}").text);
+ Assert.IsNull(ui.Root.Q("city-repair-builder"), "the repair's builder is said once, in the list");
Assert.AreEqual(1, ui.Root.Query("city-builders-row").ToList().Count, "one stepper for the city");
Assert.AreEqual(En.Format("city.builders", 1, 2), ui.Q<Label>("city-builders").text);
}
@@ -1180,4 +1230,219 @@ public class WorkshopPanelTests
Assert.AreEqual(SimBridge.ReasonText(t, broken!.Reason, C03, TownsHe), ui.Q<Label>("city-builders-reason").text);
if (hebrew) Assert.AreNotEqual(broken.Reason, ui.Q<Label>("city-builders-reason").text, "the Hebrew string, not the sim's English");
}
+
+ // ---- #1722: the city panel's project list and housing readout, per city, gdd-0.3 only ----
+
+ static (int q, int r) Home(Content c) { var h = c.SettlementHexes.Single(x => x.Id == City); return (h.Q, h.R); }
+
+ /// <summary>Haifa with <paramref name="capacity"/> homes and housing condition <paramref name="condition"/>
+ /// (TEST-ONLY SYNTHETIC values); its other counts are left as they are.</summary>
+ static void Housing(GameState s, int capacity, double condition)
+ {
+ var x = s.Cities[City];
+ s.Cities[City] = new City(x.Id, capacity, x.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits, condition, x.Craftsmen, x.JobsDefault, x.Qualified);
+ }
+
+ // R-HOUSE-005 (#1722: "Housing capacity, residents, condition and this turn's surcharge for the city, with the sim's
+ // reasons"): on the city's own hex the readout is Cities.HousingOutlook's, word for word in the UI's language. Haifa with
+ // its opening 99 residents in 80 homes at 0.15 (TEST-ONLY SYNTHETIC values): a surcharge (below 50%) of IL 3.5m, the
+ // overflow of 19 lowers the condition to 14%, and below 25% Social cohesion falls by 0.2% (Haifa is 99 of 532 own
+ // population). Each figure is large enough to show when rounded as the panel rounds it (#1722 review S2), which the
+ // precondition checks; 10 residents would give a cohesion share under 0.05 points, which has no line.
+ [Test]
+ public void TheHousingReadoutShowsTheSimsSurchargeOverflowAndCohesion_RHouse005([Values] bool hebrew)
+ {
+ const double condition = 0.15;
+ var t = hebrew ? He : En;
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ var x = s.Cities[City];
+ s.Cities[City] = new City(x.Id, x.HousingCapacity, x.JobSlots, 99, x.Employed, x.Refugees, x.Recruits, x.Condition, x.Craftsmen, x.JobsDefault, x.Qualified);
+ Housing(s, 80, condition);
+ });
+ var o = Cities.HousingOutlook(C03, bridge.State, City)!.Value;
+ Assert.IsTrue(o.Surcharge > 0 && o.ConditionAfter < condition && o.CohesionShift < 0, "precondition: all three terms are live");
+ Assert.AreNotEqual(PlayerText.Money(C03, "treasury", 0), PlayerText.Money(C03, "treasury", o.Surcharge), "precondition: the surcharge shows when rounded (S2)");
+ Assert.AreNotEqual(PlayerText.Percent(condition), PlayerText.Percent(o.ConditionAfter), "precondition: the overflow moves the rounded condition (S2)");
+ Assert.AreNotEqual(PlayerText.PercentChange(0), PlayerText.PercentChange(o.CohesionShift), "precondition: the cohesion share shows when rounded (S2)");
+ using var panel = Panel(ui, bridge, t);
+ var (q, r) = Home(C03);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.housing_surcharge", PlayerText.Money(C03, "treasury", o.Surcharge), PlayerText.Percent(o.MoneyThreshold)), ui.Q<Label>("city-surcharge").text);
+ Assert.AreEqual(t.Format("city.housing_falls", PlayerText.Percent(o.ConditionAfter)), ui.Q<Label>("city-housing-falls").text);
+ Assert.AreEqual(t.Format("city.housing_cohesion", PlayerText.PercentChange(o.CohesionShift), PlayerText.Percent(o.CohesionThreshold)), ui.Q<Label>("city-housing-cohesion").text);
+ Assert.AreEqual("50%", PlayerText.Percent(o.MoneyThreshold), "the catalogue's threshold, through the sim's formatter");
+ }
+
+ // R-HOUSE-005: at or above both thresholds in enough homes, the readout says there is no surcharge and shows no
+ // overflow or cohesion line; under gdd-0.1 (no surcharge, no cohesion term) there is no readout at all.
+ [Test]
+ public void AWellHousedCityHasNoSurchargeAndGdd01HasNoReadout_RHouse005([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ foreach (var c in new[] { C03, C01 })
+ {
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(c, t, "housing", turnsLeft: 2, edit: (s, _) => Housing(s, 100000, 0.60));
+ using var panel = Panel(ui, bridge, t);
+ var (q, r) = Home(c);
+ panel.Show(q, r);
+ Assert.IsNotNull(ui.Root.Q("city-housing"), $"{c.Ruleset}: precondition, the city's block shows");
+ if (c == C03) Assert.AreEqual(t.Format("city.housing_no_surcharge", "50%"), ui.Q<Label>("city-surcharge").text);
+ else Assert.IsNull(ui.Root.Q("city-surcharge"), "gdd-0.1 has no surcharge");
+ Assert.IsNull(ui.Root.Q("city-housing-falls"), c.Ruleset);
+ Assert.IsNull(ui.Root.Q("city-housing-cohesion"), c.Ruleset);
+ }
+ }
+
+ // R-HOUSE-005 (#1722 review S2): a housing line shows only when its figure, as the panel rounds it, says something. A
+ // surcharge under IL 0.05m would read "IL 0.0m a turn" (and "none" is not true), an overflow that leaves the rounded
+ // condition where it is would repeat the housing line's percentage, and a cohesion share under 0.05 points would read
+ // "0.0% a turn": none of the three has a line. Each case is shaped from the sim's own readout (TEST-ONLY SYNTHETIC values).
+ [Test]
+ public void AHousingTermTooSmallToShowHasNoLine_RHouse005([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ var (q, r) = Home(C03);
+ Cities.HousingReadout Outlook(GameState s) => Cities.HousingOutlook(C03, s, City)!.Value;
+
+ // A surcharge of IL 0.02m: just under 50%, in enough homes (the surcharge is linear in the points below 50%).
+ using (var ui = new UiTestKit())
+ {
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ Housing(s, 100000, 0.40);
+ Housing(s, 100000, 0.50 - 0.02 * 0.10 / Outlook(s).Surcharge);
+ });
+ var o = Outlook(bridge.State);
+ Assert.IsTrue(o.Surcharge > 0 && PlayerText.Money(C03, "treasury", o.Surcharge) == PlayerText.Money(C03, "treasury", 0), "precondition: a surcharge that rounds to nothing");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.IsNotNull(ui.Root.Q("city-housing"), "precondition: the city's block shows");
+ Assert.IsNull(ui.Root.Q("city-surcharge"), "no \"IL 0.0m a turn\" and no \"none\"");
+ }
+
+ // One person over capacity at 60.4%: the overflow lowers the condition by less than the half point that would move "60%".
+ using (var ui = new UiTestKit())
+ {
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) => Housing(s, Cities.Housed(s, s.Cities[City]) - 1, 0.604));
+ var o = Outlook(bridge.State);
+ Assert.IsTrue(o.ConditionAfter < 0.604 && PlayerText.Percent(o.ConditionAfter) == PlayerText.Percent(0.604), "precondition: an overflow that leaves the rounded condition");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.AreEqual(t.Format("city.housing_no_surcharge", "50%"), ui.Q<Label>("city-surcharge").text, "precondition: the readout shows");
+ Assert.IsNull(ui.Root.Q("city-housing-falls"), "the condition is not said twice");
+ }
+
+ // At 24.99% in enough homes: Social cohesion's share is far under 0.05 points.
+ using (var ui = new UiTestKit())
+ {
+ var (bridge, _) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) => Housing(s, 100000, 0.2499));
+ var o = Outlook(bridge.State);
+ Assert.IsTrue(o.CohesionShift < 0 && PlayerText.PercentChange(o.CohesionShift) == PlayerText.PercentChange(0), "precondition: a cohesion share that rounds to nothing");
+ using var panel = Panel(ui, bridge, t);
+ panel.Show(q, r);
+ Assert.IsNotNull(ui.Root.Q("city-surcharge"), "precondition: the readout shows");
+ Assert.IsNull(ui.Root.Q("city-housing-cohesion"), "no \"0.0% a turn\"");
+ }
+ }
+
+ // R-PROJ-001 to R-PROJ-003, R-CITY-011, R-HOUSE-006 (#1722: "Project list with builders, work done and cost"): the city's
+ // block lists every project of the city in id order, wherever it stands, the repair (no hex of its own) included: a
+ // housing project with 2 of its 6 turns of work left is "work 4 of 6", cost IL 6.0m (content/projects.yaml), no builder; a
+ // repair with its builder; a built industry project with the day it was finished. Only the projects being built have Cancel.
+ [Test]
+ public void TheCityListsEveryProjectWithWorkDoneCostAndBuilder_RProj003([Values] bool hebrew)
+ {
+ var t = hebrew ? He : En;
+ using var ui = new UiTestKit();
+ int repair = 0, industry = 0;
+ var (bridge, housing) = Game(C03, t, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ var (hq, hr) = Home(C03);
+ repair = s.NextId++;
+ s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, hq, hr, 1, builder: true));
+ industry = SecondWorkshop(C03, s);
+ var w = s.CityProjects[industry];
+ s.CityProjects[industry] = new CityProject(w.Id, "industry", City, w.Q, w.R, 0).Built(s.Date);
+ });
+ using var panel = Panel(ui, bridge, t);
+ var (q, r) = Home(C03);
+ panel.Show(q, r);
+ string Kind(string id) => PlayerText.Capitalised(ContentNames.Of(t, C03.ProjectKinds.First(x => x.Id == id)));
+ Assert.AreEqual(t.Format("city.list_header", 3), ui.Q<Label>("city-list-header").text);
+ Assert.AreEqual(t.Format("city.list_building", Kind("housing"), 4, 6, PlayerText.Money(C03, "treasury", 6), t["city.list_no_builder"]),
+ ui.Q<Label>($"city-list-project-{housing}").text);
+ Assert.AreEqual(t.Format("city.list_building", Kind(Projects.HousingRepair), 0, 1, PlayerText.Money(C03, "treasury", 0.5), t["city.list_builder"]),
+ ui.Q<Label>($"city-list-project-{repair}").text);
+ var date = t.Format("date.day_month_year", bridge.State.Date.Day, t["date.month_" + bridge.State.Date.Month], bridge.State.Date.Year);
+ Assert.AreEqual(t.Format("city.list_built", Kind("industry"), date, PlayerText.Money(C03, "treasury", 2)), ui.Q<Label>($"city-list-project-{industry}").text);
+ var names = ui.Root.Q("city-part-" + City).Query<Label>().ToList().Select(l => l.name).Where(n => n.StartsWith("city-list-project-", StringComparison.Ordinal)).ToList();
+ CollectionAssert.AreEqual(new[] { housing, repair, industry }.OrderBy(x => x).Select(x => $"city-list-project-{x}"), names, "id order");
+ Assert.IsNotNull(ui.Root.Q<Button>($"city-list-project-{housing}-cancel"));
+ Assert.IsNotNull(ui.Root.Q<Button>($"city-list-project-{repair}-cancel"));
+ Assert.IsNull(ui.Root.Q($"city-list-project-{industry}-cancel"), "a built project cannot be cancelled (R-PROJ-002)");
+ }
+
+ // R-PROJ-002: the list's Cancel queues CancelProject for that project (a repair too, which has no Cancel elsewhere), reads
+ // "Cancel ordered" and is off once queued; the sim accepts it at End turn: the project is gone and the Money is not returned.
+ [Test]
+ public void TheListsCancelQueuesTheSimsCancelProject_RProj002()
+ {
+ using var ui = new UiTestKit();
+ int repair = 0;
+ var (bridge, _) = Game(C03, En, "housing", turnsLeft: 2, edit: (s, _) =>
+ {
+ var (hq, hr) = Home(C03);
+ repair = s.NextId++;
+ s.CityProjects.Add(repair, new CityProject(repair, Projects.HousingRepair, City, hq, hr, 1));
+ });
+ using var panel = Panel(ui, bridge, En);
+ var (q, r) = Home(C03);
+ panel.Show(q, r);
+ ui.Press($"city-list-project-{repair}-cancel");
+ Assert.AreEqual(repair, bridge.Queued.OfType<CancelProject>().Single().Project);
+ var button = ui.Q<Button>($"city-list-project-{repair}-cancel");
+ Assert.AreEqual(En["city.cancel_ordered"], button.text);
+ Assert.IsFalse(button.enabledSelf);
+ var end = bridge.EndTurn();
+ Assert.IsEmpty(end.Rejected);
+ Assert.IsFalse(end.State.CityProjects.ContainsKey(repair), "the sim cancelled the repair");
+ }
+
+ // R-PROJ-001: no list without projects, and none under gdd-0.1, whose city panel is unchanged by #1722.
+ [Test]
+ public void NoListWithoutProjectsOrUnderGdd01()
+ {
+ foreach (var (c, projects) in new[] { (C03, false), (C01, true) })
+ {
+ using var ui = new UiTestKit();
+ var (bridge, _) = Game(c, En, "housing", turnsLeft: 2, edit: (s, id) => { if (!projects) s.CityProjects.Remove(id); });
+ using var panel = Panel(ui, bridge, En);
+ var (q, r) = Home(c);
+ panel.Show(q, r);
+ Assert.IsNotNull(ui.Root.Q("city-housing"), $"{c.Ruleset}: precondition, the city's block shows");
+ Assert.IsNull(ui.Root.Q("city-list-header"), c.Ruleset);
+ }
+ }
+
+ // #1722: the housing readout prices nothing itself. The surcharge, overflow and cohesion arithmetic and the catalogue's
+ // thresholds stay in the sim (Cities.HousingOutlook over Gdd03HousingFormula), so what the panel shows and what the turn
+ // charges cannot differ. Every UI script is scanned, comments stripped first.
+ [Test]
+ public void TheCityPanelHoldsNoHousingRule_RHouse005()
+ {
+ var files = Directory.GetFiles(Path.Combine(Application.dataPath, "Scripts/UI"), "*.cs", SearchOption.AllDirectories);
+ var panel = files.SingleOrDefault(f => Path.GetFileName(f) == "GddHexPanel.cs");
+ Assert.IsNotNull(panel, "not vacuous: the scan reads the city panel's source");
+ foreach (var file in files)
+ {
+ var code = System.Text.RegularExpressions.Regex.Replace(File.ReadAllText(file), @"//[^\n]*|/\*.*?\*/", "",
+ System.Text.RegularExpressions.RegexOptions.Singleline);
+ if (file == panel) StringAssert.Contains("Cities.HousingOutlook", code, "not vacuous: the panel reads the sim's readout");
+ foreach (var rule in new[] { "Gdd03HousingFormula", "money_threshold", "money_slope", "cohesion_threshold", "overflow_deterioration", "max_cohesion_loss" })
+ Assert.AreEqual(-1, code.IndexOf(rule, StringComparison.Ordinal), $"{Path.GetFileName(file)} reads the housing rules ({rule}) itself");
+ }
+ }
}
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index 35525162e..41c63105c 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -274,10 +274,12 @@ public class InfoPanelLayoutTests
}
/// <summary>R-CITY-011 (#2477 review): a housing repair being built shows on its city's own hex, outside the folded
- /// project list (GddHexPanel.Repairs), with its line, its builder line and the city's stepper. Under gdd-0.3, at every
+ /// project list (GddHexPanel.Repairs), with the city's stepper; since #1722 its line and its builder are its row in the
+ /// city's project list (owner, 8 November 2026: "Drop the old lines here (Recommended)"). Under gdd-0.3, at every
/// window size (the stacked bars and the short windows included) in English and Hebrew, the panel lies in the window, clear
/// of the minimap, the left column and the top bar, and every shown label lies inside the panel (or the panel scrolls to
- /// it) with its text fitting its box, as TheGddCityAndSitePanelsFitEveryWindow asks of the city's own hex.</summary>
+ /// it) with its text fitting its box, as TheGddCityAndSitePanelsFitEveryWindow asks of the city's own hex. #1722: with the
+ /// city's housing readout and its project list (the repair's row and its Cancel) in the city's block.</summary>
[UnityTest]
public IEnumerator ACityHexWithARepairBeingBuiltFitsEveryWindow_RCity011([Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices
{
@@ -295,7 +297,8 @@ public class InfoPanelLayoutTests
yield return Rendered(w, h, g, (root, info) => info.Show(city.Q, city.R), root =>
{
var panel = root.Q("info-panel"); var window = root.worldBound;
- foreach (var name in new[] { "city-repair-state", "city-repair-builder", "city-builders" })
+ // #1722: the city's housing readout and its project list (the repair, with its Cancel) on the same block.
+ foreach (var name in new[] { "city-builders", "city-surcharge", "city-list-header", $"city-list-project-{id}", $"city-list-project-{id}-cancel" })
if (root.Q(name) is not { } e || !Shown(e)) { problems.Add($"{at}: precondition: {name} shows"); return; }
if (!Inside(panel.worldBound, window)) problems.Add($"{at}: the panel {panel.worldBound} leaves the window {window}");
foreach (var other in new[] { "minimap", "left-column", "top-bar" })
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 5995be4c5..e0f9b634f 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -909,6 +909,21 @@ city.project_builder: "This project: has a builder"
city.project_no_builder: "This project: no builder, waiting"
city.builders: "Projects with a builder: {0} of {1}"
city.builders_ordered: "Projects with a builder at End turn: {0} of {1}"
+# #1722 (R-HOUSE-005), gdd-0.3 only: the city's housing readout, the sim's Cities.HousingOutlook on the state as it is
+# now: {0} the surcharge a turn (Money) or the condition after the overflow or Social cohesion's change a turn; {1} the
+# threshold the term starts below (a percent).
+city.housing_surcharge: "Housing surcharge now: {0} a turn (condition below {1})"
+city.housing_no_surcharge: "Housing surcharge now: none (condition {0} or more)"
+city.housing_falls: "Overflow now lowers the condition to {0}"
+city.housing_cohesion: "Social cohesion now: {0} a turn (condition below {1})"
+# #1722 (R-PROJ-001 to R-PROJ-003, R-CITY-011), gdd-0.3 only: the city's own list of its projects. {0} the kind, then for
+# one being built {1} its turns of work done, {2} the kind's turns, {3} the cost paid at its start, {4} city.list_builder or
+# city.list_no_builder; for a built one {1} the day it was finished, {2} the cost.
+city.list_header: "This city's projects: {0}"
+city.list_building: "{0}: work {1} of {2} · cost {3} · {4}"
+city.list_built: "{0}: finished on {1} · cost {2}"
+city.list_builder: "has a builder"
+city.list_no_builder: "no builder, waiting"
builder.refused_being_built_one: "{0} has 1 city project being built"
builder.refused_being_built: "{0} has {1} city projects being built"
site.available: "A designated site for a new yishuv"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 72606ffa4..49fe134ae 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -1087,6 +1087,19 @@ city.project_builder: "המיזם הזה: יש בונה"
city.project_no_builder: "המיזם הזה: אין בונה, בהמתנה"
city.builders: "מיזמים בבנייה עם בונה: {0} מתוך {1}"
city.builders_ordered: "מיזמים בבנייה עם בונה בסיום התור: {0} מתוך {1}"
+# #1722 (R-HOUSE-005), gdd-0.3 only: the city's housing readout, as in strings.en.yaml. The surcharge's word "היטל דיור"
+# is the owner's choice (2 Nov 2026: "היטל דיור (Recommended)"), as in why.cause.housing_surcharge. Agent-drafted Hebrew, for the native reviewer (#564).
+city.housing_surcharge: "היטל דיור כעת: {0} בכל תור (מצב הדיור מתחת ל־{1})"
+city.housing_no_surcharge: "היטל דיור כעת: אין (מצב הדיור {0} ומעלה)"
+city.housing_falls: "החריגה מהדיור מורידה כעת את מצב הדיור ל־{0}"
+city.housing_cohesion: "לכידות חברתית כעת: {0} בכל תור (מצב הדיור מתחת ל־{1})"
+# #1722 (R-PROJ-001 to R-PROJ-003, R-CITY-011), gdd-0.3 only: the city's own list of its projects, as in strings.en.yaml.
+# Counts as "Label: N" (HE-04). Agent-drafted Hebrew, for the native reviewer (#564).
+city.list_header: "המיזמים של העיר: {0}"
+city.list_building: "{0}: עבודה {1} מתוך {2} · עלות: {3} · {4}"
+city.list_built: "{0}: הבנייה הושלמה ב־{1} · עלות: {2}"
+city.list_builder: "יש בונה"
+city.list_no_builder: "אין בונה, בהמתנה"
builder.refused_being_built_one: "{0}: יש רק מיזם עירוני אחד בבנייה"
builder.refused_being_built: "{0}: מיזמים עירוניים בבנייה: {1}"
# Agent-drafted Hebrew; native review pending (#564).