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.

Content: the loader holds cities.yaml to the settlement file's city and town rows, in order (Fixes #2732) (#2738)

Berid6c01ed412c3
diff --git a/changelog.d/2732-cities-order.md b/changelog.d/2732-cities-order.md
new file mode 100644
index 000000000..7c8ae1dfd
--- /dev/null
+++ b/changelog.d/2732-cities-order.md
@@ -0,0 +1,4 @@
+### Fixed
+- The content loader now refuses a `cities.yaml` that is not exactly the `city` and `town` rows of
+ `map/settlements_1948.yaml`, in that file's order (R-CITY-006, Fixes #2732). It names the missing city, the city out of
+ place, or the row that is not a city or town. The shipped twelve cities already match, so the game is unchanged.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 5639a72f7..9f51c9726 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -120,7 +120,7 @@ R-CITY-010: A city the enemy holds pauses (decision D6, owner, 1 November 2026,
R-CITY-005: The cities' employed share (employed over civilians and craftsmen, summed over all cities; 1 with none) is an effect-web source of `morale`, Social cohesion (`work_lifts_cohesion`, source id `employed_share`), read after the turn's housing. The legacy loop has no cities, so there it reads 0 and adds nothing. Housing reaches Social cohesion through the existing `housing` link (`homes_lift_morale`) until Phase 3 makes it the cities' aggregate (Q-NAT-2, decided 15 October 2026). Phase 1's separate cohesion value and its two weights are gone (D-C1, Reading 2).
-R-CITY-006: The cities are the `city` and `town` rows of `map/settlements_1948.yaml`, in that file's order, and their start values are `cities.yaml`'s. Each of a city's values (`people`, `employed_share`, `housing_capacity`, `job_slots`) is required and has a status: `sourced` (read from the source named), `derived` (computed from sourced values), `wikipedia-only` (an owner-accepted Wikipedia figure) or `design` (a labelled design value, R-LOOP-005). A `sourced`, `derived` or `wikipedia-only` value has at least one source, each with a url and a checked date, and the day (YYYY-MM-DD) or month (YYYY-MM) it describes; the loader refuses a value without them, naming the file and field (GDD Phase 3 plan, review focus 3).
+R-CITY-006: The cities are the `city` and `town` rows of `map/settlements_1948.yaml`, in that file's order, and their start values are `cities.yaml`'s. The loader refuses a `cities.yaml` whose ids are not exactly those rows in that order (#2732). Each of a city's values (`people`, `employed_share`, `housing_capacity`, `job_slots`) is required and has a status: `sourced` (read from the source named), `derived` (computed from sourced values), `wikipedia-only` (an owner-accepted Wikipedia figure) or `design` (a labelled design value, R-LOOP-005). A `sourced`, `derived` or `wikipedia-only` value has at least one source, each with a url and a checked date, and the day (YYYY-MM-DD) or month (YYYY-MM) it describes; the loader refuses a value without them, naming the file and field (GDD Phase 3 plan, review focus 3).
The regional foundation under exact `gdd-0.3` identity reads optional `regions.yaml` (`schema/regions.schema.json`), separate from aliyah origins. Each explicit region has a stable id, one label place (`capital_location`), land member hexes and member place ids. A member place is a settlement, a named map location, a designated site (`sites.yaml`) or a locality, whose hex is `map/locality_hexes.yaml`'s (written by `tools/locality_hexes.py` from `map/localities_1948.yaml` and `map/region_places_1948.yaml`; read only under exact `gdd-0.3` and only with `regions.yaml`, so no older identity reads or hashes it). Owner, 2 November 2026: Q1 "Accept localities", and "Fix all, then ship (Recommended)", whose option read "Accept site ids too; author records for the 4 (sourced); for the 14, the member's hex joins its region where it's unclaimed, and where another region holds the hex the member moves to that region. All listed for Amir to review." The label place must be a member; it is a label only (Q3, owner, 2 November 2026: "All nine drafts as labels"), not the regional-capital model the owner declined on 30 October 2026 ([GDD](../GDD.md), "Regional-capital model"), and nothing gives it capital mechanics. All nine shipped labels are `APPROVED` as labels (owner, 2 November 2026: "Approve all nine as labels (Recommended)"); that changes no rule. A region may list optional `field_hexes`, the opening field hexes (#1691 Q4, owner, 2 November 2026: "Approve as drafted (Recommended)", the 20 by the 27 October 2026 split): each must be a land hex of the region's own member hexes, listed once; a hex is in at most one region, so no field hex is in two. They are data only: no rule reads them yet, and the four checks of the shipped list (land, a coastal plain, lowland or valley biome, Israeli-held on 15 May 1948 in `map/control_hexes_1948_49.yaml`, in its region) are in `tools/tests/test_region_field_hexes.py`; a person's check of each row is pending. Validation uses effective placements after overrides; a place id with different hexes in two place files, repeated members and overlapping ownership are errors. Different place ids may share one hex within a region. No contiguity or complete-map coverage is required: a land hex may be in no region. Unknown opening control stays null and never grants access. Geography approval is separate from evidence status and human historical review. The shipped file has the nine regions of #1691; no new game initializes them yet (#1689).
diff --git a/sim/Statecraft.Sim.Tests/CaptureTests.cs b/sim/Statecraft.Sim.Tests/CaptureTests.cs
index 2fe2dafea..0d3c8201b 100644
--- a/sim/Statecraft.Sim.Tests/CaptureTests.cs
+++ b/sim/Statecraft.Sim.Tests/CaptureTests.cs
@@ -9,7 +9,8 @@ using Statecraft.Sim;
/// halutz holds nothing, "enemy-held" means mvp.enemy_held_localities, and enemy units alone on an awaiting_choice target
/// take it back. The fixture's places are fixture values, not
/// history: town_a and town_c are arab_town targets the fixture lists as enemy-held, town_d an arab_town target that is
-/// not, and town_e an enemy-held arab_town that is not a target.</summary>
+/// not, and town_e an enemy-held arab_town that is not a target. town_h, a town on (0, 2), is the fixture's one city: the loader
+/// holds cities.yaml to the city and town rows (R-CITY-006).</summary>
public class CaptureTests
{
const string Types = Fixture.GddUnitTypes
@@ -48,9 +49,11 @@ public class CaptureTests
var files = Fixture.Gdd(new Dictionary<string, string>
{
["unit_types.yaml"] = Types, ["map/hexes.json"] = MovementTests.Board(), ["corridors.yaml"] = "corridors: []\n",
- ["map/settlement_hexes.yaml"] = "settlements:\n" + string.Concat(Places.Select(p => FormattableString.Invariant($" - {{ id: {p.Id}, q: {p.Q}, r: {p.R} }}\n"))),
+ ["map/settlement_hexes.yaml"] = "settlements:\n" + string.Concat(Places.Select(p => FormattableString.Invariant($" - {{ id: {p.Id}, q: {p.Q}, r: {p.R} }}\n"))) + " - { id: town_h, q: 0, r: 2 }\n",
["map/settlements_1948.yaml"] = "settlements:\n" + string.Concat(Places.Select(p => FormattableString.Invariant(
- $" - {{ id: {p.Id}, name: {p.Id.Replace("town_", "Town ").ToUpperInvariant()}, lon: 34.29, lat: 33.35, type: {p.Type}, founded: 1900, pre_modern: false }}\n"))),
+ $" - {{ id: {p.Id}, name: {p.Id.Replace("town_", "Town ").ToUpperInvariant()}, lon: 34.29, lat: 33.35, type: {p.Type}, founded: 1900, pre_modern: false }}\n")))
+ + " - { id: town_h, name: Town H, lon: 34.29, lat: 33.15, type: town, founded: 1900, pre_modern: false }\n",
+ ["cities.yaml"] = "cities:\n" + Fixture.City("town_h", 12, 8, 10, 6, "[military_camp, hakhshara]"),
["settlement_targets.yaml"] = targets.Length == 0 ? "targets: []\n" : "targets:\n" + string.Concat(targets.Select(id => { var p = Places.Single(x => x.Id == id); return Target(p.Id, p.Q, p.R, fled.Contains(p.Id)); })),
});
files["rules.yaml"] = files["rules.yaml"].Replace("enemy_held_localities: []", "enemy_held_localities: [town_a, town_c, town_e]");
diff --git a/sim/Statecraft.Sim.Tests/CitiesContentTests.cs b/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
index 3852e9ac8..20d4339f7 100644
--- a/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
+++ b/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
@@ -68,6 +68,33 @@ public class CitiesContentTests
Assert.Equal(towns, ContentLoader.Load(root).Cities.Select(x => x.Id)); // in the settlements file's order
}
+ /// <summary>The fixture's town_a, then town_b (a town row) and kibbutz_c (a kibbutz row, no city), with the cities given.
+ /// Fixture values, not history.</summary>
+ static Dictionary<string, string> TwoTowns(params string[] ids) => new Dictionary<string, string>
+ {
+ ["map/settlement_hexes.yaml"] = Fixture.Files["map/settlement_hexes.yaml"] + " - { id: town_b, q: 2, r: 1 }\n - { id: kibbutz_c, q: 3, r: 1 }\n",
+ ["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"]
+ + " - { id: town_b, name: Town B, lon: 34.42, lat: 33.28, type: town, founded: 1900, pre_modern: false }\n"
+ + " - { id: kibbutz_c, name: Kibbutz C, lon: 34.51, lat: 33.28, type: kibbutz, founded: 1930, pre_modern: false }\n",
+ ["cities.yaml"] = "cities:\n" + string.Concat(ids.Select(id => Fixture.City(id, 12, 8, 10, 6))),
+ };
+
+ // R-CITY-006 (#2732): the loader holds cities.yaml to the settlement file's city and town rows, in that file's order.
+ [Fact]
+ public void TheCitiesInTheSettlementOrderLoad() =>
+ Assert.Equal(new[] { "town_a", "town_b" }, Load(TwoTowns("town_a", "town_b")).Cities.Select(x => x.Id));
+
+ [Theory]
+ [InlineData(new[] { "town_a" }, "cities", "is missing town_b, a city or town row of map/settlements_1948.yaml")]
+ [InlineData(new[] { "town_b", "town_a" }, "cities[0].id", "is town_b; map/settlements_1948.yaml's city and town rows give town_a here")]
+ [InlineData(new[] { "town_a", "town_b", "kibbutz_c" }, "cities[kibbutz_c].id", "is not a city or town row of map/settlements_1948.yaml")]
+ public void CitiesThatAreNotTheSettlementCityAndTownRowsInOrderFail(string[] ids, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(TwoTowns(ids)));
+ Assert.Equal(("cities.yaml", field), (ex.File, ex.Field));
+ Assert.Contains(message, ex.Message);
+ }
+
/// <summary>Each city's census start (the Phase 3 plan, PR 1, from #569) and its units at people_per_unit 1,000: people
/// to the nearest unit with at least 1 for a city with people (Q-START-2: Rosh Pinna's 350 is 1), employed to the nearest
/// unit of people times the working share (Q-START-1: the city's CBS share, or the national 43.9% where none exists).</summary>
diff --git a/sim/Statecraft.Sim.Tests/CitiesTests.cs b/sim/Statecraft.Sim.Tests/CitiesTests.cs
index 596b6b944..70f7b5754 100644
--- a/sim/Statecraft.Sim.Tests/CitiesTests.cs
+++ b/sim/Statecraft.Sim.Tests/CitiesTests.cs
@@ -131,13 +131,14 @@ public class CitiesTests
Assert.Equal(6 * 1.2 * SimTime.YearFraction(TurnLength.Week), paid, 9); // the fixture's first turn is a week
}
- /// <summary>Two cities with free job slots: town_b (listed first in cities.yaml) has more civilians than jobs, town_a more
- /// jobs than civilians, so each limit of min(job slots, civilians + craftsmen) is met once.</summary>
+ /// <summary>Two cities with free job slots: town_b (listed first in the settlements file and so in cities.yaml, R-CITY-006)
+ /// has more civilians than jobs, town_a more jobs than civilians, so each limit of min(job slots, civilians + craftsmen) is
+ /// met once.</summary>
static Content TwoTowns() => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
{
["map/settlement_hexes.yaml"] = "settlements:\n - { id: town_a, q: 1, r: 0 }\n - { id: town_b, q: 2, r: 1 }\n",
- ["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"]
- + " - { id: town_b, name: Town B, lon: 34.42, lat: 33.28, type: town, founded: 1900, pre_modern: false }\n",
+ ["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"].Replace("settlements:\n",
+ "settlements:\n - { id: town_b, name: Town B, lon: 34.42, lat: 33.28, type: town, founded: 1900, pre_modern: false }\n"),
["cities.yaml"] = "cities:\n" + Fixture.City("town_b", 40, 8, 10, 0) + Fixture.City("town_a", 40, 20, 10, 6),
})));
diff --git a/sim/Statecraft.Sim.Tests/DeportNeverDominatesTests.cs b/sim/Statecraft.Sim.Tests/DeportNeverDominatesTests.cs
index 6d8728087..e223b9ceb 100644
--- a/sim/Statecraft.Sim.Tests/DeportNeverDominatesTests.cs
+++ b/sim/Statecraft.Sim.Tests/DeportNeverDominatesTests.cs
@@ -13,8 +13,8 @@ using Statecraft.Sim;
/// losing the war (Q-DEP-7 (b)). On Social cohesion and International Support it is below both by at least
/// <see cref="Margin"/>. The goldens hold no capture state until a capture is reachable in the real content (#1304), so the
/// fixture states carry the test: town_a captured at full and at minimum strength, with a halutz, with an enemy beside it,
-/// and with a second place awaiting, with the fixture's one city moved to town_d's hex, out of reach. "shared hex" keeps the
-/// city on town_a's own hex, as Tel Aviv shares Jaffa's: there no city project can be started on the depopulated hex
+/// and with a second place awaiting, with the fixture's one city, town_h, on its own hex (0, 2), out of reach. "shared hex" moves
+/// town_h onto town_a's hex, as Tel Aviv shares Jaffa's: there no city project can be started on the depopulated hex
/// (R-CTRL-020), so the reference policy builds less and spends less (IL 3.0m in the fixture), which the Money cost covers.
/// Food ends the same under all three outcomes in these states, so a Food gain from Deport shows only in
/// DeportTests.TheCostsApplyAtOnce, not here. Each run is also the fixture stand-in for the paired mvp-occupy-cost and mvp-deport-cost scenarios
@@ -50,8 +50,9 @@ public class DeportNeverDominatesTests
public void DeportNeverDominates(string name)
{
var shared = name == "shared hex";
- var c = shared ? DeportTests.Load() : DeportTests.Load(files => files["cities.yaml"] = files["cities.yaml"].Replace("id: town_a,", "id: town_d,"));
- Assert.Equal(shared ? "town_a" : "town_d", Assert.Single(c.Cities).Id);
+ var c = shared ? DeportTests.Load(files => files["map/settlement_hexes.yaml"] = files["map/settlement_hexes.yaml"].Replace("id: town_h, q: 0, r: 2", "id: town_h, q: 1, r: 0"))
+ : DeportTests.Load();
+ Assert.Equal("town_h", Assert.Single(c.Cities).Id);
var s = State(c, name);
var turnEnd = new Dictionary<string, GameState>();
var end = new Dictionary<string, GameState>();
diff --git a/sim/Statecraft.Sim.Tests/DeportTests.cs b/sim/Statecraft.Sim.Tests/DeportTests.cs
index 8199364b4..674ec6f8c 100644
--- a/sim/Statecraft.Sim.Tests/DeportTests.cs
+++ b/sim/Statecraft.Sim.Tests/DeportTests.cs
@@ -186,24 +186,30 @@ public class DeportTests
// R-CTRL-020 (impact plan section 4.1 item 4; Q-DEP-7 (c); Q-SENS-2 (c)): a depopulated place adds nothing. A reflection
// test over every command kind: each that can name a place or a hex is aimed at the depopulated one and refused, and
- // every other names none. The fixture puts a road segment on the place's hex, which is also town_a's city's own hex, and
+ // every other names none. The fixture puts a road segment on the place's hex, which is also the hex of the fixture's one city,
+ // town_h (a city with its own id on a target's hex, as Tel Aviv shares Jaffa's), and
// no site can be on a settlement's hex. No effect target can name a place. The record keeps no timer, so step 10 neither counts it down nor
// charges upkeep, and a later capture check never takes it again.
[Fact]
public void ADepopulatedPlaceAddsNothing()
{
- var c = Load(files => files["corridors.yaml"] = Fixture.GddCorridors.Replace("hexes: [[2, 0], [3, 0]]", "hexes: [[1, 0], [2, 0]]"));
+ var c = Load(files =>
+ {
+ files["corridors.yaml"] = Fixture.GddCorridors.Replace("hexes: [[2, 0], [3, 0]]", "hexes: [[1, 0], [2, 0]]");
+ files["map/settlement_hexes.yaml"] = files["map/settlement_hexes.yaml"].Replace("id: town_h, q: 0, r: 2", "id: town_h, q: 1, r: 0");
+ });
// No designated site can be on a 1948 settlement's hex at all: the loader refuses it (so no pioneer site needs a check).
var onThePlace = Assert.Throws<ContentException>(() => Load(files => files["sites.yaml"] = files["sites.yaml"].Replace("q: 2\n r: 0\n kinds: [yishuv]", "q: 1\n r: 0\n kinds: [yishuv]")));
Assert.Contains("holds the 1948 settlement town_a", onThePlace.Message);
- var s = Step(c, Awaiting(c, Soldier(1, 1, 0), new Unit(2, "halutz", 1, 0)), Answer(SettlementControl.Deport)).State;
+ var awaiting = Awaiting(c, Soldier(1, 1, 0), new Unit(2, "halutz", 1, 0));
+ var s = Step(c, awaiting, Answer(SettlementControl.Deport)).State;
var ctrl = s.Settlements["town_a"];
Assert.Equal(("", "", true, 0, ""), (ctrl.Owner, ctrl.State, ctrl.Depopulated, ctrl.Turns, ctrl.Buildings));
var segment = c.Corridors[0].Id + ":1";
var aimed = new Dictionary<Type, Command[]?>
{
[typeof(MapAction)] = new Command[] { new MapAction(MapActions.Housing, 1, 0) },
- [typeof(StartProject)] = c.ProjectKinds.Select(k => (Command)new StartProject(k.Id, "town_a", 1, 0)).ToArray(),
+ [typeof(StartProject)] = c.ProjectKinds.Select(k => (Command)new StartProject(k.Id, "town_h", 1, 0)).ToArray(),
[typeof(PioneerWork)] = new Command[] { new PioneerWork(2, Corridors.BuildRoad, segment) },
[typeof(Move)] = new Command[] { new Move(1, 1, 0), new Move(2, 1, 0) },
[typeof(UnitOrder)] = new Command[] { new UnitOrder(1, Combat.Attack, 1, 0) },
diff --git a/sim/Statecraft.Sim.Tests/EndOccupationTests.cs b/sim/Statecraft.Sim.Tests/EndOccupationTests.cs
index f53f7f59c..791265bd3 100644
--- a/sim/Statecraft.Sim.Tests/EndOccupationTests.cs
+++ b/sim/Statecraft.Sim.Tests/EndOccupationTests.cs
@@ -12,7 +12,7 @@ public class EndOccupationTests
internal static GameState AwaitingEnd(Content c, bool fled, params Unit[] units) => AwaitingEnd(c, "town_a", fled, units);
/// <summary>A new game with <paramref name="units"/> and <paramref name="id"/> awaiting the end of its occupation. The
- /// fixture's cities.yaml already has a town_a city, so the stayed annexation tests use town_c (hex 4,0).</summary>
+ /// stayed annexation tests use town_c (hex 4,0).</summary>
static GameState AwaitingEnd(Content c, string id, bool fled, params Unit[] units)
{
var s = CombatTests.With(c, units);
@@ -54,7 +54,7 @@ public class EndOccupationTests
public void TheOptionsAreAnnexThenWithdraw()
{
var c = CaptureTests.Load(CaptureTests.AllTargets);
- var s = AwaitingEnd(c, "town_c", false, Soldier(1, 4, 0)); // town_a is a fixture city
+ var s = AwaitingEnd(c, "town_c", false, Soldier(1, 4, 0));
var before = s.Describe();
var options = SettlementControl.EndOptions(c, s, "town_c");
Assert.Equal(new[] { SettlementControl.Annex, SettlementControl.WithdrawOutcome }, options.Select(x => x.Outcome).ToArray());
@@ -226,7 +226,8 @@ public class EndOccupationTests
public void AnnexingOntoAnExistingCityIsRefused()
{
var c = CaptureTests.Load(CaptureTests.AllTargets);
- var s = AwaitingEnd(c, false, Soldier(1, 1, 0)); // the fixture already has a town_a city
+ var s = AwaitingEnd(c, false, Soldier(1, 1, 0));
+ s.Cities["town_a"] = new City("town_a", 12, 8, 10, 6, 0); // by hand: the loader refuses a target that is a city (R-CITY-006)
var before = s.Describe();
Assert.NotNull(SettlementControl.End(c, s, "town_a", SettlementControl.Annex, new List<Cause>()));
Assert.Equal(before, s.Describe());
@@ -268,7 +269,7 @@ public class EndOccupationTests
public void TheEndPreviewIsTheOutcome()
{
var c = CaptureTests.Load(f => f["rules.yaml"] = f["rules.yaml"].Replace("end_occupation: 0", "end_occupation: 1"), CaptureTests.AllTargets);
- var s = AwaitingEnd(c, "town_c", false, Soldier(1, 4, 0)); // town_a is a fixture city
+ var s = AwaitingEnd(c, "town_c", false, Soldier(1, 4, 0));
s.Attention = 5;
var cost = AttentionSystem.Cost(c, s, SettlementControl.EndKind);
Assert.True(cost > 0);
diff --git a/sim/Statecraft.Sim.Tests/EnemyAITests.cs b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
index 853d8f94c..a1d6f2da7 100644
--- a/sim/Statecraft.Sim.Tests/EnemyAITests.cs
+++ b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
@@ -698,7 +698,11 @@ public class EnemyAITests
{
files["rules.yaml"] = files["rules.yaml"].Replace("enemy_held_localities: []", "enemy_held_localities: [town_a]");
files["settlement_targets.yaml"] = "targets:\n" + CaptureTests.Target("town_a", 1, 0);
- files["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"].Replace("type: town", "type: arab_town");
+ // town_a is now an Arab town, so the fixture's city moves to town_h, a town on a far corner (R-CITY-006).
+ files["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"].Replace("type: town", "type: arab_town")
+ + " - { id: town_h, name: Town H, lon: 34.79, lat: 33.15, type: town, founded: 1900, pre_modern: false }\n";
+ files["map/settlement_hexes.yaml"] = Fixture.Files["map/settlement_hexes.yaml"] + " - { id: town_h, q: 5, r: 2 }\n";
+ files["cities.yaml"] = "cities:\n" + Fixture.City("town_h", 12, 8, 10, 6, "[military_camp, hakhshara]");
}
return ContentLoader.Load(Fixture.Write(files, new() { ["probe.yaml"] = card }));
}
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 051e07a1b..caaf07b38 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -489,7 +489,7 @@ namespace Statecraft.Sim
c.ProjectKindsOfOtherRulesets = kinds.Except(c.ProjectKinds).ToList();
c.Corridors = Read<CorridorsFile>(readFile, "corridors.yaml").Corridors; // sourced, hexes derived (Phase 4 PR 2)
if (c.Ruleset == SaveGame.Gdd03Ruleset) ApplyGdd03Start(readFile, c);
- ValidateGdd(c, settlementIds);
+ ValidateGdd(c, settlementIds, settlements.Where(x => x.type is "city" or "town").Select(x => x.id).ToList());
Gdd03Military.Validate(c); // after effective map overrides and role validation, only exact gdd-0.3
// The sourced starting forces (Phase 5 PR 4, R-UNIT-006), once the types and people_per_unit are known valid.
c.StartingForces = StartingForces.Read(readFile, c);
@@ -1312,7 +1312,7 @@ namespace Statecraft.Sim
}
/// <summary>The GDD v0.1 city data and rules (Phase 1 PR 3), checked only when systems.loop is gdd.</summary>
- static void ValidateGdd(Content c, List<string> settlementIds)
+ static void ValidateGdd(Content c, List<string> settlementIds, List<string> cityAndTownIds)
{
const string cf = "cities.yaml", uf = "unit_types.yaml";
Unique(cf, "cities", c.Cities.Select(x => x.Id));
@@ -1410,6 +1410,18 @@ namespace Statecraft.Sim
throw new ContentException(uf, "types[veteran_soldier]", "required as an Israeli infantry unit for recruit promotion");
// R-CITY-003: the arrivals are spread over the cities, so there must be one to take them.
if (c.Cities.Count == 0) throw new ContentException(cf, "cities", "the GDD loop needs at least one city to take the arrivals");
+ // R-CITY-006 (#2732): the cities are exactly the settlement file's city and town rows, in that file's order.
+ foreach (var x in c.Cities)
+ if (!cityAndTownIds.Contains(x.Id))
+ throw new ContentException(cf, $"cities[{x.Id}].id", $"is not a city or town row of {SettlementsFileName}");
+ for (int i = 0; i < cityAndTownIds.Count; i++)
+ {
+ if (i >= c.Cities.Count)
+ throw new ContentException(cf, "cities", $"is missing {cityAndTownIds[i]}, a city or town row of {SettlementsFileName}");
+ if (c.Cities[i].Id != cityAndTownIds[i])
+ throw new ContentException(cf, FormattableString.Invariant($"cities[{i}].id"),
+ $"is {c.Cities[i].Id}; {SettlementsFileName}'s city and town rows give {cityAndTownIds[i]} here");
+ }
foreach (var (file, r) in new[] { ("rules.yaml", c.Rules) }.Concat(c.EraRules.OrderBy(kv => kv.Key, StringComparer.Ordinal).Select(kv => ("rules/" + kv.Key + ".yaml", kv.Value))))
{
var m = r.Mvp ?? throw new ContentException(file, "mvp", "required when eras.yaml systems.loop is gdd");