A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: city projects can need a local resource; the winery needs vineyards (R-PROJ-005, refs #737) (#1025)
Beri9f75733d43e4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2848142f8..00116be16 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -62,6 +62,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBkibbutzim and the moshav (a townsman, a smith and a nurse), and an arriving man and woman beside each transit camp fromthe day it is placed. They are scenery, never units; the static figures stream after the first frame and the animatedones only at close zoom (refs #666, #663).+- City projects can need a local resource: a `projects.yaml` kind's `requires:` names one, a `cities.yaml` city lists+ its `resources:` with sources, and `StartProject` refuses the kind in a city without it (R-PROJ-005, D-D8; refs #737).+ The loader refuses a resource without sources and a kind whose resource no city has. The winery (vineyards, Zikhron+ Ya'akov, flagged `to_verify` by the owner on 18 Oct 2026) is not in `content/` yet: its rows wait for a person to+ check the vineyards' source, so the goldens do not move.- Delegation reads a minister's loyalty (R-EVT-003): when an unanswered event goes to a minister rated below`delegation_loyalty_floor` (5), only `disloyal_effect_share` (0.5) of each numeric effect of the option lands. Bothare labelled design values in `rules.yaml` `mvp:`. No minister in `people.yaml` is rated below 5 today, so thediff --git a/docs/gdd/cities.md b/docs/gdd/cities.mdindex a15d03ac0..4966177c8 100644--- a/docs/gdd/cities.md+++ b/docs/gdd/cities.md@@ -17,8 +17,7 @@ As a player of the MVP, I want the twelve Jewish cities and towns to start at th- Two housing types: permanent housing adds capacity and condition from the game's start; the transit camp is cheap, adds capacity and lowers condition, and keeps the ma'abarot policy gate in 1950 (`Q-HOUSE-3`, decided 15 October 2026 [S3]). Residents are assigned automatically, and people in training and recruits count against their city's housing while halutz units do not (`Q-HOUSE-4` and `Q-HOUSE-5`, decided 15 October 2026 [S3]).- City projects (housing and industry) are paid in full at the start and borrowed if the Treasury is short, need no workers, take a free land hex within one hex of the settlement hex that holds no other placement, and at most two start per turn nationally (`Q-PROJ-1` to `Q-PROJ-4`, decided 15 October 2026 [S3]). Starting a project costs Attention and cancelling costs half as much, both labelled design values (`Q-PROJ-5`, decided 15 October 2026 [S3]). Their costs, times and capacities are labelled design values taken from the plan's PR zero table (the plan's table merged by #604; `Q-PROJ-1`).- The craftsman trains in a city with a completed industry project, fills an ordinary job slot and earns a multiple of the job income (`Q-CRAFT-1` and `Q-CRAFT-2`, decided 15 October 2026 [S3]; D-D4). The income multiple, training time and training cost are labelled design values taken from the plan's PR zero table (the plan's table merged by #604; `Q-CRAFT-2` and `Q-CRAFT-3`). Free job slots fill automatically at no Attention cost until the player fixes a city's number with `AssignWorkers` (`Q-JOBS-1`, decided 15 October 2026 [S3]).-- The one specialised industry is the winery, in Rishon LeZion, subject to a dated 1948 to 1951 source for the town's vineyards (`Task 6.0`) (`Q-SPEC-1`, decided 15 October 2026 [S3]; Carmel Winery's first winery is in Rishon LeZion [S5]). The winery's job slots are a labelled design value taken from the plan's PR zero table (the plan's table merged by #604; `Q-SPEC-2`).-- Zichron Ya'akov's map entry adds a location-specific industry opportunity; it does not move the Rishon LeZion winery or define another winery's balance or implementation in this phase [S13].+- The one specialised industry is the winery, in Zikhron Ya'akov, its vineyards flagged `to_verify`: `Task 6.0` found no dated 1948 to 1951 source for any town's vineyards [S14], and the owner then ruled the city on #737 (18 October 2026, "all defaults" [S15]). This replaces the 15 October pick, Rishon LeZion subject to such a source (`Q-SPEC-1` [S3]; Carmel Winery's first winery is in Rishon LeZion [S5]), and the map roster's line that kept the winery there [S13]. The winery's job slots are a labelled design value taken from the plan's PR zero table (the plan's table merged by #604; `Q-SPEC-2`).- The "absorb immigrants" objective completes when, over all city residents, no refugees wait for housing, overflow stays within its bound, and employed civilians reach their share (`Q-ABS-2`, decided 15 October 2026 [S3]; D-B4; the two shares are labelled design values taken from the plan's PR zero table, merged by #604). Its milestone is the Jewish population passing one million, marked on 20 December 1949 (`Q-ABS-1`, the owner's pick, 15 October 2026 [S3]; JTA [S6]). With that milestone the card shows no photograph unless the owner approves a generic arrival one (`Q-ABS-3`, decided 15 October 2026 [S3]).- The on-screen Hebrew words: craftsman בעל מלאכה, housing condition מצב הדיור, housing project מיזם דיור, industry תעשייה, winery יקב (`Q-UI-2`, all five approved, decided 15 October 2026 [S11]).@@ -57,6 +56,8 @@ As a player of the MVP, I want the twelve Jewish cities and towns to start at th- [S11] The owner's decision on #375, 15 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/375#issuecomment-6190619484, checked 2026-10-15- [S12] GDD v0.1 Phase 2 plan, docs/superpowers/plans/2026-10-14-gdd-phase-2.md, the Q-MONEY-2 row; and docs/gdd/cutover-resource-layer.md (merged by #580), "Out of scope": "Upkeep: none until the third phase", checked 2026-10-15- [S13] MVP location scope, map priorities and separate location identities, docs/locations.md+- [S14] The winery's city: a dated 1948-51 source for its vineyards, research note merged by #823, research_notes/GDD phase 3/winery-vineyards-1948-51.md+- [S15] The owner's ruling on #737, 18 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/737#issuecomment-6249501060, checked 2026-10-18## Open questionsdiff --git a/docs/gdd/city-projects.md b/docs/gdd/city-projects.mdindex 88fc77e68..4ca8b3b23 100644--- a/docs/gdd/city-projects.md+++ b/docs/gdd/city-projects.md@@ -14,6 +14,7 @@ As a player of the MVP, I want to build housing and industry in a city over seve- A project needs no workers (R-PROJ-001).- `CancelProject(id)` stops a project being built; the Money is not returned. It costs 0.5 Attention (R-PROJ-002).- Construction resolves on the turn's construction step, after the pioneer work; the turn of the order counts. A finished project adds its capacity, condition and job slots once (R-PROJ-003).+- A specialised project, such as the winery, needs a local resource: it starts only in a city whose `cities.yaml` row lists that resource with its sources, and otherwise it is an ordinary project. The winery needs vineyards, adds 10 units of job slots for IL 2m over 6 turns (design values, `Q-SPEC-2`) and goes in Zikhron Ya'akov, its vineyards flagged `to_verify` (owner, 18 October 2026, on #737 [S5]). Its two content rows wait for a person to check the vineyards' source (R-PROJ-005).## Data touched@@ -31,7 +32,7 @@ As a player of the MVP, I want to build housing and industry in a city over seve- Refusing the legacy map actions in the GDD loop (R-PROJ-004), a separate PR.- The buttons and the drawing of projects on the map (Phase 3 PR 8).-- The craftsman (PR 5) and the winery (PR 6).+- The craftsman (PR 5).## Sources@@ -39,6 +40,7 @@ As a player of the MVP, I want to build housing and industry in a city over seve- [S2] GDD v0.1 impact analysis and phased plan, section 5, docs/superpowers/specs/2026-10-12-gdd-v0.1-impact-and-plan.md- [S3] GDD Phase 3 plan, PR 0's recommended answers and PR 4, docs/superpowers/plans/2026-10-15-gdd-phase-3.md- [S4] The ma'abara date and the map action costs, content/rules.yaml+- [S5] The owner's ruling on #737, 18 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/737#issuecomment-6249501060, checked 2026-10-18## Open questionsdiff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 68fe24d7e..1e24427cd 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -72,6 +72,8 @@ R-PROJ-002: `CancelProject(id)` removes a city project that is being built. TheR-PROJ-003: On step 5 of the turn (D-A6), after the pioneer work, every city project being built has one turn less to go, in ascending id. One that reaches 0 is built on the turn's end date and adds its kind's `capacity` to the city's housing capacity, its `condition` to the city's housing condition (kept from 0 to 1, R-HOUSE-001) and its `job_slots` to the city's job slots, once: a built project keeps its record, with its hex, and is never advanced again. `GameState.CityProjects` is hashed as `cproj[...]` only when it has a project (R-LOOP-002).+R-PROJ-005: A specialised project is allowed only in a city that has its resource (D-D8: "A winery requires areas for grapes"; Phase 3 PR 6, #737). A `projects.yaml` kind may name a `requires:` resource; a `cities.yaml` city lists its `resources:`, each with an id and sources (a url and a checked date each), and may say what the sources leave open (`to_verify`). `StartProject` of such a kind in a city without the resource is refused like the other R-PROJ-001 refusals, before the hex checks; a city founded in play has no resources. The loader refuses a resource without sources and a kind whose resource no city has. Otherwise the kind is an ordinary city project (R-PROJ-003). The one such kind is the winery, which needs vineyards, in Zikhron Ya'akov with its vineyards flagged `to_verify` (owner, 18 October 2026, on #737, "all defaults"); its content rows enter once a person has checked the vineyards' source (CONTENT_POLICY section 2, rule 6).+## TrainingTraining is step 4 of the turn in the approved order (§2.3, D-A6): it runs before production. One military camp and one Hakhshara exist in Tel Aviv at the start, a labelled design assumption (D-D5); pioneers build more at camp sites (R-CAMP-001).diff --git a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs b/sim/Statecraft.Sim.Tests/CityProjectsTests.csindex 707044c78..4561a82cf 100644--- a/sim/Statecraft.Sim.Tests/CityProjectsTests.cs+++ b/sim/Statecraft.Sim.Tests/CityProjectsTests.cs@@ -163,6 +163,33 @@ public class CityProjectsTestsAssert.Equal(s.Cities["town_a"].HousingCapacity + 3, r.State.Cities["town_a"].HousingCapacity);}+ /// <summary>town_a and town_b (on (2, 1)); only town_b has vineyards, with a fixture source, and the fixture's kinds plus a+ /// winery (IL 2m, 2 turns, +6 job slots) that requires them. Fixture values, not the game's.</summary>+ static Content WineCountry() => 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",+ ["cities.yaml"] = "cities:\n" + Fixture.City("town_a", 12, 8, 10, 6)+ + Fixture.City("town_b", 5, 2, 2, 1).Replace("facilities: [] }", Fixture.Vineyards + " }"),+ ["projects.yaml"] = Fixture.GddProjects + Fixture.Winery,+ })));++ // R-PROJ-005: a specialised project is allowed only in a city that has its resource, and is then an industry project.+ [Fact]+ public void AWineryNeedsVineyards()+ {+ var c = WineCountry();+ var s = New(c);+ var refused = Step(c, s, new StartProject("winery", "town_a", 1, 1));+ Assert.Equal("Town A has no vineyards for a winery", Assert.Single(refused.Rejected).Reason);+ Assert.Equal(Step(c, s).State.Hash(), refused.State.Hash());++ var built = Step(c, Step(c, s, new StartProject("winery", "town_b", 3, 1)).State);+ Assert.Empty(built.Rejected);+ Assert.Equal(s.Cities["town_b"].JobSlots + 6, built.State.Cities["town_b"].JobSlots);+ }+// R-PROJ-002 (D-A3): cancelling returns no Money (and, with no workers, no people) and the project adds nothing.[Fact]public void CancellingReturnsPeopleNotMoney()diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.csindex a7c044417..680fc321b 100644--- a/sim/Statecraft.Sim.Tests/Fixture.cs+++ b/sim/Statecraft.Sim.Tests/Fixture.cs@@ -272,6 +272,12 @@ projects:- { id: industry, name: an industry project, cost: 2, turns: 2, capacity: 0, condition: 0, job_slots: 3 }";+ /// <summary>A city's resources key with vineyards and a fixture source (R-PROJ-005), to add to a <see cref="City"/> row.</summary>+ public const string Vineyards = @"resources: [{ id: vineyards, sources: [{ url: ""https://example.org/vineyards"", checked: 2026-10-18 }], to_verify: a fixture note }]";++ /// <summary>A projects.yaml kind that requires vineyards (R-PROJ-005), to add to <see cref="GddProjects"/>. Fixture values.</summary>+ public const string Winery = " - { id: winery, name: a winery, cost: 2, turns: 2, capacity: 0, condition: 0, job_slots: 6, requires: vineyards }\n";+/// <summary>One designated site on a land hex next to town_a, with no settlement on it. Fixture values, not history.</summary>public const string GddSites = @"sites:diff --git a/sim/Statecraft.Sim.Tests/ProjectsContentTests.cs b/sim/Statecraft.Sim.Tests/ProjectsContentTests.csindex 747a2ec73..6e6ae0d4d 100644--- a/sim/Statecraft.Sim.Tests/ProjectsContentTests.cs+++ b/sim/Statecraft.Sim.Tests/ProjectsContentTests.cs@@ -31,4 +31,31 @@ public class ProjectsContentTestsvar e = Assert.Throws<ContentException>(() => ContentLoader.Load(dir));Assert.Contains(where, e.Message);}++ /// <summary>The fixture's cities.yaml with <paramref name="row"/> (a `resources:` key) added to town_a.</summary>+ static string WithVineyards(string row) => "\ncities:\n" + Fixture.City("town_a", 12, 8, 10, 6, "[military_camp, hakhshara]").Replace("hakhshara] }", "hakhshara], " + row + " }");++ // R-PROJ-005: a resource is a fact about the city, so it names its sources, each with a url and a checked date.+ [Theory]+ [InlineData("resources: [{ id: vineyards }]", "cities[town_a].resources[vineyards].sources")]+ [InlineData("resources: [{ id: vineyards, sources: [{ url: \"https://example.org/v\" }] }]", "cities[town_a].resources[vineyards].sources[0]")]+ [InlineData("resources: [{ id: '', sources: [{ url: \"https://example.org/v\", checked: 2026-10-18 }] }]", "cities[town_a].resources[].id")]+ public void AResourceNeedsASource(string row, string where)+ {+ var dir = Fixture.Write(Fixture.Gdd(new Dictionary<string, string> { ["cities.yaml"] = WithVineyards(row) }));+ var e = Assert.Throws<ContentException>(() => ContentLoader.Load(dir));+ Assert.Contains(where, e.Message);+ }++ // R-PROJ-005: a kind that requires a resource no city has could never be built, so the loader refuses it; with the+ // resource on a city it loads.+ [Fact]+ public void AKindNeedsACityWithItsResource()+ {+ var projects = new Dictionary<string, string> { ["projects.yaml"] = Fixture.GddProjects + Fixture.Winery };+ var e = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(Fixture.Gdd(projects))));+ Assert.Contains("projects[winery].requires", e.Message);+ projects["cities.yaml"] = WithVineyards(Fixture.Vineyards);+ Assert.Equal("vineyards", ContentLoader.Load(Fixture.Write(Fixture.Gdd(projects))).ProjectKinds.Single(k => k.Id == "winery").Requires);+ }}diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex 5cce0db7f..9aa19f2c3 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -550,6 +550,9 @@ namespace Statecraft.Simpublic double Condition { get; set; }/// <summary>Job slots added to the city when done, in population units.</summary>public int JobSlots { get; set; }+ /// <summary>A city resource the city must have (cities.yaml `resources:`), or "" for none: a specialised industry such as+ /// the winery, which needs vineyards (R-PROJ-005, D-D8).</summary>+ public string Requires { get; set; } = "";}/// <summary>A designated site (sites.yaml; docs/GDD.md "Pioneer work": building is allowed only at designated spots, and a@@ -599,6 +602,16 @@ namespace Statecraft.Simpublic List<Source> Sources { get; set; } = new List<Source>();}+ /// <summary>A city's local resource (cities.yaml `resources:`; R-PROJ-005, D-D8: "A winery requires areas for grapes"): an+ /// id a project kind's `requires` names, its sources (each with a url and a checked date), and what the sources leave+ /// open (`to_verify`, as in map/routes_1948.yaml).</summary>+ public sealed class CityResource+ {+ public string Id { get; set; } = "";+ public List<Source> Sources { get; set; } = new List<Source>();+ [YamlMember(Alias = "to_verify")] public string ToVerify { get; set; } = "";+ }+/// <summary>A city's start values (cities.yaml, GDD "Cities and construction"). The file gives people and shares, each/// with its status (R-CITY-006); the loader turns them into the population units the sim counts (D-A1, R-CITY-007).</summary>public sealed class CityStart@@ -615,6 +628,8 @@ namespace Statecraft.Sim[YamlMember(Alias = "job_slots")] public CityValue? Jobs { get; set; }/// <summary>Training facilities in the city (military_camp, hakhshara). PR 4 uses them (D-D5).</summary>public List<string> Facilities { get; set; } = new List<string>();+ /// <summary>The city's local resources (R-PROJ-005, D-D8), each sourced, which a specialised project may require.</summary>+ public List<CityResource> Resources { get; set; } = new List<CityResource>();// The units the sim starts from, set by the loader (R-CITY-007).[YamlIgnore] public int HousingCapacity { get; internal set; }diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex 059f5bab8..7991c31df 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -1032,6 +1032,16 @@ namespace Statecraft.SimWhole(cf, at + ".job_slots", CityValueOf(cf, at + ".job_slots", x.Jobs));foreach (var f in x.Facilities)if (!Facilities.Contains(f)) throw new ContentException(cf, at + ".facilities", $"unknown facility '{f}' (military_camp or hakhshara)");+ // R-PROJ-005: a resource is a fact about the city, so it is sourced like a sourced city value.+ foreach (var r in x.Resources)+ {+ var rat = $"{at}.resources[{r.Id}]";+ if (string.IsNullOrWhiteSpace(r.Id)) throw new ContentException(cf, rat + ".id", "is required");+ if (r.Sources.Count == 0) throw new ContentException(cf, rat + ".sources", "required: a resource needs a source");+ for (int i = 0; i < r.Sources.Count; i++)+ if (r.Sources[i] == null || string.IsNullOrWhiteSpace(r.Sources[i].Url) || r.Sources[i].Checked == default)+ throw new ContentException(cf, FormattableString.Invariant($"{rat}.sources[{i}]"), "needs a url and checked date");+ }}Unique(uf, "types", c.UnitTypes.Select(x => x.Id));foreach (var x in c.UnitTypes)@@ -1178,6 +1188,9 @@ namespace Statecraft.Simif (x.Capacity < 0) throw new ContentException(pf, at + ".capacity", "must not be negative");if (x.JobSlots < 0) throw new ContentException(pf, at + ".job_slots", "must not be negative");if (!(x.Condition >= -1 && x.Condition <= 1)) throw new ContentException(pf, at + ".condition", "must be a number from -1 to 1");+ // R-PROJ-005: a kind whose resource no city has could never be built.+ if (!string.IsNullOrEmpty(x.Requires) && !c.Cities.Any(k => k.Resources.Any(r => r.Id == x.Requires)))+ throw new ContentException(pf, at + ".requires", $"no city in cities.yaml has the resource '{x.Requires}'");}}diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex bffe26d5d..c8948ec38 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -170,11 +170,11 @@ namespace Statecraft.Simpublic static CityProject? CityProjectAt(GameState s, int q, int r) => s.CityProjects.Values.FirstOrDefault(p => p.Q == q && p.R == r);/// <summary>R-PROJ-001: null when city project <paramref name="kind"/> may be started for <paramref name="city"/> on hex- /// (q, r) now, else the reason. Refused for an unknown kind or city; a transit camp without the ma'abarot policy- /// (Q-HOUSE-3, D-D3: the policy carries its sourced date); a hex that is not land, is further than- /// map_action_max_distance from the city's settlement hex, or holds a placement or another city project (Q-PROJ-2); and- /// once map_actions_per_turn map actions and city projects together were started this turn (Q-PROJ-4). A short- /// Treasury is not a reason: it borrows (Q-MONEY-3). The reference player asks this before it orders.</summary>+ /// (q, r) now, else the reason. Refused for an unknown kind or city; a kind whose resource the city lacks (R-PROJ-005); a+ /// transit camp without the ma'abarot policy (Q-HOUSE-3, D-D3: the policy carries its sourced date); a hex that is not+ /// land, is further than map_action_max_distance from the city's settlement hex, or holds a placement or another city+ /// project (Q-PROJ-2); and once map_actions_per_turn map actions and city projects together were started this turn+ /// (Q-PROJ-4). A short Treasury is not a reason: it borrows (Q-MONEY-3). The reference player asks this before it orders.</summary>public static string? CheckCity(Content c, GameState s, string kind, string city, int q, int r){var k = c.ProjectKinds.FirstOrDefault(x => x.Id == kind);@@ -182,6 +182,9 @@ namespace Statecraft.Simif (!s.Cities.ContainsKey(city)) return "There is no such city";if (kind == MapActions.TransitCamp && !(s.Policies.TryGetValue(MapActions.MaabarotPolicy, out var m) && m >= 0.5))return "Transit camps need the ma'abarot policy";+ // R-PROJ-005. A city founded in play is not in cities.yaml, so it has no resources.+ if (!string.IsNullOrEmpty(k.Requires) && c.Cities.FirstOrDefault(x => x.Id == city)?.Resources.Any(x => x.Id == k.Requires) != true)+ return $"{PlayerText.Settlement(c, city)} has no {k.Requires} for {k.Name}";var hex = c.HexAt(q, r);if (hex == null || !hex.Land) return "This hex is not land";var rules = c.RulesAt(s.Date); // the era the turn starts in