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.

sim: GDD Phase 7 PR 2 (second slice), event effects on a city's housing condition (R-EFX-004, R-EFX-005; refs #806) (#1002)

Beri527be9446967
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 50b13e91c..9a5a1a25d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
under the monthly turn) join the yishuv sites in `content/sites.yaml`, each with a field site in its hex; the
founding days are the owner's (#785), and the rows stay draft. The reference player builds them in id order, so
Mefalsim is built in March 1950 and the goldens move (refs #785, #782).
+- Event options in the GDD loop can move a city's housing condition: `city_effects` takes `field: condition` with a
+ change from -1 to 1, the condition stays from 0 to 1, and a sensitive event may only lower it (R-EFX-004, R-EFX-005;
+ refs #806). No event uses them yet.
- Settings: a graphics quality choice, Automatic, High or Low (refs #40, second slice; owner decision of 18 Oct 2026).
Automatic is what the game did before: the tier the device gets, and on the web the frame-time fallback steps down
when frames are slow. High is the PC tier at render scale 1.0 and Low the Mobile tier at 0.8, both fixed, so the
diff --git a/content/schema/event.schema.json b/content/schema/event.schema.json
index 845c30cdf..9c7bb72a8 100644
--- a/content/schema/event.schema.json
+++ b/content/schema/event.schema.json
@@ -137,16 +137,19 @@
},
"city_effects": {
"type": "array",
- "description": "R-EFX-004 (GDD loop only): a whole-unit change to one city's housing_capacity or job_slots. A sensitive event may only cut (R-EFX-005).",
+ "description": "R-EFX-004 (GDD loop only): a whole-unit change to one city's housing_capacity or job_slots, or a change from -1 to 1 to its housing condition. A sensitive event may only cut (R-EFX-005).",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["city", "field", "delta"],
"properties": {
"city": { "type": "string", "minLength": 1 },
- "field": { "enum": ["housing_capacity", "job_slots"] },
- "delta": { "type": "integer", "not": { "const": 0 } }
- }
+ "field": { "enum": ["housing_capacity", "job_slots", "condition"] },
+ "delta": { "type": "number", "not": { "const": 0 } }
+ },
+ "if": { "properties": { "field": { "const": "condition" } } },
+ "then": { "properties": { "delta": { "minimum": -1, "maximum": 1 } } },
+ "else": { "properties": { "delta": { "type": "integer", "minimum": -2147483647, "maximum": 2147483647 } } }
}
},
"alternative": { "$ref": "#/definitions/alternative" }
diff --git a/docs/WRITING_EVENTS.md b/docs/WRITING_EVENTS.md
index cb8f88e78..87332e5e1 100644
--- a/docs/WRITING_EVENTS.md
+++ b/docs/WRITING_EVENTS.md
@@ -268,6 +268,8 @@ These act on the GDD records, so only content whose `eras.yaml` sets `systems.lo
- `city_effects: [{ city: haifa, field: housing_capacity, delta: 5 }]` changes one city's `housing_capacity` or
`job_slots` by a whole, non-zero number. Capacity never drops below 0 and job slots never below the city's employed
(R-EFX-004).
+- `city_effects: [{ city: haifa, field: condition, delta: -0.1 }]` moves the city's housing condition (0 to 1,
+ R-HOUSE-001) by a non-zero number from -1 to 1. It stays from 0 to 1, so a cut larger than the condition stops at 0.
An event with a sensitive tag may carry no grant and no positive `city_effects` delta; a cut is allowed (R-EFX-005).
@@ -343,8 +345,10 @@ Errors are printed as `file: field: message`. These are the messages you are mos
| `sites cannot be grant targets` | A grant's `at` names a site. |
| `no single city has the military camp` | A grant leaves out `at` when no single city has the camp. |
| `unknown city` | A grant's `at` or a `city_effects` entry names no city. |
-| `unknown field` | A `city_effects` field other than `housing_capacity` or `job_slots`. |
+| `unknown field` | A `city_effects` field other than `housing_capacity`, `job_slots` or `condition`. |
| `must not be 0` | A `city_effects` delta of 0. |
+| `must be a whole number` | A `housing_capacity` or `job_slots` delta with a fraction, or beyond the int range. |
+| `must be a number from -1 to 1` | A `condition` delta outside -1 to 1. |
| `sensitive events cannot reward units` | A sensitive-tagged event with a grant. A positive `city_effects` delta gives the same message with the field's name. |
| `unknown objective` | `objective` names an objective that is not in `objectives.yaml`. |
| `has another card` | `objective` names an objective whose `card` is a different event. |
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 35ce90a5b..ccb361978 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -156,13 +156,13 @@ R-EFX-001: An option's effect may target an indicator id from `model.yaml`, `tre
R-EFX-002: An option of an event tagged `holocaust`, `terror`, `massacre` or `war-casualties` cannot raise `treasury`, `fx_reserves`, `food`, `food_supply`, `morale` or `intl_standing` (Q-EFX-2, decided 15 October 2026: the no-gain rule covers all five resources, with the legacy indicators standing for Food, Social cohesion and International Support; `food` is Food's own target, and Arms joins the rule with its pool, #781). A cost stays allowed. The rule for the Phase 6 `displacement` tag is Q-DEP-6 (open).
-D-H2 in the GDD loop (GDD Phase 7 PR 2, #806). The owner took the plan's recommendations for Q-HFX-1 to Q-HFX-3 on 17 October 2026 (#784): grants of units, a city's housing capacity, condition and job slots, and project unlock, each validated at load; a grant is free and stands at the military camp or at the site the event names (in this slice, a city the event names: a site waits until sites carry a date, R-EFX-006); the no-reward rule covers them. This first slice builds unit grants and the housing capacity and job slots; condition and project unlock come with the records they act on (#734, #735).
+D-H2 in the GDD loop (GDD Phase 7 PR 2, #806). The owner took the plan's recommendations for Q-HFX-1 to Q-HFX-3 on 17 October 2026 (#784): grants of units, a city's housing capacity, condition and job slots, and project unlock, each validated at load; a grant is free and stands at the military camp or at the site the event names (in this slice, a city the event names: a site waits until sites carry a date, R-EFX-006); the no-reward rule covers them. The first slice built unit grants and the housing capacity and job slots; the second adds the housing condition (#855); project unlock comes with the records it acts on (#735).
R-EFX-003: An option's `grant_units` entry `{ type, n, at }` adds `n` (at least 1) units of a `unit_types.yaml` type of kind `unit`, free, taking the next ids in turn. They stand at the settlement hex of the city `at` names or, with no `at`, at the settlement hex of the one city whose `facilities` include `military_camp` (Q-HFX-2). With no such single city, `at` is required. A site is not yet a target (R-EFX-006).
-R-EFX-004: An option's `city_effects` entry `{ city, field, delta }` changes only that city's `housing_capacity` or `job_slots`, by a whole, non-zero `delta`. Housing capacity never drops below 0, and job slots never drop below the city's employed, so a larger cut applies only to what is free. Capacity may fall below the city's civilians, as overcrowding already can. The cause carries the change that applied.
+R-EFX-004: An option's `city_effects` entry `{ city, field, delta }` changes only that city's `housing_capacity` or `job_slots`, by a whole, non-zero `delta`, or its housing `condition` by a non-zero `delta` from -1 to 1. Housing capacity never drops below 0, and job slots never drop below the city's employed, so a larger cut applies only to what is free. Capacity may fall below the city's civilians, as overcrowding already can. The condition stays from 0 to 1 (R-HOUSE-001). The other fields of the city, its condition included, do not change. The cause carries the change that applied.
-R-EFX-005: An option of an event tagged `holocaust`, `terror`, `massacre` or `war-casualties` carries no unit grant and no `city_effects` gain (Q-HFX-3; extends R-EFX-002). A cut stays allowed.
+R-EFX-005: An option of an event tagged `holocaust`, `terror`, `massacre` or `war-casualties` carries no unit grant and no `city_effects` gain, whether capacity, slots or condition (Q-HFX-3; extends R-EFX-002). A cut stays allowed.
R-EFX-006: The structured effects apply after the numeric effects, grants first and then city effects, each in the option's list order. A target that does not exist on the date (an unbuilt site, a city not yet in the game) is refused at load with file and field, never skipped at run time; so is an unknown type, city or field. Every `cities.yaml` city is in the game from the first turn. A site has no window and starts unbuilt, so a site id as `at` is refused until sites carry a date. The legacy loop, which has no cities or units, refuses them. The preview (R-EVT-005) lists them in the same order.
diff --git a/sim/Statecraft.Sim.Tests/StructuredEffectTests.cs b/sim/Statecraft.Sim.Tests/StructuredEffectTests.cs
index 897bd4d79..70ef3ab4c 100644
--- a/sim/Statecraft.Sim.Tests/StructuredEffectTests.cs
+++ b/sim/Statecraft.Sim.Tests/StructuredEffectTests.cs
@@ -7,8 +7,8 @@ using Statecraft.Sim;
/// Q-HFX-1 to Q-HFX-3 on 17 October 2026 (#784): grants of units, city housing capacity, condition and job slots, and
/// project unlock, each validated at load; a grant is free and stands at the military camp or at the site the event
/// names (here a city it names); a sensitive option gains nothing from them (R-EFX-005). This first slice builds the kinds whose records are on
-/// main: unit grants and a city's housing capacity and job slots. Condition (#734), project unlock (#735) and site targets
-/// (once a site carries a date, R-EFX-006) follow.</summary>
+/// main: unit grants and a city's housing capacity and job slots; the second adds its housing condition (#855). Project unlock
+/// (#735) and site targets (once a site carries a date, R-EFX-006) follow.</summary>
public class StructuredEffectTests
{
const string Arms = @"
@@ -33,6 +33,7 @@ from: 1948-05-15
city_effects:
- { city: town_a, field: housing_capacity, delta: 3 }
- { city: town_a, field: job_slots, delta: -100 }
+ - { city: town_b, field: condition, delta: -0.05 }
";
static string Event(string structured, string tags = "") =>
@@ -116,7 +117,7 @@ from: 1948-05-15
var s = Simulation.NewGame(c, 1, Mode.Historical);
var why = new List<Cause>();
Assert.Null(EventSystem.Choose(c, s, "arms", "accept", why));
- Assert.Equal(new[] { "fx_reserves", "halutz", "halutz", "town_a.housing_capacity", "town_a.job_slots" },
+ Assert.Equal(new[] { "fx_reserves", "halutz", "halutz", "town_a.housing_capacity", "town_a.job_slots", "town_b.condition" },
why.Where(w => w.System == "events" && w.Target != "arms").Select(w => w.Target));
}
@@ -130,8 +131,14 @@ from: 1948-05-15
[InlineData(" grant_units:\n - { type: halutz, n: 1, at: nowhere }\n", "grant_units[0].at", "unknown city")]
[InlineData(" grant_units:\n - { type: halutz, n: 1, at: site_a }\n", "grant_units[0].at", "sites cannot be grant targets")]
[InlineData(" city_effects:\n - { city: nowhere, field: job_slots, delta: 1 }\n", "city_effects[0].city", "unknown city")]
- [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: 1 }\n", "city_effects[0].field", "housing_capacity or job_slots")]
+ [InlineData(" city_effects:\n - { city: town_a, field: morale, delta: 1 }\n", "city_effects[0].field", "housing_capacity, job_slots or condition")]
[InlineData(" city_effects:\n - { city: town_a, field: job_slots, delta: 0 }\n", "city_effects[0].delta", "must not be 0")]
+ [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: 0 }\n", "city_effects[0].delta", "must not be 0")]
+ [InlineData(" city_effects:\n - { city: town_a, field: housing_capacity, delta: 1.5 }\n", "city_effects[0].delta", "whole number")]
+ [InlineData(" city_effects:\n - { city: town_a, field: job_slots, delta: 3000000000 }\n", "city_effects[0].delta", "whole number")]
+ [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: 1.5 }\n", "city_effects[0].delta", "from -1 to 1")]
+ [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: -1.01 }\n", "city_effects[0].delta", "from -1 to 1")]
+ [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: .nan }\n", "city_effects[0].delta", "from -1 to 1")]
public void TheLoaderRefusesAnUnknownTarget(string structured, string field, string message)
{
var ex = Refused(structured);
@@ -149,11 +156,12 @@ from: 1948-05-15
Assert.Contains("military camp", ex.Message);
}
- // R-EFX-005: an option of a sensitive event carries no grant and no capacity or slot gain; a cut stays allowed.
+ // R-EFX-005: an option of a sensitive event carries no grant and no capacity, slot or condition gain; a cut stays allowed.
[Theory]
[InlineData(" grant_units:\n - { type: halutz, n: 1 }\n", "grant_units[0]")]
[InlineData(" city_effects:\n - { city: town_a, field: housing_capacity, delta: 1 }\n", "city_effects[0]")]
[InlineData(" city_effects:\n - { city: town_a, field: job_slots, delta: 2 }\n", "city_effects[0]")]
+ [InlineData(" city_effects:\n - { city: town_a, field: condition, delta: 0.1 }\n", "city_effects[0]")]
public void ASensitiveOptionGrantsNothing(string structured, string field)
{
var ex = Refused(structured, "war-casualties");
@@ -161,12 +169,39 @@ from: 1948-05-15
Assert.Contains("sensitive events cannot reward", ex.Message);
}
- // R-EFX-005: a sensitive option may still cut a city's capacity or slots.
+ // R-EFX-005: a sensitive option may still cut a city's capacity, slots or condition.
[Fact]
public void ASensitiveOptionMayCut()
{
Assert.Single(Load(Event(" city_effects:\n - { city: town_a, field: job_slots, delta: -1 }\n", "terror")).Events);
Assert.Single(Load(Event(" city_effects:\n - { city: town_a, field: housing_capacity, delta: -1 }\n", "war-casualties")).Events);
+ Assert.Single(Load(Event(" city_effects:\n - { city: town_a, field: condition, delta: -0.2 }\n", "massacre")).Events);
+ }
+
+ // R-EFX-004 with R-HOUSE-001: a condition effect moves only that city's housing condition, and it stays from 0 to 1; the
+ // cause carries the change that applied. The fixture starts every city at housing_start_condition.
+ [Theory]
+ [InlineData(0.25)]
+ [InlineData(-0.2)]
+ [InlineData(1.0)] // clipped at 1
+ [InlineData(-1.0)] // clipped at 0
+ public void AConditionEffectStaysFrom0To1(double delta)
+ {
+ var c = Load(Event(FormattableString.Invariant($" city_effects:\n - {{ city: town_a, field: condition, delta: {delta} }}\n")));
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var x = s.Cities["town_a"];
+ var other = s.Cities["town_b"].Canonical();
+ var start = x.Condition!.Value;
+ var why = new List<Cause>();
+ Assert.Null(EventSystem.Choose(c, s, "arms", "accept", why));
+ var y = s.Cities["town_a"];
+ var want = Math.Min(1.0, Math.Max(0.0, start + delta));
+ Assert.Equal(want, y.Condition!.Value, 12);
+ Assert.Equal((x.HousingCapacity, x.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits),
+ (y.HousingCapacity, y.JobSlots, y.Civilians, y.Employed, y.Refugees, y.Recruits));
+ Assert.Equal(other, s.Cities["town_b"].Canonical()); // R-HOUSE-001: per city
+ var cause = Assert.Single(why, w => w.Target == "town_a.condition");
+ Assert.Equal(want - start, cause.Delta, 12);
}
// R-EFX-004: housing capacity never drops below 0; the cause carries the cut that applied.
@@ -214,12 +249,13 @@ from: 1948-05-15
var c = Load(Event(Grants));
var s = Simulation.NewGame(c, 1, Mode.Historical);
var lines = EventSystem.OptionEffects(c, s, c.Events.Single().Options[0]);
- Assert.Equal(new[] { "fx_reserves", "halutz", "halutz", "town_a.housing_capacity", "town_a.job_slots" }, lines.Select(l => l.Target));
- Assert.Equal(new[] { -10.0, 2, 1, 3, -100 }, lines.Select(l => l.Delta));
+ Assert.Equal(new[] { "fx_reserves", "halutz", "halutz", "town_a.housing_capacity", "town_a.job_slots", "town_b.condition" }, lines.Select(l => l.Target));
+ Assert.Equal(new[] { -10.0, 2, 1, 3, -100, -0.05 }, lines.Select(l => l.Delta));
Assert.Equal("2 halutz units at Town A", lines[1].Message);
Assert.Equal("1 halutz unit at Town B", lines[2].Message);
Assert.Equal("Town A: housing capacity +3", lines[3].Message);
Assert.Equal("Town A: job slots -100", lines[4].Message);
+ Assert.Equal("Town B: housing condition -5.0%", lines[5].Message);
}
// A game with a granted unit replays from its save to the same hash.
@@ -237,8 +273,8 @@ from: 1948-05-15
Assert.Equal(g.State.Units.Values.OrderBy(u => u.Id).Select(u => (u.Id, u.Type, u.Q, u.R)),
loaded.State.Units.Values.OrderBy(u => u.Id).Select(u => (u.Id, u.Type, u.Q, u.R)));
Assert.Equal(g.State.NextId, loaded.State.NextId);
- Assert.Equal((g.State.Cities["town_a"].HousingCapacity, g.State.Cities["town_a"].JobSlots),
- (loaded.State.Cities["town_a"].HousingCapacity, loaded.State.Cities["town_a"].JobSlots));
+ Assert.Equal((g.State.Cities["town_a"].HousingCapacity, g.State.Cities["town_a"].JobSlots, g.State.Cities["town_b"].Condition),
+ (loaded.State.Cities["town_a"].HousingCapacity, loaded.State.Cities["town_a"].JobSlots, loaded.State.Cities["town_b"].Condition));
Assert.Equal(g.State.Hash(), loaded.State.Hash());
}
}
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 995a65523..07040104b 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -732,7 +732,7 @@ namespace Statecraft.Sim
public Dictionary<string, double> SetPolicy { get; set; } = new Dictionary<string, double>();
/// <summary>R-EFX-003: units this option grants, free, in list order (D-H2, Q-HFX-2).</summary>
public List<UnitGrant> GrantUnits { get; set; } = new List<UnitGrant>();
- /// <summary>R-EFX-004: changes to a city's housing capacity or job slots, in list order (D-H2, Q-HFX-1).</summary>
+ /// <summary>R-EFX-004: changes to a city's housing capacity, job slots or housing condition, in list order (D-H2, Q-HFX-1).</summary>
public List<CityEffect> CityEffects { get; set; } = new List<CityEffect>();
/// <summary>Who put this non-historical option forward, and on what record (R-ALT-003). Null when absent.</summary>
public OptionAlternative? Alternative { get; set; }
@@ -750,12 +750,13 @@ namespace Statecraft.Sim
public string At { get; set; } = "";
}
- /// <summary>An option's change to one field of a city: housing_capacity or job_slots, by whole units (R-EFX-004).</summary>
+ /// <summary>An option's change to one field of a city (R-EFX-004): housing_capacity or job_slots by whole units, or the
+ /// housing condition by a number from -1 to 1. A double, so one key carries both; the loader checks each field's kind.</summary>
public sealed class CityEffect
{
public string City { get; set; } = "";
public string Field { get; set; } = "";
- public int Delta { get; set; }
+ public double Delta { get; set; }
}
/// <summary>Who put forward a non-historical option, and on what record (R-ALT-003). `proposed` and `debated` name a
diff --git a/sim/Statecraft.Sim/EventRules.cs b/sim/Statecraft.Sim/EventRules.cs
index f8ca29f07..29154d38d 100644
--- a/sim/Statecraft.Sim/EventRules.cs
+++ b/sim/Statecraft.Sim/EventRules.cs
@@ -138,9 +138,17 @@ namespace Statecraft.Sim
var x = o.CityEffects[i];
string X(string field) => F(FormattableString.Invariant($"options[{o.Id}].city_effects[{i}]{field}"));
if (c.Cities.All(k => k.Id != x.City)) throw new ContentException(e.File, X(".city"), $"unknown city '{x.City}'");
- if (x.Field != EventSystem.HousingField && x.Field != EventSystem.JobsField)
- throw new ContentException(e.File, X(".field"), $"unknown field '{x.Field}' (housing_capacity or job_slots)");
+ if (x.Field != EventSystem.HousingField && x.Field != EventSystem.JobsField && x.Field != EventSystem.ConditionField)
+ throw new ContentException(e.File, X(".field"), $"unknown field '{x.Field}' (housing_capacity, job_slots or condition)");
if (x.Delta == 0) throw new ContentException(e.File, X(".delta"), "must not be 0");
+ // The condition is from 0 to 1 (R-HOUSE-001), so no change can exceed 1 either way; capacity and slots are whole
+ // units that Resolve adds as an int. The negated range test also refuses NaN.
+ if (x.Field == EventSystem.ConditionField)
+ {
+ if (!(x.Delta >= -1 && x.Delta <= 1)) throw new ContentException(e.File, X(".delta"), "must be a number from -1 to 1");
+ }
+ else if (!(Math.Abs(x.Delta) <= int.MaxValue) || x.Delta != Math.Floor(x.Delta))
+ throw new ContentException(e.File, X(".delta"), "must be a whole number in the int range");
if (sensitive && x.Delta > 0) throw new ContentException(e.File, X(""), $"sensitive events cannot reward {x.Field}");
}
}
diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.cs
index bfac1a0f9..851928f35 100644
--- a/sim/Statecraft.Sim/EventSystem.cs
+++ b/sim/Statecraft.Sim/EventSystem.cs
@@ -8,7 +8,7 @@ namespace Statecraft.Sim
{
public const int MaxSoftEventsPerTurn = 3;
/// <summary>The facility a grant with no `at` stands at (Q-HFX-2) and the city fields an option may change (R-EFX-004).</summary>
- public const string MilitaryCamp = "military_camp", HousingField = "housing_capacity", JobsField = "job_slots";
+ public const string MilitaryCamp = "military_camp", HousingField = "housing_capacity", JobsField = "job_slots", ConditionField = "condition";
static GameEvent Get(Content c, string id) => c.Events.First(e => e.Id == id);
@@ -106,10 +106,21 @@ namespace Statecraft.Sim
foreach (var x in o.CityEffects)
{
// R-EFX-004: only the named field changes. Housing capacity stays at 0 or more; job slots never fall below the
- // city's employed, so a cut takes only free slots. The cause carries the change that applied.
+ // city's employed, so a cut takes only free slots; the condition stays from 0 to 1 (R-HOUSE-001). The loader
+ // has checked the capacity and slot deltas are whole. The cause carries the change that applied.
var city = s.Cities[x.City];
- var housing = x.Field == HousingField ? Math.Max(0, city.HousingCapacity + x.Delta) : city.HousingCapacity;
- var jobs = x.Field == JobsField ? Math.Max(city.Employed, city.JobSlots + x.Delta) : city.JobSlots;
+ if (x.Field == ConditionField)
+ {
+ // A hand-built test city may have no condition; every GDD game's cities have one (R-HOUSE-001).
+ if (city.Condition is not double now) continue;
+ var condition = Math.Min(1.0, Math.Max(0.0, now + x.Delta));
+ s.Cities[x.City] = city.WithCondition(condition);
+ why.Add(new Cause("events", x.City + "." + x.Field, condition - now, $"{CityChange(c, x.City, x.Field, condition - now)} ({title})"));
+ continue;
+ }
+ var delta = (int)x.Delta;
+ var housing = x.Field == HousingField ? Math.Max(0, city.HousingCapacity + delta) : city.HousingCapacity;
+ var jobs = x.Field == JobsField ? Math.Max(city.Employed, city.JobSlots + delta) : city.JobSlots;
s.Cities[x.City] = new City(city.Id, housing, jobs, city.Civilians, city.Employed, city.Refugees, city.Recruits, city.Condition);
var applied = housing - city.HousingCapacity + jobs - city.JobSlots;
why.Add(new Cause("events", x.City + "." + x.Field, applied, $"{CityChange(c, x.City, x.Field, applied)} ({title})"));
@@ -138,8 +149,10 @@ namespace Statecraft.Sim
static string Granted(UnitGrant g, string place) =>
FormattableString.Invariant($"{g.N} {g.Type} unit{(g.N == 1 ? "" : "s")} at {place}");
- static string CityChange(Content c, string city, string field, int delta) =>
- FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {field.Replace('_', ' ')} {(delta > 0 ? "+" : "")}{delta}");
+ static string CityChange(Content c, string city, string field, double delta) =>
+ field == ConditionField
+ ? $"{PlayerText.Settlement(c, city)}: housing condition {PlayerText.PercentChange(delta)}"
+ : FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {field.Replace('_', ' ')} {(delta > 0 ? "+" : "")}{delta}");
/// <summary>R-EVT-005: every effect of an option, in the order choosing it applies them (Resolve): the numeric
/// effects, the unit grants and city effects (R-EFX-006), the policies it sets (by id), the security level, then rejoin.