A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Key the remaining report Causes for Hebrew rendering (#1682) (#1811)
Eyal Golan9a1a9cb8ae5c
diff --git a/changelog.d/1682-cause-keys.md b/changelog.d/1682-cause-keys.mdnew file mode 100644index 000000000..8e26ebc65--- /dev/null+++ b/changelog.d/1682-cause-keys.md@@ -0,0 +1,4 @@+### Fixed++- Key the remaining 68 report Cause producers for Hebrew rendering while preserving English messages and simulation rules.+ Hebrew drafts await native review; sensitive capture and displacement wording awaits sensitivity review (#1682, #564).diff --git a/sim/Statecraft.Sim.Tests/CabinetTests.cs b/sim/Statecraft.Sim.Tests/CabinetTests.csindex 58592cf46..12edce8d0 100644--- a/sim/Statecraft.Sim.Tests/CabinetTests.cs+++ b/sim/Statecraft.Sim.Tests/CabinetTests.cs@@ -402,4 +402,36 @@ public class CabinetTestsAssert.DoesNotContain(Cabinet.Lineup(c, new GameState { Date = new DateTime(1949, 6, 13) }), seat => seat.Office.Id == "minority_affairs_minister");Assert.DoesNotContain(Cabinet.Vacancies(c, new GameState { Date = new DateTime(1949, 6, 14), Attention = 4 }, none), o => o.Id == "minority_affairs_minister");}++ [Fact]+ public void AppointmentAndReshuffleRowsSnapshotTheirPeopleAndDatedTitles()+ {+ var c = Load();+ var office = c.Offices.Single(x => x.Id == "finance_minister");+ // Synthetic titles, native-review-pending; these assert snapshots, not historical names.+ office.TitleHe = "תפקיד קודם";+ office.TitleHeFrom = new DateTime(1948, 5, 15);+ office.TitleHeUntil = new DateTime(1948, 5, 16);+ var s = Simulation.NewGame(c, 42, Mode.Historical);+ var why = new List<Cause>();+ Assert.Null(Cabinet.Appoint(c, s, "finance_minister", "loyalist", why));+ var appointed = Assert.Single(why, x => x.Key == "appointed");+ var replaced = Assert.Single(why, x => x.Key == "reshuffle");+ Assert.Equal(new[] { "loyalist", "תפקיד קודם", "def_two" }, appointed.Args);+ Assert.Equal("Loy Alist appointed Minister of Finance, replacing Def Two", appointed.Message);+ Assert.Equal(new[] { "", "def_two", "other", "Minister of Finance", "תפקיד קודם" }, replaced.Args);+ Assert.Equal("Coalition stability -10.0% (Def Two lost the Minister of Finance)", replaced.Message);+ why.Clear();+ Assert.Null(Cabinet.Appoint(c, s, "finance_minister", "loyal_two", why));+ var reshuffled = Assert.Single(why, x => x.Key == "reshuffle");+ Assert.Equal(new[] { "alpha", "loyalist", "same", "Minister of Finance", "תפקיד קודם" }, reshuffled.Args);+ Assert.Equal("Coalition stability -3.0% (Alpha resents the reshuffle)", reshuffled.Message);+ s.Date = s.Date.AddDays(2);+ Assert.Equal("", office.TitleHeOn(Cabinet.Holder(c, s, office.Id), s.Date));+ office.TitleHe = "תפקיד נוכחי";+ Assert.Equal("תפקיד קודם", appointed.Args[1]);+ Assert.Equal("def_two", appointed.Args[2]);+ Assert.Equal("תפקיד קודם", replaced.Args[4]);+ }+}diff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.csnew file mode 100644index 000000000..8b4593889--- /dev/null+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs@@ -0,0 +1,445 @@+using System.Text.RegularExpressions;++namespace Statecraft.Sim.Tests;++/// <summary>#1682's 68 source producers, including rare branches. The pre-key constructor expressions are pinned to+/// c7851de so Message, Target and Delta cannot drift while metadata is added. This is not runtime branch coverage.</summary>+public class RemainingCauseKeysTests+{+ static string Root()+ {+ var dir = new DirectoryInfo(AppContext.BaseDirectory);+ while (dir != null && !File.Exists(Path.Combine(dir.FullName, "sim", "Statecraft.sln"))) dir = dir.Parent;+ return dir?.FullName ?? throw new InvalidOperationException("repository root not found");+ }++ public static IEnumerable<object[]> Producers()+ {+ yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", city, count - x.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, city)}: {count} groups in work\")" };+ yield return new object[] { "Cities.cs", "WagesPaid", "new Cause(\"city\", x.Id, paid, $\"{PlayerText.Settlement(c, x.Id)}: jobs paid {PlayerText.MoneyChange(c, \"treasury\", paid)}\"" };+ yield return new object[] { "Cities.cs", "ImmigrantsHoused", "new Cause(\"city\", x.Id, absorbed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed\")" };+ yield return new object[] { "Cities.cs", "WorkersAssigned", "new Cause(\"city\", x.Id, work - housed.Employed, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {work} groups in work\")" };+ yield return new object[] { "Cities.cs", "HousingShortage", "new Cause(\"city\", x.Id, over, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold\")" };+ yield return new object[] { "Cities.cs", "ImmigrantsWaiting", "new Cause(\"city\", x.Id, added, FormattableString.Invariant($\"{PlayerText.Settlement(c, x.Id)}: {added} groups of immigrants arrived and wait for homes\")" };+ yield return new object[] { "Military.cs", "RecruitsVeteran", "new Cause(\"city\", \"units\", u.Strength, \"Recruits became veteran soldiers\"" };+ yield return new object[] { "Corridors.cs", "CorridorStarted", "new Cause(\"map\", def.Id, 1, $\"{name}: a group of halutzim began building, cost {PlayerText.Money(c, \"treasury\", cost)}\"" };+ yield return new object[] { "Corridors.cs", "CorridorCancelled", "new Cause(\"map\", work.Id, -1, $\"{SegmentName(def, index)}: the halutzim stopped building; the Money spent is not returned\"" };+ yield return new object[] { "Corridors.cs", "CorridorCompleted", "new Cause(\"map\", w.Id, 1, $\"{SegmentName(def, i)} built\"" };+ yield return new object[] { "Corridors.cs", "PioneersVeteran", "new Cause(\"map\", w.Id, 1, \"A group of halutzim became veteran pioneers\"" };+ yield return new object[] { "MapActions.cs", "MapBorrowed", "new Cause(\"economy\", \"debt\", -s.Treasury, $\"borrowed {PlayerText.Money(c, \"debt\", -s.Treasury)} to build {PlayerText.MapAction(c, action)}\"" };+ yield return new object[] { "MapActions.cs", "MapBuilt", "new Cause(\"map\", action, 1, FormattableString.Invariant(\n $\"Built {PlayerText.MapAction(c, action)}: cost {PlayerText.Money(c, \"treasury\", rule.Cost)}, {PlayerText.Change(c, \"housing\", housing)}, {PlayerText.Change(c, \"morale\", morale)}\")" };+ yield return new object[] { "Projects.cs", "LandWorkStarted", "new Cause(\"map\", site, 1, $\"{place.Name}: a group of halutzim began {(plow ? \"plowing\" : \"draining the swamp\")}, cost {PlayerText.Money(c, \"treasury\", cost)}\"" };+ yield return new object[] { "Projects.cs", "SiteStarted", "new Cause(\"map\", site, 1, $\"{place.Name}: a group of halutzim began building {(camp ? \"a training camp\" : \"a yishuv\")}, cost {PlayerText.Money(c, \"treasury\", cost)}\"" };+ yield return new object[] { "Projects.cs", "SiteCancelled", "new Cause(\"map\", work.Site, -1, $\"{PlayerText.Site(c, work.Site)}: the halutzim stopped building; the Money spent is not returned\"" };+ yield return new object[] { "Projects.cs", "SiteCompleted", "new Cause(\"map\", w.Site, 1, $\"{place.Name} {(IsCamp(place) ? \"built\" : place.Kinds.Contains(FieldKind) ? \"plowed\" : place.Kinds.Contains(SwampKind) ? \"drained\" : \"founded\")}\"" };+ yield return new object[] { "Projects.cs", "PioneersVeteran", "new Cause(\"map\", w.Site, 1, \"A group of halutzim became veteran pioneers\"" };+ yield return new object[] { "Projects.cs", "ProjectStarted", "new Cause(\"city\", city, 1, $\"{name}: {k.Name} began, cost {PlayerText.Money(c, \"treasury\", k.Cost)}\"" };+ yield return new object[] { "Projects.cs", "ProjectCancelled", "new Cause(\"city\", p.City, -1, $\"{PlayerText.Settlement(c, p.City)}: {k.Name} was cancelled; the Money spent is not returned\"" };+ yield return new object[] { "Projects.cs", "ProjectCompleted", "new Cause(\"city\", p.City, 1, $\"{PlayerText.Settlement(c, p.City)}: {k.Name} was finished\"" };+ yield return new object[] { "Pools.cs", "ArmsBought", "new Cause(\"economy\", \"arms\", count, FormattableString.Invariant($\"Bought {count} Arms, cost {PlayerText.Money(c, \"treasury\", cost)}\")" };+ yield return new object[] { "Pools.cs", "FoodHarvest", "new Cause(\"economy\", \"food\", yield, FormattableString.Invariant($\"{f.Name}: the plowed land yielded {yield} units of Food\")" };+ yield return new object[] { "Pools.cs", "FoodShortage", "new Cause(\"economy\", \"food\", -s.FoodUnmet, FormattableString.Invariant($\"Food ran out: {s.FoodUnmet} of {need} units of the month's need went unmet\")" };+ yield return new object[] { "Pools.cs", "FoodWithoutImports", "new Cause(\"economy\", \"food\", -eaten, FormattableString.Invariant($\"No Food imported (foreign currency crisis): the stock fell to {s.Food} units\")" };+ yield return new object[] { "Prisoners.cs", "PrisonerFood", "new Cause(\"economy\", \"food\", -eaten, FormattableString.Invariant($\"The prisoners held ate {eaten} units of Food\")" };+ yield return new object[] { "Prisoners.cs", "PrisonerFoodShortage", "new Cause(\"economy\", \"morale\", change, FormattableString.Invariant($\"The prisoners held went short of {unfed} units of Food: {PlayerText.Change(c, \"morale\", change)}\")" };+ yield return new object[] { "Qualification.cs", "CraftsmenReturned", "new Cause(\"city\", city, count, $\"{name}: {Groups(count)} of craftsmen returned to civilian life and keep their training\"" };+ yield return new object[] { "Qualification.cs", "CraftsmenReassigned", "new Cause(\"city\", city, -count, $\"{name}: {Groups(count)} of qualified craftsmen are craftsmen again\"" };+ yield return new object[] { "Qualification.cs", "PioneerReturned", "new Cause(\"map\", unitId.ToString(CultureInfo.InvariantCulture), 1,\n $\"Unit {unitId} returned to civilian life in {PlayerText.Settlement(c, city)} and keeps its training\"" };+ yield return new object[] { "Qualification.cs", "PioneersReassigned", "new Cause(\"city\", city, -count, $\"{name}: {Groups(count)} of qualified {(veteran ? \"veteran pioneers\" : \"halutzim\")} are units again\"" };+ yield return new object[] { "Training.cs", "TrainingStarted", "new Cause(\"city\", city, -count, $\"{name}: {Groups(count)} began {Course(type)}{aim}, cost {PlayerText.Money(c, \"treasury\", cost)}\"" };+ yield return new object[] { "Training.cs", "TrainingArms", "new Cause(\"city\", \"arms\", -arms, FormattableString.Invariant($\"{name}: {Course(type)} took {arms} Arms\")" };+ yield return new object[] { "Training.cs", "TrainingCancelled", "new Cause(\"city\", k.City, k.Count,\n $\"{PlayerText.Settlement(c, k.City)}: {Groups(k.Count)} left {Course(type)}; the Money spent is not returned\"" };+ yield return new object[] { "Training.cs", "TrainingArmsReturned", "new Cause(\"city\", \"arms\", back, FormattableString.Invariant($\"{PlayerText.Settlement(c, k.City)}: {Course(type)} returned {back} Arms\")" };+ yield return new object[] { "Training.cs", "ReplacementsStopped", "new Cause(\"city\", k.City, 0, FormattableString.Invariant($\"{PlayerText.Settlement(c, k.City)}: unit {aim} is no longer in {PlayerText.Settlement(c, k.City)}, so its replacements stop training\")" };+ yield return new object[] { "Training.cs", "ReplacementsJoined", "new Cause(\"city\", k.City, k.Count, FormattableString.Invariant($\"{name}: {Groups(k.Count)} finished {Course(type)} and joined unit {target.Id}\")" };+ yield return new object[] { "Training.cs", "MilitaryTrained", "new Cause(\"city\", k.City, k.Count, $\"{name}: {Groups(k.Count)} finished {Course(type)} and are {Trained(type)}\"" };+ yield return new object[] { "Training.cs", "PioneersTrained", "new Cause(\"city\", k.City, k.Count, $\"{name}: {Groups(k.Count)} finished {Course(type)} and are halutzim\"" };+ yield return new object[] { "Training.cs", "CraftsmenTrained", "new Cause(\"city\", k.City, k.Count, $\"{name}: {Groups(k.Count)} finished {Course(type)} and are craftsmen\"" };+ yield return new object[] { "Cabinet.cs", "Appointed", "new Cause(\"cabinet\", officeId, 0, displaced == null\n ? $\"{person.Name} appointed {office.Title}\"\n : $\"{person.Name} appointed {office.Title}, replacing {displaced.Name}\"" };+ yield return new object[] { "Cabinet.cs", "Reshuffle", "new Cause(\"politics\", \"coalition_stability\", s.CoalitionStability - before, (\n $\"coalition stability {PlayerText.PercentChange(s.CoalitionStability - before)} ({who} {(sameParty ? \"resents the reshuffle\" : \"lost the \" + office.Title)})\")" };+ yield return new object[] { "Cabinet.cs", "AppointmentsEnded", "new Cause(\"cabinet\", \"appointments\", -s.Appointments.Count, \"A new government took office with its own ministers; your appointments ended\"" };+ yield return new object[] { "PoliticsSystem.cs", "ApprovalStability", "new Cause(\"politics\", \"coalition_stability\", s.CoalitionStability - old, $\"coalition stability {PlayerText.PercentChange(s.CoalitionStability - old)} (public approval)\"" };+ yield return new object[] { "PoliticsSystem.cs", "CoalitionCollapsed", "new Cause(\"politics\", \"game_over\", 0, \"The coalition collapsed. Your premiership is over.\"" };+ yield return new object[] { "PoliticsSystem.cs", "LegislatureConvened", "new Cause(\"politics\", l1.Id, 0, FormattableString.Invariant($\"{l1.Body} convened ({l1.Size} seats{elected}); coalition holds {seats}/{size}\")" };+ yield return new object[] { "PoliticsSystem.cs", "GovernmentTookOffice", "new Cause(\"politics\", g1!.Id, 0, $\"{g1.Name} took office ({string.Join(\", \", PartyNames(c, g1.CoalitionOn(g1.From)))})\"" };+ yield return new object[] { "PoliticsSystem.cs", "CoalitionChanged", "new Cause(\"politics\", g.Id, 0, FormattableString.Invariant($\"{string.Join(\"; \", what)} (coalition holds {seats}/{size})\")" };+ yield return new object[] { "Simulation.cs", "EraEnded", "new Cause(\"era\", s.GameOver, 0, PlayerText.GameOver(s.GameOver)" };+ yield return new object[] { "Simulation.cs", "AdvisoryPolicyRejected", "new Cause(\"politics\", p.Policy, 0, $\"{legislature.Body} voted against {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}, but its vote does not bind\"" };+ yield return new object[] { "Simulation.cs", "PolicyRejected", "new Cause(\"politics\", p.Policy, 0, $\"{legislature.Body} voted down {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}\"" };+ yield return new object[] { "Simulation.cs", "PolicySet", "new Cause(\"policy\", p.Policy, p.Level, $\"{PlayerText.Target(c, p.Policy)} set to {PlayerText.Percent(p.Level)}\"" };+ yield return new object[] { "Simulation.cs", "AdvisoryBudgetRejected", "new Cause(\"politics\", \"budget\", 0, $\"{Offices.Legislature(c, s.Date)!.Body} voted against the budget, but its vote does not bind\"" };+ yield return new object[] { "Simulation.cs", "BudgetRejected", "new Cause(\"politics\", \"budget\", 0, $\"{Offices.Legislature(c, s.Date)!.Body} voted the budget down\"" };+ yield return new object[] { "TurnResolver.cs", "EraEnded", "new Cause(\"era\", s.GameOver, s.ExhaustedTurns, PlayerText.GameOver(s.GameOver)" };+ yield return new object[] { "TurnResolver.cs", "EraEnded", "new Cause(\"era\", s.GameOver, u.Id, PlayerText.GameOver(s.GameOver)" };+ yield return new object[] { "SettlementControl.cs", "PlaceCaptured", "new Cause(\"map\", t.Id, 0, $\"{c.SettlementNames[t.Id]} is captured: Israeli units hold it and no enemy unit is there. \"\n + (fled ? \"Its residents fled. \" : \"\") + \"It awaits a decision\"" };+ yield return new object[] { "SettlementControl.cs", "EnemyRegained", "new Cause(\"map\", t.Id, 0, $\"{c.SettlementNames[t.Id]} is under enemy control again: enemy units hold it and no Israeli unit is there\"\n + (record.Fled ? \". \" + FledLine : \"\")" };+ yield return new object[] { "SettlementControl.cs", "PlaceAnnexed", "new Cause(\"map\", id, 0, x.Fled\n ? $\"{name} is annexed. Its residents fled when it was captured, so no people, homes or jobs are added\"\n : $\"{name} is annexed. Its residents join the population\"" };+ yield return new object[] { "SettlementControl.cs", "PlaceWithdrawn", "new Cause(\"map\", id, 0, moved.Count > 0\n ? $\"{name}: Israeli units withdrew and it is under enemy control again. {residents}\"\n : $\"{name} is under enemy control again. {residents}\"" };+ yield return new object[] { "SettlementControl.cs", "PlaceDeported", "new Cause(\"map\", id, 0, $\"{name}: Deport. Its residents are displaced and the place is depopulated\"" };+ yield return new object[] { "SettlementControl.cs", "DeportEffect", "new Cause(\"map\", indicator, change, $\"{PlayerText.Change(c, indicator, change)} (Deport of {name})\"" };+ yield return new object[] { "SettlementControl.cs", "DeportCost", "new Cause(\"economy\", \"treasury\", -r.DeportMoneyCost!.Value, $\"{PlayerText.Change(c, \"treasury\", -r.DeportMoneyCost.Value)} (Deport of {name})\"" };+ yield return new object[] { "SettlementControl.cs", "OccupationStarted", "new Cause(\"map\", id, turns, FormattableString.Invariant($\"{name} is occupied for {turns} turns: an Israeli unit stays there. \") + Residents(x)" };+ yield return new object[] { "SettlementControl.cs", "PendingBecameRaid", "new Cause(\"map\", id, 0, $\"{c.SettlementNames[id]}: no decision was made before the end, so it counts as a raid\"" };+ yield return new object[] { "SettlementControl.cs", "OccupationLostUnit", "new Cause(\"map\", id, 0, $\"{name}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {Residents(x)}\"" };+ yield return new object[] { "SettlementControl.cs", "OccupationCountdown", "new Cause(\"map\", id, left, left == 0\n ? $\"{name}: the occupation period has ended. It awaits a decision\"\n : FormattableString.Invariant($\"{name}: {left} turns of occupation left\")" };+ yield return new object[] { "SettlementControl.cs", "DepopulationSupport", "new Cause(\"map\", SupportIndicator, change, $\"{PlayerText.Change(c, SupportIndicator, change)} (the places depopulated by Deport)\"" };+ }++ [Theory]+ [MemberData(nameof(Producers))]+ public void EveryListedProducerKeepsItsEnglishExpressionsAndAddsARegisteredKey(string file, string key, string original)+ {+ var source = File.ReadAllText(Path.Combine(Root(), "sim", "Statecraft.Sim", file));+ Assert.Contains(original + ", key: CauseKeys." + key, source);+ var field = typeof(CauseKeys).GetField(key);+ Assert.NotNull(field);+ Assert.Contains((string)field!.GetRawConstantValue()!, CauseKeys.All);+ }++ [Fact]+ public void InventoryContainsExactly68ProducerSites()+ {+ Assert.Equal(68, Producers().Count());+ }++ [Fact]+ public void EverySourceProducerIsKeyed()+ {+ var sites = 0;+ foreach (var file in Directory.GetFiles(Path.Combine(Root(), "sim", "Statecraft.Sim"), "*.cs"))+ {+ var source = File.ReadAllText(file);+ foreach (var keyed in SourceCauseKeys(source))+ {+ Assert.True(keyed, file + ": Cause needs a top-level key argument");+ sites++;+ }+ }+ Assert.Equal(104, sites);+ }++ [Fact]+ public void InventoryIgnoresLiteralCommentAndNestedKeyText()+ {+ // Red-first regression: the old scanner never balances the first literal's '('.+ var source = "new Cause(\"map\", \"town\", 0, \"(\" /* key: fake */);\n"+ + "new Cause(\"map\", \"town\", 0, $\"({Name(\"(\")}\", key: CauseKeys.PlaceCaptured);\n"+ + "new Cause(\"map\", \"town\", 0, @\"(\"\" key: fake\");\n"+ + "new Cause(\"map\", \"town\", 0, $@\"({Name(@\"(\")}\");\n"+ + "new Cause(\"map\", \"town\", 0, @$\"({Name(\"(\")}\");\n"+ + "new Cause(\"map\", \"town\", 0, Label('(', key: fake)); // key: fake\n";+ Assert.Equal(new[] { false, true, false, false, false, false }, SourceCauseKeys(source).ToArray());+ }++ [Fact]+ public void InventoryIgnoresRawLiteralAndInterpolationKeyText()+ {+ // Source snippets are escaped ordinary strings so the fixture itself needs no raw syntax.+ var rows = new[]+ {+ "new Cause(\"map\", \"town\", 0, \"\"\"a\", key: fake, \"b\"\"\");",+ "new Cause(\"map\", \"town\", 0, $\"\"\"a\", key: fake, \"{Name(\"\"\"nested\"\"\")}\"b\"\"\");",+ "new Cause(\"map\", \"town\", 0, $$\"\"\"a\", key: fake, \"{{Name(\"\"\"nested\"\"\")}}\"b\"\"\");",+ "new Cause(\"map\", \"town\", 0, \"\"\"\"\n a\"\"\", key: fake, \"\"\"b (\n \"\"\"\");",+ "new Cause(\"map\", \"town\", 0, $$\"\"\"\n {literal} a\", key: fake, \"{{new { Text = \"\"\"nested\"\"\" }}} b (\n \"\"\");",+ };+ foreach (var row in rows)+ {+ Assert.Equal(new[] { false }, SourceCauseKeys(row).ToArray());+ // Masking must stop at the delimiter and preserve a real following key argument.+ var keyed = row.Insert(row.LastIndexOf(')'), ", key: CauseKeys.PlaceCaptured");+ Assert.Equal(new[] { true }, SourceCauseKeys(keyed).ToArray());+ }+ }++ [Theory]+ [InlineData("new Cause(\"m\", \"t\", 0, $\"{1:\\\\'}\", key: K);")]+ [InlineData("new Cause(\"m\", \"t\", 0, $$\"\"\"{{1:\\'}}\"\"\", key: K);")]+ [InlineData("new Cause(\"m\", \"t\", 0, $\"{1:\\\\\\\"}\", key: K);")]+ [InlineData("new Cause(\"m\", \"t\", 0, $$\"\"\"{{1:\\\"}}\"\"\", key: K);")]+ [InlineData("new Cause(\"m\", \"t\", 0, $@\"{1:'\"\"}\", key: K);")]+ [InlineData("new Cause(\"m\", \"t\", 0, $\"{(true ? 1 : 2):\\\\'}\", key: K);")]+ public void InventoryKeepsRealKeysAfterInterpolationFormatClauses(string source)+ {+ Assert.Equal(new[] { true }, SourceCauseKeys(source).ToArray());+ Assert.Equal(new[] { false }, SourceCauseKeys(source.Replace(", key: K", "")).ToArray());+ }++ static IEnumerable<bool> SourceCauseKeys(string source)+ {+ // Keep offsets, but erase whole literals (including interpolation holes) and comments.+ var masked = source.ToCharArray();+ for (var i = 0; i < source.Length;)+ {+ var start = i;+ if (!SkipLiteralOrComment(source, ref i)) { i++; continue; }+ for (var j = start; j < i; j++) masked[j] = ' ';+ }+ var code = new string(masked);+ foreach (Match start in Regex.Matches(code, @"\bnew\s+Cause\s*\("))+ {+ var parens = 1; var brackets = 0; var braces = 0;+ var argument = start.Index + start.Length;+ var keyed = false;+ var end = argument;+ for (; end < code.Length; end++)+ {+ var ch = code[end];+ if (parens == 1 && brackets == 0 && braces == 0 && (ch == ',' || ch == ')'))+ {+ keyed |= Regex.IsMatch(code.Substring(argument, end - argument), @"^\s*key\s*:(?!:)");+ argument = end + 1;+ }+ if (ch == '(') parens++;+ if (ch == ')') parens--;+ if (ch == '[') brackets++;+ if (ch == ']') brackets--;+ if (ch == '{') braces++;+ if (ch == '}') braces--;+ if (parens == 0) break;+ }+ Assert.Equal(0, parens);+ yield return keyed;+ }+ }++ static bool SkipLiteralOrComment(string source, ref int i)+ {+ var start = i;+ if (source[i] == '/' && i + 1 < source.Length)+ {+ if (source[i + 1] == '/')+ {+ i += 2;+ while (i < source.Length && source[i] != '\n') i++;+ return true;+ }+ if (source[i + 1] == '*')+ {+ var end = source.IndexOf("*/", i + 2, StringComparison.Ordinal);+ i = end < 0 ? source.Length : end + 2;+ return true;+ }+ }+ // Raw literals use a quote-run delimiter; dollar count sets interpolation brace width.+ var quoteStart = i;+ while (quoteStart < source.Length && source[quoteStart] == '$') quoteStart++;+ var quoteEnd = quoteStart;+ while (quoteEnd < source.Length && source[quoteEnd] == '\"') quoteEnd++;+ var quotes = quoteEnd - quoteStart;+ if (quotes >= 3)+ {+ var dollars = quoteStart - i;+ i = quoteEnd;+ while (i < source.Length)+ {+ var end = i;+ while (end < source.Length && source[end] == '\"') end++;+ if (end - i == quotes) { i = end; return true; }+ if (end > i) { i = end; continue; }+ if (dollars > 0 && source[i] == '{')+ {+ end = i;+ while (end < source.Length && source[end] == '{') end++;+ if (end - i >= dollars)+ {+ i = end;+ SkipInterpolation(source, ref i, dollars, raw: true);+ continue;+ }+ i = end;+ continue;+ }+ i++;+ }+ return true;+ }+ var verbatim = false; var interpolated = false;+ if (source[i] == '$' || source[i] == '@')+ {+ verbatim = source[i] == '@'; interpolated = source[i] == '$'; i++;+ if (i < source.Length && ((verbatim && source[i] == '$') || (interpolated && source[i] == '@')))+ {+ verbatim = interpolated = true; i++;+ }+ }+ if (i >= source.Length || (source[i] != '"' && (i != start || source[i] != '\'')))+ {+ i = start; return false;+ }+ var quote = source[i++];+ while (i < source.Length)+ {+ var ch = source[i++];+ if (!verbatim && ch == '\\') { if (i < source.Length) i++; continue; }+ if (ch == quote)+ {+ if (verbatim && i < source.Length && source[i] == quote) { i++; continue; }+ return true;+ }+ if (interpolated && ch == '{')+ {+ if (i < source.Length && source[i] == '{') { i++; continue; }+ SkipInterpolation(source, ref i, verbatim: verbatim);+ }+ }+ return true;+ }++ static void SkipInterpolation(string source, ref int i, int braceWidth = 1, bool verbatim = false, bool raw = false)+ {+ var depth = 0; var parens = 0; var brackets = 0;+ while (i < source.Length)+ {+ if (SkipLiteralOrComment(source, ref i)) continue;+ // A format component is literal text, not another C# expression. In particular,+ // an apostrophe there must not start a character literal that swallows the real key.+ if (source[i] == ':' && depth == 0 && parens == 0 && brackets == 0)+ {+ if (i + 1 < source.Length && source[i + 1] == ':') { i += 2; continue; }+ i++;+ SkipFormat(source, ref i, braceWidth, verbatim, raw);+ return;+ }+ if (source[i] == '(') parens++;+ if (source[i] == ')') parens--;+ if (source[i] == '[') brackets++;+ if (source[i] == ']') brackets--;+ if (source[i] == '{') depth++;+ if (source[i] == '}')+ {+ if (depth > 0) { depth--; i++; continue; }+ var end = i;+ while (end < source.Length && source[end] == '}') end++;+ if (end - i >= braceWidth) { i += braceWidth; return; }+ i = end;+ continue;+ }+ i++;+ }+ }++ static void SkipFormat(string source, ref int i, int braceWidth, bool verbatim, bool raw)+ {+ while (i < source.Length)+ {+ if (!raw && !verbatim && source[i] == '\\') { i += Math.Min(2, source.Length - i); continue; }+ if (!raw && verbatim && source[i] == '"' && i + 1 < source.Length && source[i + 1] == '"')+ { i += 2; continue; }+ if (source[i] == '}')+ {+ var end = i;+ while (end < source.Length && source[end] == '}') end++;+ if (end - i >= braceWidth) { i += braceWidth; return; }+ i = end; continue;+ }+ i++;+ }+ }++ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void TheFullReferenceRunKeysEveryProducer(bool legacy)+ {+ var c = legacy ? RealContentTests.Legacy() : ContentLoader.Load(RealContentTests.ContentRoot());+ var state = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);+ var count = 0;+ for (var turn = 0; turn < 1000 && state.GameOver == null; turn++)+ {+ var result = Simulation.Step(c, state, GoldenRun.Orders(c, state));+ foreach (var line in result.Why)+ {+ Assert.True(CauseKeys.All.Contains(line.Key) || WhyKeys.All.Contains(line.Key), line.ToString());+ count++;+ }+ state = result.State;+ }+ Assert.True(count > 0);+ Assert.NotNull(state.GameOver);+ }++ [Fact]+ public void WorkerAndTrainingProducersCaptureCountsAndKeepEnglish()+ {+ var c = ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>+ {+ ["cities.yaml"] = "cities:\n" + Fixture.City("town_a", 12, 20, 10, 6, "[military_camp, hakhshara]"),+ })));+ var state = Simulation.NewGame(c, 1, Mode.Historical);+ state.Attention = 10; // Synthetic budget: both fixture commands must be legal.+ var result = Simulation.Step(c, state, new Command[] { new AssignWorkers("town_a", "job", 4), new Train("town_a", "recruit", 3) });+ Assert.Empty(result.Rejected);+ var workers = Assert.Single(result.Why, x => x.Key == "workers_assigned" && x.Args[0] == "4");+ Assert.Equal("Town A: 4 groups in work", workers.Message);+ var training = Assert.Single(result.Why, x => x.Key == "training_started");+ Assert.Equal(new[] { "3", "basic", "", "1.5" }, training.Args);+ Assert.Equal("Town A: 3 groups began basic training, cost IL 1.5m", training.Message);+ }++ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void CaptureAndWithdrawalSnapshotResidentsBeforeRelease(bool fled)+ {+ var c = fled ? CaptureTests.LoadFled(new[] { "town_a" }, CaptureTests.AllTargets) : CaptureTests.Load(CaptureTests.AllTargets);+ var state = CombatTests.With(c, CaptureTests.Soldier(1, 1, 0));+ var result = Simulation.Step(c, state, new Command[] { new ResolveCapture("town_a", SettlementControl.Raid) });+ Assert.Empty(result.Rejected);+ var captured = Assert.Single(result.Why, x => x.Key == "place_captured");+ var withdrawn = Assert.Single(result.Why, x => x.Key == "place_withdrawn");+ Assert.Equal(new[] { fled ? "1" : "0" }, captured.Args);+ Assert.Equal(new[] { "1", fled ? "1" : "0" }, withdrawn.Args);+ Assert.Equal("TOWN A is captured: Israeli units hold it and no enemy unit is there. "+ + (fled ? "Its residents fled. " : "") + "It awaits a decision", captured.Message);+ Assert.Equal("TOWN A: Israeli units withdrew and it is under enemy control again. "+ + (fled ? "Its residents fled when it was captured" : "Its residents are unchanged"), withdrawn.Message);+ // Release leaves no stayed record; the stored line must still carry the prior resident state.+ if (!fled) Assert.False(result.State.Settlements.ContainsKey("town_a"));+ result.State.Settlements.Clear();+ Assert.Equal(fled ? "1" : "0", withdrawn.Args[1]);+ }++ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void OccupationAndAnnexationCaptureResidentsFromTheRealProducers(bool fled)+ {+ var c = fled ? CaptureTests.LoadFled(new[] { "town_c" }, CaptureTests.AllTargets) : CaptureTests.Load(CaptureTests.AllTargets);+ var state = CombatTests.With(c, CaptureTests.Soldier(1, 4, 0));+ var why = new List<Cause>();+ SettlementControl.Capture(c, state, state.Date.AddDays(7), why);+ why.Clear();+ Assert.Null(SettlementControl.Resolve(c, state, "town_c", SettlementControl.Occupy, why));+ var occupied = Assert.Single(why, x => x.Key == "occupation_started");+ Assert.Equal(new[] { fled ? "1" : "0" }, occupied.Args);+ var turns = c.RulesAt(state.Date).Mvp!.OccupationTurns!.Value;+ Assert.Equal(FormattableString.Invariant($"TOWN C is occupied for {turns} turns: an Israeli unit stays there. ")+ + (fled ? "Its residents fled when it was captured" : "Its residents are unchanged"), occupied.Message);+ var record = state.Settlements["town_c"];+ state.Settlements["town_c"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingEnd, record.Since, fled: fled);+ why.Clear();+ Assert.Null(SettlementControl.End(c, state, "town_c", SettlementControl.Annex, why));+ var annexed = Assert.Single(why, x => x.Key == "place_annexed");+ Assert.Equal(new[] { fled ? "1" : "0" }, annexed.Args);+ Assert.Equal("TOWN C is annexed. " + (fled+ ? "Its residents fled when it was captured, so no people, homes or jobs are added"+ : "Its residents join the population"), annexed.Message);+ state.Settlements.Clear();+ Assert.Equal(fled ? "1" : "0", occupied.Args[0]);+ Assert.Equal(fled ? "1" : "0", annexed.Args[0]);+ }++ [Theory]+ [InlineData("hash1950")]+ [InlineData("hash1952")]+ [InlineData("mvp-end")]+ public void GddIdentityUsesOnlyTheGoldenManifest(string name)+ {+ var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var state = name == "mvp-end" ? GoldenRun.PlayToEnd(c)+ : GoldenRun.Play(c, name == "hash1950" ? GoldenRun.Until1950 : GoldenRun.Until1952);+ Assert.Equal(GoldenManifest.Expected(name), state.Hash());+ }++}diff --git a/sim/Statecraft.Sim/Cabinet.cs b/sim/Statecraft.Sim/Cabinet.csindex 6ea0fe172..053f64eae 100644--- a/sim/Statecraft.Sim/Cabinet.cs+++ b/sim/Statecraft.Sim/Cabinet.cs@@ -169,7 +169,7 @@ namespace Statecraft.Sims.Appointments[officeId] = new Appointment(personId, s.Date);why.Add(new Cause("cabinet", officeId, 0, displaced == null? $"{person.Name} appointed {office.Title}"- : $"{person.Name} appointed {office.Title}, replacing {displaced.Name}"));+ : $"{person.Name} appointed {office.Title}, replacing {displaced.Name}", key: CauseKeys.Appointed, args: new[] { person.Id, office.TitleHeOn(person, s.Date), displaced?.Id ?? "" }));if (displaced == null) return null;var oldParty = Offices.PartyOf(c, displaced, s.Date);var newParty = Offices.PartyOf(c, person, s.Date);@@ -181,7 +181,7 @@ namespace Statecraft.Sims.CoalitionStability = Math.Max(0, before - cost);var who = oldParty == "" ? displaced.Name : c.Parties.First(p => p.Id == oldParty).Name;why.Add(new Cause("politics", "coalition_stability", s.CoalitionStability - before, (- $"coalition stability {PlayerText.PercentChange(s.CoalitionStability - before)} ({who} {(sameParty ? "resents the reshuffle" : "lost the " + office.Title)})")));+ $"coalition stability {PlayerText.PercentChange(s.CoalitionStability - before)} ({who} {(sameParty ? "resents the reshuffle" : "lost the " + office.Title)})"), key: CauseKeys.Reshuffle, args: new[] { oldParty, displaced.Id, sameParty ? "same" : "other", office.Title, office.TitleHeOn(displaced, s.Date) }));return null;}@@ -190,7 +190,7 @@ namespace Statecraft.Sim{if (s.AppointedUnder == "" || Offices.Government(c, s.Date)?.Id == s.AppointedUnder) return;if (s.Appointments.Count > 0)- why.Add(new Cause("cabinet", "appointments", -s.Appointments.Count, "A new government took office with its own ministers; your appointments ended"));+ why.Add(new Cause("cabinet", "appointments", -s.Appointments.Count, "A new government took office with its own ministers; your appointments ended", key: CauseKeys.AppointmentsEnded));s.Appointments.Clear();s.AppointedUnder = "";}diff --git a/sim/Statecraft.Sim/Cause.cs b/sim/Statecraft.Sim/Cause.csindex c1f264d10..0a1080b7a 100644--- a/sim/Statecraft.Sim/Cause.cs+++ b/sim/Statecraft.Sim/Cause.cs@@ -19,7 +19,7 @@ namespace Statecraft.Simpublic string EnemyOrder { get; }/// <summary>With EnemyOrder Combat.Attack: the enemy units that attacked in the engagement, in id order; else empty.</summary>public IReadOnlyList<int> EnemyAttackers { get; }- /// <summary>A stable localization key when this line names units (#1399); else empty.</summary>+ /// <summary>A stable localization key for a unit line (#1399) or report producer (CauseKeys); else empty.</summary>public string Key { get; }/// <summary>Snapshots of the units this line names, in placeholder order (#1399); else empty.</summary>public IReadOnlyList<UnitRef> Units { get; }@@ -35,7 +35,7 @@ namespace Statecraft.Simpublic override string ToString() => $"[{System}] {Message}";}- /// <summary>B1: the keys of the resource, population, effect and security lines, so the UI words them in the player's+ /// <summary>B1: the keys of the resource, population, effect, security and remaining report lines (#1682), so the UI words them in the player's/// language (why.cause.<key>) from the line's Target, Delta and Args instead of its English Message. Message stays/// as it was, word for word, for the CLI, the tests and every line without a key. These lines name no unit, so they are/// apart from <see cref="WhyKeys"/>. A line that is not keyed yet keeps its English Message on screen.</summary>@@ -82,6 +82,137 @@ namespace Statecraft.Sim// Grant: context then city id. City: context then city id, field. Rejoin: context then EN/HE title.public const string MilitaryUpkeep = "military_upkeep";++ // #1682: immutable values in Args; no current-state lookup is needed to word an old report.+ /// <summary>Args: CauseKeys.Number(work).</summary>+ public const string WorkersAssigned = "workers_assigned";+ /// <summary>Args: none.</summary>+ public const string WagesPaid = "wages_paid";+ /// <summary>Args: CauseKeys.Number(absorbed).</summary>+ public const string ImmigrantsHoused = "immigrants_housed";+ /// <summary>Args: CauseKeys.Number(over).</summary>+ public const string HousingShortage = "housing_shortage";+ /// <summary>Args: CauseKeys.Number(added).</summary>+ public const string ImmigrantsWaiting = "immigrants_waiting";+ /// <summary>Args: none.</summary>+ public const string RecruitsVeteran = "recruits_veteran";+ /// <summary>Args: def.Id; CauseKeys.Number(n); CauseKeys.Number(cost).</summary>+ public const string CorridorStarted = "corridor_started";+ /// <summary>Args: def.Id; CauseKeys.Number(index + 1).</summary>+ public const string CorridorCancelled = "corridor_cancelled";+ /// <summary>Args: def.Id; CauseKeys.Number(i + 1).</summary>+ public const string CorridorCompleted = "corridor_completed";+ /// <summary>Args: none.</summary>+ public const string PioneersVeteran = "pioneers_veteran";+ /// <summary>Args: action.</summary>+ public const string MapBorrowed = "map_borrowed";+ /// <summary>Args: CauseKeys.Number(rule.Cost); CauseKeys.Number(housing); CauseKeys.Number(morale).</summary>+ public const string MapBuilt = "map_built";+ /// <summary>Args: plow ? "plow" : "drain"; CauseKeys.Number(cost).</summary>+ public const string LandWorkStarted = "land_work_started";+ /// <summary>Args: camp ? "camp" : "yishuv"; CauseKeys.Number(cost).</summary>+ public const string SiteStarted = "site_started";+ /// <summary>Args: none.</summary>+ public const string SiteCancelled = "site_cancelled";+ /// <summary>Args: IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : place.Kinds.Contains(SwampKind) ? "drained" : "founded".</summary>+ public const string SiteCompleted = "site_completed";+ /// <summary>Args: kind; CauseKeys.Number(k.Cost).</summary>+ public const string ProjectStarted = "project_started";+ /// <summary>Args: k.Id.</summary>+ public const string ProjectCancelled = "project_cancelled";+ /// <summary>Args: k.Id.</summary>+ public const string ProjectCompleted = "project_completed";+ /// <summary>Args: CauseKeys.Number(cost).</summary>+ public const string ArmsBought = "arms_bought";+ /// <summary>Args: f.Id.</summary>+ public const string FoodHarvest = "food_harvest";+ /// <summary>Args: CauseKeys.Number(need).</summary>+ public const string FoodShortage = "food_shortage";+ /// <summary>Args: CauseKeys.Number(s.Food).</summary>+ public const string FoodWithoutImports = "food_without_imports";+ /// <summary>Args: none.</summary>+ public const string PrisonerFood = "prisoner_food";+ /// <summary>Args: CauseKeys.Number(unfed).</summary>+ public const string PrisonerFoodShortage = "prisoner_food_shortage";+ /// <summary>Args: CauseKeys.Number(count).</summary>+ public const string CraftsmenReturned = "craftsmen_returned";+ /// <summary>Args: CauseKeys.Number(count).</summary>+ public const string CraftsmenReassigned = "craftsmen_reassigned";+ /// <summary>Args: city.</summary>+ public const string PioneerReturned = "pioneer_returned";+ /// <summary>Args: CauseKeys.Number(count); veteran ? "veteran" : "halutz".</summary>+ public const string PioneersReassigned = "pioneers_reassigned";+ /// <summary>Args: CauseKeys.Number(count); Training.CourseId(type); unit.HasValue ? CauseKeys.Number(unit.Value) : ""; CauseKeys.Number(cost).</summary>+ public const string TrainingStarted = "training_started";+ /// <summary>Args: city; Training.CourseId(type).</summary>+ public const string TrainingArms = "training_arms";+ /// <summary>Args: CauseKeys.Number(k.Count); Training.CourseId(type).</summary>+ public const string TrainingCancelled = "training_cancelled";+ /// <summary>Args: k.City; Training.CourseId(type).</summary>+ public const string TrainingArmsReturned = "training_arms_returned";+ /// <summary>Args: CauseKeys.Number(aim).</summary>+ public const string ReplacementsStopped = "replacements_stopped";+ /// <summary>Args: CauseKeys.Number(k.Count); Training.CourseId(type); CauseKeys.Number(target.Id).</summary>+ public const string ReplacementsJoined = "replacements_joined";+ /// <summary>Args: CauseKeys.Number(k.Count); Training.CourseId(type); type.Class == Combat.ArtilleryClass ? "artillery" : type.Class == Armour ? "armour" : "recruit".</summary>+ public const string MilitaryTrained = "military_trained";+ /// <summary>Args: CauseKeys.Number(k.Count); Training.CourseId(type).</summary>+ public const string PioneersTrained = "pioneers_trained";+ /// <summary>Args: CauseKeys.Number(k.Count); Training.CourseId(type).</summary>+ public const string CraftsmenTrained = "craftsmen_trained";+ /// <summary>Args: person.Id; office.TitleHeOn(person, s.Date); displaced?.Id ?? "".</summary>+ public const string Appointed = "appointed";+ /// <summary>Args: oldParty; displaced.Id; sameParty ? "same" : "other"; office.Title; office.TitleHeOn(displaced, s.Date).</summary>+ public const string Reshuffle = "reshuffle";+ /// <summary>Args: none.</summary>+ public const string AppointmentsEnded = "appointments_ended";+ /// <summary>Args: none.</summary>+ public const string ApprovalStability = "approval_stability";+ /// <summary>Args: none.</summary>+ public const string CoalitionCollapsed = "coalition_collapsed";+ /// <summary>Args: CauseKeys.Number(seats); CauseKeys.Number(size).</summary>+ public const string LegislatureConvened = "legislature_convened";+ /// <summary>Args: string.Join("|", g1!.CoalitionOn(g1.From)).</summary>+ public const string GovernmentTookOffice = "government_took_office";+ /// <summary>Args: string.Join("|", ch.Leaves); string.Join("|", ch.Joins); CauseKeys.Number(seats); CauseKeys.Number(size).</summary>+ public const string CoalitionChanged = "coalition_changed";+ /// <summary>Args: none.</summary>+ public const string EraEnded = "era_ended";+ /// <summary>Args: legislature.Id; CauseKeys.Number(p.Level).</summary>+ public const string AdvisoryPolicyRejected = "advisory_policy_rejected";+ /// <summary>Args: legislature.Id; CauseKeys.Number(p.Level).</summary>+ public const string PolicyRejected = "policy_rejected";+ /// <summary>Args: none.</summary>+ public const string PolicySet = "policy_set";+ /// <summary>Args: Offices.Legislature(c, s.Date)!.Id.</summary>+ public const string AdvisoryBudgetRejected = "advisory_budget_rejected";+ /// <summary>Args: Offices.Legislature(c, s.Date)!.Id.</summary>+ public const string BudgetRejected = "budget_rejected";+ /// <summary>Args: fled ? "1" : "0".</summary>+ public const string PlaceCaptured = "place_captured";+ /// <summary>Args: record.Fled ? "1" : "0".</summary>+ public const string EnemyRegained = "enemy_regained";+ /// <summary>Args: x.Fled ? "1" : "0".</summary>+ public const string PlaceAnnexed = "place_annexed";+ /// <summary>Args: moved.Count > 0 ? "1" : "0"; residentsFled ? "1" : "0".</summary>+ public const string PlaceWithdrawn = "place_withdrawn";+ /// <summary>Args: none.</summary>+ public const string PlaceDeported = "place_deported";+ /// <summary>Args: id.</summary>+ public const string DeportEffect = "deport_effect";+ /// <summary>Args: id.</summary>+ public const string DeportCost = "deport_cost";+ /// <summary>Args: x.Fled ? "1" : "0".</summary>+ public const string OccupationStarted = "occupation_started";+ /// <summary>Args: none.</summary>+ public const string PendingBecameRaid = "pending_became_raid";+ /// <summary>Args: x.Fled ? "1" : "0".</summary>+ public const string OccupationLostUnit = "occupation_lost_unit";+ /// <summary>Args: none.</summary>+ public const string OccupationCountdown = "occupation_countdown";+ /// <summary>Args: none.</summary>+ public const string DepopulationSupport = "depopulation_support";+/// <summary>What a <see cref="Borrowed"/> line borrowed for (EconomySystem.PayOrBorrow's callers, and the deficit).</summary>public static class Purpose{@@ -107,6 +238,7 @@ namespace Statecraft.SimEventNew, EventChosen, EventDelegated, EventDelegatedPartial, EventAmount, EventStock, EventGrant, EventCity,EventUnlock, EventPolicy, EventSetRung, EventRejoin, MilitaryUpkeep,ObjectiveCompleted, PrisonersReturned, SoldiersReturned,+ WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ArmsBought, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,};/// <summary>A number as an Arg: invariant and round-trip, so the UI rounds exactly the value Message rounded.</summary>diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex e7e81a296..2193ba5c2 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -73,7 +73,7 @@ namespace Statecraft.Sim? FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.JobSlots} jobs"): FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.Civilians + x.Craftsmen} civilians and craftsmen");s.Cities[city] = x.WithCounts(x.Civilians, count, x.Refugees).WithJobsDefault(false);- why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {count} groups in work")));+ why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {count} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(count) }));return null;}@@ -88,7 +88,7 @@ namespace Statecraft.Simvar craftsmen = Math.Min(x.Craftsmen, x.Employed);var paid = ((x.Employed - craftsmen) + craftsmen * r.CraftsmanIncomeMultiple) * r.IncomePerJobPerYear * yearFraction;s.Treasury += paid;- why.Add(new Cause("city", x.Id, paid, $"{PlayerText.Settlement(c, x.Id)}: jobs paid {PlayerText.MoneyChange(c, "treasury", paid)}"));+ why.Add(new Cause("city", x.Id, paid, $"{PlayerText.Settlement(c, x.Id)}: jobs paid {PlayerText.MoneyChange(c, "treasury", paid)}", key: CauseKeys.WagesPaid));}}@@ -134,11 +134,11 @@ namespace Statecraft.Simvar absorbed = x.Refugees == 0 ? 0 : Math.Min(x.Refugees, (int)Math.Floor(x.Refugees * m));var housed = absorbed == 0 ? x : x.WithCounts(x.Civilians + absorbed, x.Employed, x.Refugees - absorbed);if (absorbed != 0)- why.Add(new Cause("city", x.Id, absorbed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed")));+ why.Add(new Cause("city", x.Id, absorbed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed"), key: CauseKeys.ImmigrantsHoused, args: new[] { CauseKeys.Number(absorbed) }));var work = MaxWorkers(housed);if (housed.JobsDefault && work != housed.Employed){- why.Add(new Cause("city", x.Id, work - housed.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {work} groups in work")));+ why.Add(new Cause("city", x.Id, work - housed.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {work} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(work) }));housed = housed.WithCounts(housed.Civilians, work, housed.Refugees);}s.Cities[x.Id] = housed;@@ -204,7 +204,7 @@ namespace Statecraft.Simif (over == 0) continue;if (x.Condition is double now)s.Cities[x.Id] = x.WithCondition(Math.Max(0.0, now - r.OverflowConditionLoss!.Value * over / Housed(s, x)));- why.Add(new Cause("city", x.Id, over, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold")));+ why.Add(new Cause("city", x.Id, over, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold"), key: CauseKeys.HousingShortage, args: new[] { CauseKeys.Number(over) }));}}@@ -238,7 +238,7 @@ namespace Statecraft.Simif (added == 0) continue;var x = s.Cities[kv.Key];s.Cities[x.Id] = x.WithCounts(x.Civilians, x.Employed, x.Refugees + added);- why.Add(new Cause("city", x.Id, added, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {added} groups of immigrants arrived and wait for homes")));+ why.Add(new Cause("city", x.Id, added, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {added} groups of immigrants arrived and wait for homes"), key: CauseKeys.ImmigrantsWaiting, args: new[] { CauseKeys.Number(added) }));}}diff --git a/sim/Statecraft.Sim/Corridors.cs b/sim/Statecraft.Sim/Corridors.csindex 7f8b6ff71..bda92c408 100644--- a/sim/Statecraft.Sim/Corridors.cs+++ b/sim/Statecraft.Sim/Corridors.cs@@ -64,7 +64,7 @@ namespace Statecraft.Sims.Corridors[def.Id] = work == null? new CorridorWork(def.Id, Enumerable.Range(0, def.Segments.Count).Select(i => i == index ? started : null).ToArray()): work.With(index, started)!;- why.Add(new Cause("map", def.Id, 1, $"{name}: a group of halutzim began building, cost {PlayerText.Money(c, "treasury", cost)}"));+ why.Add(new Cause("map", def.Id, 1, $"{name}: a group of halutzim began building, cost {PlayerText.Money(c, "treasury", cost)}", key: CauseKeys.CorridorStarted, args: new[] { def.Id, CauseKeys.Number(n), CauseKeys.Number(cost) }));return null;}@@ -77,7 +77,7 @@ namespace Statecraft.Simvar rest = work.With(index, null);if (rest == null) s.Corridors.Remove(work.Id); else s.Corridors[work.Id] = rest;var def = c.Corridors.First(x => x.Id == work.Id);- why.Add(new Cause("map", work.Id, -1, $"{SegmentName(def, index)}: the halutzim stopped building; the Money spent is not returned"));+ why.Add(new Cause("map", work.Id, -1, $"{SegmentName(def, index)}: the halutzim stopped building; the Money spent is not returned", key: CauseKeys.CorridorCancelled, args: new[] { def.Id, CauseKeys.Number(index + 1) }));return true;}@@ -108,14 +108,14 @@ namespace Statecraft.Simelse{cur = cur.With(i, new SegmentWork(null, progress, next))!;- why.Add(new Cause("map", w.Id, 1, $"{SegmentName(def, i)} built"));+ why.Add(new Cause("map", w.Id, 1, $"{SegmentName(def, i)} built", key: CauseKeys.CorridorCompleted, args: new[] { def.Id, CauseKeys.Number(i + 1) }));}// R-VET-001: the segment progressed this turn, so a halutz serves a turn; a veteran counts no further.if (u.Type != "halutz") continue;var service = u.Service + 1;var promoted = service >= r.VeteranHalutzService!.Value;s.Units[u.Id] = new Unit(u.Id, promoted ? Projects.VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);- if (promoted) why.Add(new Cause("map", w.Id, 1, "A group of halutzim became veteran pioneers"));+ if (promoted) why.Add(new Cause("map", w.Id, 1, "A group of halutzim became veteran pioneers", key: CauseKeys.PioneersVeteran));}s.Corridors[w.Id] = cur;}diff --git a/sim/Statecraft.Sim/MapActions.cs b/sim/Statecraft.Sim/MapActions.csindex 120d34f2e..18c2a65de 100644--- a/sim/Statecraft.Sim/MapActions.cs+++ b/sim/Statecraft.Sim/MapActions.cs@@ -111,13 +111,13 @@ namespace Statecraft.Simif (s.Treasury < 0){s.Debt += -s.Treasury;- why.Add(new Cause("economy", "debt", -s.Treasury, $"borrowed {PlayerText.Money(c, "debt", -s.Treasury)} to build {PlayerText.MapAction(c, action)}"));+ why.Add(new Cause("economy", "debt", -s.Treasury, $"borrowed {PlayerText.Money(c, "debt", -s.Treasury)} to build {PlayerText.MapAction(c, action)}", key: CauseKeys.MapBorrowed, args: new[] { action }));s.Treasury = 0;}var housing = rule.Housing == 0 ? 0 : EffectsSystem.Shift(c, s, "housing", rule.Housing);var morale = rule.Morale == 0 ? 0 : EffectsSystem.Shift(c, s, "morale", rule.Morale);why.Add(new Cause("map", action, 1, FormattableString.Invariant(- $"Built {PlayerText.MapAction(c, action)}: cost {PlayerText.Money(c, "treasury", rule.Cost)}, {PlayerText.Change(c, "housing", housing)}, {PlayerText.Change(c, "morale", morale)}")));+ $"Built {PlayerText.MapAction(c, action)}: cost {PlayerText.Money(c, "treasury", rule.Cost)}, {PlayerText.Change(c, "housing", housing)}, {PlayerText.Change(c, "morale", morale)}"), key: CauseKeys.MapBuilt, args: new[] { CauseKeys.Number(rule.Cost), CauseKeys.Number(housing), CauseKeys.Number(morale) }));return null;}}diff --git a/sim/Statecraft.Sim/Military.cs b/sim/Statecraft.Sim/Military.csindex 5ec64c769..d6fd7a60a 100644--- a/sim/Statecraft.Sim/Military.cs+++ b/sim/Statecraft.Sim/Military.cs@@ -18,7 +18,7 @@ namespace Statecraft.Simvar veteran = service >= r.VeteranSoldierService!.Value;s.Units[u.Id] = new Unit(u.Id, veteran ? "veteran_soldier" : u.Type, u.Q, u.R, service,u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);- if (veteran) why.Add(new Cause("city", "units", u.Strength, "Recruits became veteran soldiers"));+ if (veteran) why.Add(new Cause("city", "units", u.Strength, "Recruits became veteran soldiers", key: CauseKeys.RecruitsVeteran));}}diff --git a/sim/Statecraft.Sim/PoliticsSystem.cs b/sim/Statecraft.Sim/PoliticsSystem.csindex e058cc55c..48cb5261d 100644--- a/sim/Statecraft.Sim/PoliticsSystem.cs+++ b/sim/Statecraft.Sim/PoliticsSystem.cs@@ -36,13 +36,13 @@ namespace Statecraft.Simvar old = s.CoalitionStability;s.CoalitionStability = old + (EffectsSystem.Approval(c, s) - old) * Math.Min(1.0, yearFraction * 2);if (Math.Abs(s.CoalitionStability - old) > 1e-9)- why.Add(new Cause("politics", "coalition_stability", s.CoalitionStability - old, $"coalition stability {PlayerText.PercentChange(s.CoalitionStability - old)} (public approval)"));+ why.Add(new Cause("politics", "coalition_stability", s.CoalitionStability - old, $"coalition stability {PlayerText.PercentChange(s.CoalitionStability - old)} (public approval)", key: CauseKeys.ApprovalStability));// R-GOV-001: in the GDD loop the coalition stays, but it can no longer end the game (D-C5; D-B5, "Coalition// collapse is off in the MVP"). The legacy loop keeps its collapse while the legacy code exists (D-E1).if (!c.IsGdd && s.CoalitionStability < CollapseBelow && s.GameOver == null){s.GameOver = GameOverCodes.CoalitionCollapse;- why.Add(new Cause("politics", "game_over", 0, "The coalition collapsed. Your premiership is over."));+ why.Add(new Cause("politics", "game_over", 0, "The coalition collapsed. Your premiership is over.", key: CauseKeys.CoalitionCollapsed));}}@@ -53,12 +53,12 @@ namespace Statecraft.Sim{var (seats, size) = CoalitionSeats(c, to);var elected = l1.Elected.HasValue ? $", elected {PlayerText.Date(l1.Elected.Value)}" : "";- why.Add(new Cause("politics", l1.Id, 0, FormattableString.Invariant($"{l1.Body} convened ({l1.Size} seats{elected}); coalition holds {seats}/{size}")));+ why.Add(new Cause("politics", l1.Id, 0, FormattableString.Invariant($"{l1.Body} convened ({l1.Size} seats{elected}); coalition holds {seats}/{size}"), key: CauseKeys.LegislatureConvened, args: new[] { CauseKeys.Number(seats), CauseKeys.Number(size) }));}var g0 = Offices.Government(c, from); var g1 = Offices.Government(c, to);var tookOffice = g1 != null && g1 != g0;var reported = false;- void TookOffice() { reported = true; why.Add(new Cause("politics", g1!.Id, 0, $"{g1.Name} took office ({string.Join(", ", PartyNames(c, g1.CoalitionOn(g1.From)))})")); }+ void TookOffice() { reported = true; why.Add(new Cause("politics", g1!.Id, 0, $"{g1.Name} took office ({string.Join(", ", PartyNames(c, g1.CoalitionOn(g1.From)))})", key: CauseKeys.GovernmentTookOffice, args: new[] { string.Join("|", g1!.CoalitionOn(g1.From)) })); }// Changes inside a term, in date order; a government taking office comes before the changes dated on or after its start.var changes = c.Governments.SelectMany(g => g.CoalitionChanges.Select(ch => (g, ch))).Where(x => x.ch.Date > from && x.ch.Date <= to).OrderBy(x => x.ch.Date);@@ -69,7 +69,7 @@ namespace Statecraft.Simvar what = new List<string>();if (ch.Leaves.Count > 0) what.Add($"{string.Join(", ", PartyNames(c, ch.Leaves))} left the coalition");if (ch.Joins.Count > 0) what.Add($"{string.Join(", ", PartyNames(c, ch.Joins))} joined the coalition");- why.Add(new Cause("politics", g.Id, 0, FormattableString.Invariant($"{string.Join("; ", what)} (coalition holds {seats}/{size})")));+ why.Add(new Cause("politics", g.Id, 0, FormattableString.Invariant($"{string.Join("; ", what)} (coalition holds {seats}/{size})"), key: CauseKeys.CoalitionChanged, args: new[] { string.Join("|", ch.Leaves), string.Join("|", ch.Joins), CauseKeys.Number(seats), CauseKeys.Number(size) }));}if (tookOffice && !reported) TookOffice();}diff --git a/sim/Statecraft.Sim/Pools.cs b/sim/Statecraft.Sim/Pools.csindex 52c785be0..5b4c466d9 100644--- a/sim/Statecraft.Sim/Pools.cs+++ b/sim/Statecraft.Sim/Pools.cs@@ -47,7 +47,7 @@ namespace Statecraft.Simvar cost = count * c.RulesAt(s.Date).Mvp!.ArmsPrice!.Value;EconomySystem.PayOrBorrow(c, s, cost, "for Arms", why, CauseKeys.Purpose.Arms);s.Arms += count;- why.Add(new Cause("economy", "arms", count, FormattableString.Invariant($"Bought {count} Arms, cost {PlayerText.Money(c, "treasury", cost)}")));+ why.Add(new Cause("economy", "arms", count, FormattableString.Invariant($"Bought {count} Arms, cost {PlayerText.Money(c, "treasury", cost)}"), key: CauseKeys.ArmsBought, args: new[] { CauseKeys.Number(cost) }));return null;}@@ -66,7 +66,7 @@ namespace Statecraft.Sim{if (!(s.Sites.TryGetValue(f.Id, out var w) && w.BuiltOn != null)) continue;s.Food += yield;- why.Add(new Cause("economy", "food", yield, FormattableString.Invariant($"{f.Name}: the plowed land yielded {yield} units of Food")));+ why.Add(new Cause("economy", "food", yield, FormattableString.Invariant($"{f.Name}: the plowed land yielded {yield} units of Food"), key: CauseKeys.FoodHarvest, args: new[] { f.Id }));}}@@ -82,10 +82,10 @@ namespace Statecraft.Sims.FoodNeed = need;s.FoodUnmet = need - eaten;if (s.FoodUnmet > 0)- why.Add(new Cause("economy", "food", -s.FoodUnmet, FormattableString.Invariant($"Food ran out: {s.FoodUnmet} of {need} units of the month's need went unmet")));+ why.Add(new Cause("economy", "food", -s.FoodUnmet, FormattableString.Invariant($"Food ran out: {s.FoodUnmet} of {need} units of the month's need went unmet"), key: CauseKeys.FoodShortage, args: new[] { CauseKeys.Number(need) }));if (s.ActiveSituations.Contains(EconomySystem.FxCrisis)){- why.Add(new Cause("economy", "food", -eaten, FormattableString.Invariant($"No Food imported (foreign currency crisis): the stock fell to {s.Food} units")));+ why.Add(new Cause("economy", "food", -eaten, FormattableString.Invariant($"No Food imported (foreign currency crisis): the stock fell to {s.Food} units"), key: CauseKeys.FoodWithoutImports, args: new[] { CauseKeys.Number(s.Food) }));return;}var target = (long)r.CoverMonths!.Value * need;diff --git a/sim/Statecraft.Sim/Prisoners.cs b/sim/Statecraft.Sim/Prisoners.csindex b040ec60a..44f4a53fe 100644--- a/sim/Statecraft.Sim/Prisoners.cs+++ b/sim/Statecraft.Sim/Prisoners.cs@@ -63,12 +63,12 @@ namespace Statecraft.Sim{var eaten = (int)Math.Min(need, s.Food);s.Food -= eaten;- why.Add(new Cause("economy", "food", -eaten, FormattableString.Invariant($"The prisoners held ate {eaten} units of Food")));+ why.Add(new Cause("economy", "food", -eaten, FormattableString.Invariant($"The prisoners held ate {eaten} units of Food"), key: CauseKeys.PrisonerFood));var unfed = need - eaten;if (unfed > 0){var change = EffectsSystem.Shift(c, s, "morale", -unfed * r.PrisonerShortfallCohesion!.Value);- why.Add(new Cause("economy", "morale", change, FormattableString.Invariant($"The prisoners held went short of {unfed} units of Food: {PlayerText.Change(c, "morale", change)}")));+ why.Add(new Cause("economy", "morale", change, FormattableString.Invariant($"The prisoners held went short of {unfed} units of Food: {PlayerText.Change(c, "morale", change)}"), key: CauseKeys.PrisonerFoodShortage, args: new[] { CauseKeys.Number(unfed) }));}}var held = s.SoldiersHeld.Values.Sum();diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex 32b1b4408..fda649210 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -162,8 +162,8 @@ namespace Statecraft.Sim// (ProjectsTests.AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusFive).s.Sites[site] = new SiteWork(site, unit, turns, null);why.Add(plow || drain- ? new Cause("map", site, 1, $"{place.Name}: a group of halutzim began {(plow ? "plowing" : "draining the swamp")}, cost {PlayerText.Money(c, "treasury", cost)}")- : new Cause("map", site, 1, $"{place.Name}: a group of halutzim began building {(camp ? "a training camp" : "a yishuv")}, cost {PlayerText.Money(c, "treasury", cost)}"));+ ? new Cause("map", site, 1, $"{place.Name}: a group of halutzim began {(plow ? "plowing" : "draining the swamp")}, cost {PlayerText.Money(c, "treasury", cost)}", key: CauseKeys.LandWorkStarted, args: new[] { plow ? "plow" : "drain", CauseKeys.Number(cost) })+ : new Cause("map", site, 1, $"{place.Name}: a group of halutzim began building {(camp ? "a training camp" : "a yishuv")}, cost {PlayerText.Money(c, "treasury", cost)}", key: CauseKeys.SiteStarted, args: new[] { camp ? "camp" : "yishuv", CauseKeys.Number(cost) }));return null;}@@ -201,7 +201,7 @@ namespace Statecraft.Simvar work = s.Sites.Values.FirstOrDefault(w => w.BuiltOn == null && w.Unit == unit);if (work == null) return Corridors.Stop(c, s, unit, why) ? null : "That group of halutzim is not building anything";s.Sites.Remove(work.Site);- why.Add(new Cause("map", work.Site, -1, $"{PlayerText.Site(c, work.Site)}: the halutzim stopped building; the Money spent is not returned"));+ why.Add(new Cause("map", work.Site, -1, $"{PlayerText.Site(c, work.Site)}: the halutzim stopped building; the Money spent is not returned", key: CauseKeys.SiteCancelled));return null;}@@ -229,14 +229,14 @@ namespace Statecraft.Simelse{s.Sites[w.Site] = SiteWork.Built(w.Site, next);- why.Add(new Cause("map", w.Site, 1, $"{place.Name} {(IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : place.Kinds.Contains(SwampKind) ? "drained" : "founded")}"));+ why.Add(new Cause("map", w.Site, 1, $"{place.Name} {(IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : place.Kinds.Contains(SwampKind) ? "drained" : "founded")}", key: CauseKeys.SiteCompleted, args: new[] { IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : place.Kinds.Contains(SwampKind) ? "drained" : "founded" }));}// R-VET-001: the project progressed this turn, so a halutz serves a turn; a veteran counts no further.if (u.Type != "halutz") continue;var service = u.Service + 1;var promoted = service >= r.VeteranHalutzService!.Value;s.Units[u.Id] = new Unit(u.Id, promoted ? VeteranType : u.Type, u.Q, u.R, service, u.Side, u.Strength, u.Order, u.OrderTarget, u.HomeCity, u.Full);- if (promoted) why.Add(new Cause("map", w.Site, 1, "A group of halutzim became veteran pioneers"));+ if (promoted) why.Add(new Cause("map", w.Site, 1, "A group of halutzim became veteran pioneers", key: CauseKeys.PioneersVeteran));}Corridors.Advance(c, s, next, why); // R-COR-002: after the sites (Phase 4 PR 2)}@@ -322,7 +322,7 @@ namespace Statecraft.SimEconomySystem.PayOrBorrow(c, s, k.Cost, "to build " + k.Name, why, CauseKeys.Purpose.Project, k.Id);var id = s.NextId++;s.CityProjects.Add(id, new CityProject(id, kind, city, q, r, k.Turns));- why.Add(new Cause("city", city, 1, $"{name}: {k.Name} began, cost {PlayerText.Money(c, "treasury", k.Cost)}"));+ why.Add(new Cause("city", city, 1, $"{name}: {k.Name} began, cost {PlayerText.Money(c, "treasury", k.Cost)}", key: CauseKeys.ProjectStarted, args: new[] { kind, CauseKeys.Number(k.Cost) }));return null;}@@ -335,7 +335,7 @@ namespace Statecraft.Simvar k = c.ProjectKinds.First(x => x.Id == p.Kind);if (p.BuiltOn != null) return $"{PlayerText.Capitalised(k.Name)} is already built";s.CityProjects.Remove(project);- why.Add(new Cause("city", p.City, -1, $"{PlayerText.Settlement(c, p.City)}: {k.Name} was cancelled; the Money spent is not returned"));+ why.Add(new Cause("city", p.City, -1, $"{PlayerText.Settlement(c, p.City)}: {k.Name} was cancelled; the Money spent is not returned", key: CauseKeys.ProjectCancelled, args: new[] { k.Id }));return null;}@@ -359,7 +359,7 @@ namespace Statecraft.Simvar x = s.Cities[p.City];var condition = x.Condition is double now ? Math.Min(1.0, Math.Max(0.0, now + k.Condition)) : (double?)null;s.Cities[p.City] = new City(x.Id, x.HousingCapacity + k.Capacity, x.JobSlots + k.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits, condition, x.Craftsmen, x.JobsDefault, x.Qualified);- why.Add(new Cause("city", p.City, 1, $"{PlayerText.Settlement(c, p.City)}: {k.Name} was finished"));+ why.Add(new Cause("city", p.City, 1, $"{PlayerText.Settlement(c, p.City)}: {k.Name} was finished", key: CauseKeys.ProjectCompleted, args: new[] { k.Id }));}}}diff --git a/sim/Statecraft.Sim/Qualification.cs b/sim/Statecraft.Sim/Qualification.csindex 4a22860fa..9facbb4d0 100644--- a/sim/Statecraft.Sim/Qualification.cs+++ b/sim/Statecraft.Sim/Qualification.cs@@ -79,7 +79,7 @@ namespace Statecraft.Simif (count > x.Craftsmen) return FormattableString.Invariant($"{name} has {x.Craftsmen} craftsmen");s.Cities[city] = x.WithCraftsmen(x.Craftsmen - count).WithCounts(x.Civilians + count, x.Employed, x.Refugees).WithQualified(x.Qualified.WithCraftsmen(x.Qualified.Craftsmen + count));- why.Add(new Cause("city", city, count, $"{name}: {Groups(count)} of craftsmen returned to civilian life and keep their training"));+ why.Add(new Cause("city", city, count, $"{name}: {Groups(count)} of craftsmen returned to civilian life and keep their training", key: CauseKeys.CraftsmenReturned, args: new[] { CauseKeys.Number(count) }));return null;}@@ -97,7 +97,7 @@ namespace Statecraft.Simif (count > idle) return FormattableString.Invariant($"{name} has {idle} civilians without work");s.Cities[city] = x.WithCounts(x.Civilians - count, x.Employed, x.Refugees).WithCraftsmen(x.Craftsmen + count).WithQualified(x.Qualified.WithCraftsmen(x.Qualified.Craftsmen - count));- why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} of qualified craftsmen are craftsmen again"));+ why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} of qualified craftsmen are craftsmen again", key: CauseKeys.CraftsmenReassigned, args: new[] { CauseKeys.Number(count) }));return null;}@@ -124,7 +124,7 @@ namespace Statecraft.Simvar q = u.Type == Projects.VeteranType ? x.Qualified.WithVeterans(x.Qualified.Veterans + 1) : x.Qualified.AddHalutz(u.Service);s.Cities[city] = x.WithCounts(x.Civilians + 1, x.Employed, x.Refugees).WithQualified(q);why.Add(new Cause("map", unitId.ToString(CultureInfo.InvariantCulture), 1,- $"Unit {unitId} returned to civilian life in {PlayerText.Settlement(c, city)} and keeps its training"));+ $"Unit {unitId} returned to civilian life in {PlayerText.Settlement(c, city)} and keeps its training", key: CauseKeys.PioneerReturned, args: new[] { city }));return null;}@@ -156,7 +156,7 @@ namespace Statecraft.Sim}s.Cities[city] = x.WithCounts(x.Civilians - count, x.Employed, x.Refugees).WithQualified(veteran ? q.WithVeterans(q.Veterans - count) : q.TakeHalutzim(count));- why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} of qualified {(veteran ? "veteran pioneers" : "halutzim")} are units again"));+ why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} of qualified {(veteran ? "veteran pioneers" : "halutzim")} are units again", key: CauseKeys.PioneersReassigned, args: new[] { CauseKeys.Number(count), veteran ? "veteran" : "halutz" }));return null;}}diff --git a/sim/Statecraft.Sim/SettlementControl.cs b/sim/Statecraft.Sim/SettlementControl.csindex 9f689683d..ddb457491 100644--- a/sim/Statecraft.Sim/SettlementControl.cs+++ b/sim/Statecraft.Sim/SettlementControl.cs@@ -30,7 +30,7 @@ namespace Statecraft.Simvar fled = t.Residents == ContentLoader.Fled;s.Settlements[t.Id] = new SettlementControl(Movement.PlayerSide, AwaitingChoice, fled: fled);why.Add(new Cause("map", t.Id, 0, $"{c.SettlementNames[t.Id]} is captured: Israeli units hold it and no enemy unit is there. "- + (fled ? "Its residents fled. " : "") + "It awaits a decision"));+ + (fled ? "Its residents fled. " : "") + "It awaits a decision", key: CauseKeys.PlaceCaptured, args: new[] { fled ? "1" : "0" }));}}@@ -58,7 +58,7 @@ namespace Statecraft.Simif (Holder(s, t.Q, t.R) != Enemy || !s.Settlements.TryGetValue(t.Id, out var record) || record.State != AwaitingChoice) continue;Release(s, t.Id);why.Add(new Cause("map", t.Id, 0, $"{c.SettlementNames[t.Id]} is under enemy control again: enemy units hold it and no Israeli unit is there"- + (record.Fled ? ". " + FledLine : "")));+ + (record.Fled ? ". " + FledLine : ""), key: CauseKeys.EnemyRegained, args: new[] { record.Fled ? "1" : "0" }));}}@@ -198,7 +198,7 @@ namespace Statecraft.Sims.Settlements[id] = new SettlementControl(Movement.PlayerSide, Annexed, x.Since, x.Depopulated, x.Combatants, x.Buildings, 0, x.Fled);why.Add(new Cause("map", id, 0, x.Fled? $"{name} is annexed. Its residents fled when it was captured, so no people, homes or jobs are added"- : $"{name} is annexed. Its residents join the population"));+ : $"{name} is annexed. Its residents join the population", key: CauseKeys.PlaceAnnexed, args: new[] { x.Fled ? "1" : "0" }));return null;}@@ -218,12 +218,13 @@ namespace Statecraft.Simvar name = c.SettlementNames[id];var moved = new List<(Unit From, Unit To)>();if (MoveOut(c, s, t, name, atTheEnd, moved) is CaptureRefusal no) return no;+ var residentsFled = s.Settlements[id].Fled; // snapshot before Release removes the recordvar residents = Residents(s.Settlements[id]);Release(s, id);Withdrew(id, name, moved, why);why.Add(new Cause("map", id, 0, moved.Count > 0? $"{name}: Israeli units withdrew and it is under enemy control again. {residents}"- : $"{name} is under enemy control again. {residents}"));+ : $"{name} is under enemy control again. {residents}", key: CauseKeys.PlaceWithdrawn, args: new[] { moved.Count > 0 ? "1" : "0", residentsFled ? "1" : "0" }));return null;}@@ -288,15 +289,15 @@ namespace Statecraft.Sims.Settlements[id] = new SettlementControl(since: s.Settlements[id].Since, depopulated: true);s.DisplacedByPlayer++;Withdrew(id, name, moved, why);- why.Add(new Cause("map", id, 0, $"{name}: Deport. Its residents are displaced and the place is depopulated"));+ why.Add(new Cause("map", id, 0, $"{name}: Deport. Its residents are displaced and the place is depopulated", key: CauseKeys.PlaceDeported));var r = c.RulesAt(s.Date).Mvp!; // the loader requires both costs in the GDD loopforeach (var (indicator, cost) in new[] { ("morale", r.DeportCohesionCost!.Value), (SupportIndicator, r.DeportSupportCost!.Value) }){var change = EffectsSystem.Shift(c, s, indicator, -cost);- why.Add(new Cause("map", indicator, change, $"{PlayerText.Change(c, indicator, change)} (Deport of {name})"));+ why.Add(new Cause("map", indicator, change, $"{PlayerText.Change(c, indicator, change)} (Deport of {name})", key: CauseKeys.DeportEffect, args: new[] { id }));}// Deport never pays (owner, 22 October 2026, #1327): its Money stays at or below Occupy's and Raid's.- why.Add(new Cause("economy", "treasury", -r.DeportMoneyCost!.Value, $"{PlayerText.Change(c, "treasury", -r.DeportMoneyCost.Value)} (Deport of {name})"));+ why.Add(new Cause("economy", "treasury", -r.DeportMoneyCost!.Value, $"{PlayerText.Change(c, "treasury", -r.DeportMoneyCost.Value)} (Deport of {name})", key: CauseKeys.DeportCost, args: new[] { id }));EconomySystem.PayOrBorrow(c, s, r.DeportMoneyCost.Value, $"for the Deport of {name}", why, CauseKeys.Purpose.Deport, id);return null;}@@ -316,7 +317,7 @@ namespace Statecraft.Simvar x = s.Settlements[id];var turns = c.RulesAt(s.Date).Mvp!.OccupationTurns!.Value;s.Settlements[id] = new SettlementControl(x.Owner, Occupied, x.Since, x.Depopulated, x.Combatants, x.Buildings, turns, x.Fled);- why.Add(new Cause("map", id, turns, FormattableString.Invariant($"{name} is occupied for {turns} turns: an Israeli unit stays there. ") + Residents(x)));+ why.Add(new Cause("map", id, turns, FormattableString.Invariant($"{name} is occupied for {turns} turns: an Israeli unit stays there. ") + Residents(x), key: CauseKeys.OccupationStarted, args: new[] { x.Fled ? "1" : "0" }));return null;}@@ -337,7 +338,7 @@ namespace Statecraft.Sim{foreach (var id in s.Settlements.Where(kv => kv.Value.State == AwaitingChoice).Select(kv => kv.Key).ToList()) // ordinal{- why.Add(new Cause("map", id, 0, $"{c.SettlementNames[id]}: no decision was made before the end, so it counts as a raid"));+ why.Add(new Cause("map", id, 0, $"{c.SettlementNames[id]}: no decision was made before the end, so it counts as a raid", key: CauseKeys.PendingBecameRaid));Withdraw(c, s, id, why, true); // at the end it never refuses}}@@ -357,7 +358,7 @@ namespace Statecraft.Simif (!Garrisoned(s, c.SettlementTargets.First(t => t.Id == id))){Release(s, id);- why.Add(new Cause("map", id, 0, $"{name}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {Residents(x)}"));+ why.Add(new Cause("map", id, 0, $"{name}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {Residents(x)}", key: CauseKeys.OccupationLostUnit, args: new[] { x.Fled ? "1" : "0" }));continue;}EconomySystem.PayOrBorrow(c, s, r.OccupationUpkeepPerTurn!.Value, $"for the occupation of {name}", why, CauseKeys.Purpose.Occupation, id);@@ -366,7 +367,7 @@ namespace Statecraft.Sims.Settlements[id] = new SettlementControl(x.Owner, left == 0 ? AwaitingEnd : Occupied, x.Since, x.Depopulated, x.Combatants, x.Buildings, left, x.Fled);why.Add(new Cause("map", id, left, left == 0? $"{name}: the occupation period has ended. It awaits a decision"- : FormattableString.Invariant($"{name}: {left} turns of occupation left")));+ : FormattableString.Invariant($"{name}: {left} turns of occupation left"), key: CauseKeys.OccupationCountdown));}}@@ -377,7 +378,7 @@ namespace Statecraft.Sim{if (s.DisplacedByPlayer == 0) return;var change = EffectsSystem.Shift(c, s, SupportIndicator, -r.DeportSupportDragPerTurn!.Value * s.DisplacedByPlayer);- if (change != 0) why.Add(new Cause("map", SupportIndicator, change, $"{PlayerText.Change(c, SupportIndicator, change)} (the places depopulated by Deport)"));+ if (change != 0) why.Add(new Cause("map", SupportIndicator, change, $"{PlayerText.Change(c, SupportIndicator, change)} (the places depopulated by Deport)", key: CauseKeys.DepopulationSupport));}/// <summary>R-CTRL-020 (Q-DEP-7 (c), Q-SENS-2 (c)): whether (q, r) is the hex of a place the player has depopulated,diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.csindex 029e8a65c..4f903bb3c 100644--- a/sim/Statecraft.Sim/Simulation.cs+++ b/sim/Statecraft.Sim/Simulation.cs@@ -74,7 +74,7 @@ namespace Statecraft.Sim{// #19's legacy report is EndReport.For, which the end screen reads once GameOver is set (D-H4)s.GameOver = end == c.Eras[c.Eras.Count - 1].To ? GameOverCodes.EraEnded : GameOverCodes.MvpEnded;- why.Add(new Cause("era", s.GameOver, 0, PlayerText.GameOver(s.GameOver)));+ why.Add(new Cause("era", s.GameOver, 0, PlayerText.GameOver(s.GameOver), key: CauseKeys.EraEnded));}ContentWindows.Update(c, s, turnStart);Cabinet.ExpireOnGovernmentChange(c, s, why);@@ -179,15 +179,15 @@ namespace Statecraft.Simif (!PassVote(c, s)){if (Advisory(c, s))- why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted against {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}, but its vote does not bind"));+ why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted against {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}, but its vote does not bind", key: CauseKeys.AdvisoryPolicyRejected, args: new[] { legislature.Id, CauseKeys.Number(p.Level) }));else{- why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted down {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}"));+ why.Add(new Cause("politics", p.Policy, 0, $"{legislature.Body} voted down {PlayerText.Target(c, p.Policy)} at {PlayerText.Percent(p.Level)}", key: CauseKeys.PolicyRejected, args: new[] { legislature.Id, CauseKeys.Number(p.Level) }));return null;}}s.Policies[p.Policy] = p.Level;- why.Add(new Cause("policy", p.Policy, p.Level, $"{PlayerText.Target(c, p.Policy)} set to {PlayerText.Percent(p.Level)}"));+ why.Add(new Cause("policy", p.Policy, p.Level, $"{PlayerText.Target(c, p.Policy)} set to {PlayerText.Percent(p.Level)}", key: CauseKeys.PolicySet));return null;case AllocateBudget b:{@@ -198,11 +198,11 @@ namespace Statecraft.Simif (PoliticsSystem.BudgetNeedsVote(c, s.Date) && !PassVote(c, s)){if (Advisory(c, s))- why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted against the budget, but its vote does not bind"));+ why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted against the budget, but its vote does not bind", key: CauseKeys.AdvisoryBudgetRejected, args: new[] { Offices.Legislature(c, s.Date)!.Id }));else{s.Budget = old;- why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted the budget down"));+ why.Add(new Cause("politics", "budget", 0, $"{Offices.Legislature(c, s.Date)!.Body} voted the budget down", key: CauseKeys.BudgetRejected, args: new[] { Offices.Legislature(c, s.Date)!.Id }));}}return null;diff --git a/sim/Statecraft.Sim/Training.cs b/sim/Statecraft.Sim/Training.csindex cf9705547..e6e05556a 100644--- a/sim/Statecraft.Sim/Training.cs+++ b/sim/Statecraft.Sim/Training.cs@@ -32,6 +32,11 @@ namespace Statecraft.Simt.Class == Combat.ArtilleryClass ? "artillery training" : t.Class == Armour ? "armoured car training": t.Facility == "military_camp" ? "basic training" : t.Facility == Industry ? "craft training" : "pioneer training";+ /// <summary>The course of <see cref="Course"/> as a report Arg (#1682): the UI words it from why.cause.course.<id>.</summary>+ static string CourseId(UnitType t) =>+ t.Class == Combat.ArtilleryClass ? "artillery" : t.Class == Armour ? "armour"+ : t.Facility == "military_camp" ? "basic" : t.Facility == Industry ? "craft" : "pioneer";+/// <summary>The armoured car's class (R-UNIT-001).</summary>const string Armour = "armour";@@ -141,11 +146,11 @@ namespace Statecraft.Sim// T+3", open the cohort with type.TrainingTurns + 1 here; nothing else changes.s.Cohorts.Add(id, new Cohort(id, type.Id, city, count, type.TrainingTurns, (int)arms, unit));var aim = unit is int target ? FormattableString.Invariant($" as replacements for unit {target}") : "";- why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} began {Course(type)}{aim}, cost {PlayerText.Money(c, "treasury", cost)}"));+ why.Add(new Cause("city", city, -count, $"{name}: {Groups(count)} began {Course(type)}{aim}, cost {PlayerText.Money(c, "treasury", cost)}", key: CauseKeys.TrainingStarted, args: new[] { CauseKeys.Number(count), CourseId(type), unit.HasValue ? CauseKeys.Number(unit.Value) : "", CauseKeys.Number(cost) }));if (arms > 0){s.Arms -= (int)arms;- why.Add(new Cause("city", "arms", -arms, FormattableString.Invariant($"{name}: {Course(type)} took {arms} Arms")));+ why.Add(new Cause("city", "arms", -arms, FormattableString.Invariant($"{name}: {Course(type)} took {arms} Arms"), key: CauseKeys.TrainingArms, args: new[] { city, CourseId(type) }));}return null;}@@ -163,12 +168,12 @@ namespace Statecraft.Sims.Cohorts.Remove(cohort);var type = c.UnitTypes.First(t => t.Id == k.Type);why.Add(new Cause("city", k.City, k.Count,- $"{PlayerText.Settlement(c, k.City)}: {Groups(k.Count)} left {Course(type)}; the Money spent is not returned"));+ $"{PlayerText.Settlement(c, k.City)}: {Groups(k.Count)} left {Course(type)}; the Money spent is not returned", key: CauseKeys.TrainingCancelled, args: new[] { CauseKeys.Number(k.Count), CourseId(type) }));if (k.Arms > 0){var back = (int)Math.Min(k.Arms, (long)int.MaxValue - s.Arms); // the stock stops at int.MaxValue, as an event or a purchase leaves its.Arms += back;- why.Add(new Cause("city", "arms", back, FormattableString.Invariant($"{PlayerText.Settlement(c, k.City)}: {Course(type)} returned {back} Arms")));+ why.Add(new Cause("city", "arms", back, FormattableString.Invariant($"{PlayerText.Settlement(c, k.City)}: {Course(type)} returned {back} Arms"), key: CauseKeys.TrainingArmsReturned, args: new[] { k.City, CourseId(type) }));}return null;}@@ -189,7 +194,7 @@ namespace Statecraft.Simvar at = c.SettlementHexes.First(h => h.Id == k.City);if (!s.Units.TryGetValue(aim, out target) || (target.Q, target.R) != (at.Q, at.R)){- why.Add(new Cause("city", k.City, 0, FormattableString.Invariant($"{PlayerText.Settlement(c, k.City)}: unit {aim} is no longer in {PlayerText.Settlement(c, k.City)}, so its replacements stop training")));+ why.Add(new Cause("city", k.City, 0, FormattableString.Invariant($"{PlayerText.Settlement(c, k.City)}: unit {aim} is no longer in {PlayerText.Settlement(c, k.City)}, so its replacements stop training"), key: CauseKeys.ReplacementsStopped, args: new[] { CauseKeys.Number(aim) }));Cancel(c, s, k.Id, why);continue;}@@ -204,26 +209,26 @@ namespace Statecraft.Simvar strength = target.Strength + k.Count;s.Units[target.Id] = new Unit(target.Id, target.Type, target.Q, target.R, target.Service, target.Side, strength,target.Order, target.OrderTarget, target.HomeCity, strength >= target.Full ? 0 : target.Full);- why.Add(new Cause("city", k.City, k.Count, FormattableString.Invariant($"{name}: {Groups(k.Count)} finished {Course(type)} and joined unit {target.Id}")));+ why.Add(new Cause("city", k.City, k.Count, FormattableString.Invariant($"{name}: {Groups(k.Count)} finished {Course(type)} and joined unit {target.Id}"), key: CauseKeys.ReplacementsJoined, args: new[] { CauseKeys.Number(k.Count), CourseId(type), CauseKeys.Number(target.Id) }));}else if (type.Side != ""){var hex = c.SettlementHexes.First(h => h.Id == k.City);var id = s.NextId++;s.Units.Add(id, new Unit(id, type.Id, hex.Q, hex.R, side: type.Side, strength: k.Count, homeCity: k.City));- why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are {Trained(type)}"));+ why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are {Trained(type)}", key: CauseKeys.MilitaryTrained, args: new[] { CauseKeys.Number(k.Count), CourseId(type), type.Class == Combat.ArtilleryClass ? "artillery" : type.Class == Armour ? "armour" : "recruit" }));}else if (type.Kind == "unit"){var hex = c.SettlementHexes.First(h => h.Id == k.City); // every settlement has one (ValidateMap)for (int i = 0; i < k.Count; i++) { var id = s.NextId++; s.Units.Add(id, new Unit(id, type.Id, hex.Q, hex.R)); }- why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are halutzim"));+ why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are halutzim", key: CauseKeys.PioneersTrained, args: new[] { CauseKeys.Number(k.Count), CourseId(type) }));}else if (type.Id == Craftsman){var x = s.Cities[k.City];s.Cities[k.City] = x.WithCraftsmen(x.Craftsmen + k.Count);- why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are craftsmen"));+ why.Add(new Cause("city", k.City, k.Count, $"{name}: {Groups(k.Count)} finished {Course(type)} and are craftsmen", key: CauseKeys.CraftsmenTrained, args: new[] { CauseKeys.Number(k.Count), CourseId(type) }));}}}diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.csindex 891f1786f..94d90f7c5 100644--- a/sim/Statecraft.Sim/TurnResolver.cs+++ b/sim/Statecraft.Sim/TurnResolver.cs@@ -51,7 +51,7 @@ namespace Statecraft.Sims.ExhaustedTurns = s.Debt >= r.DebtCeiling!.Value && s.Food == 0 ? s.ExhaustedTurns + 1 : 0;if (s.ExhaustedTurns < r.DefeatTurns!.Value) return;s.GameOver = GameOverCodes.DefeatEconomy;- why.Add(new Cause("era", s.GameOver, s.ExhaustedTurns, PlayerText.GameOver(s.GameOver))); // the game's end, grouped with the MVP end+ why.Add(new Cause("era", s.GameOver, s.ExhaustedTurns, PlayerText.GameOver(s.GameOver), key: CauseKeys.EraEnded)); // the game's end, grouped with the MVP end}/// <summary>R-END-003: an enemy military unit holding the hex of one of the player's GDD cities at the turn's@@ -72,7 +72,7 @@ namespace Statecraft.Simif (u.Side == "" || u.Side == Movement.PlayerSide) continue; // not an enemy (Movement's reading of "the enemy")if (!cities.Contains((u.Q, u.R))) continue;s.GameOver = GameOverCodes.DefeatWar;- why.Add(new Cause("era", s.GameOver, u.Id, PlayerText.GameOver(s.GameOver))); // the game's end, grouped with the MVP end+ why.Add(new Cause("era", s.GameOver, u.Id, PlayerText.GameOver(s.GameOver), key: CauseKeys.EraEnded)); // the game's end, grouped with the MVP endreturn;}}diff --git a/unity/Assets/Scripts/UI/CauseText.cs b/unity/Assets/Scripts/UI/CauseText.csindex c2c5403d7..8c3d273c3 100644--- a/unity/Assets/Scripts/UI/CauseText.cs+++ b/unity/Assets/Scripts/UI/CauseText.cs@@ -19,6 +19,7 @@ namespace Statecraft.Game.UIpublic static string Line(Cause cause, Content c, IReadOnlyList<UnitEntry> rows, UiText text,IReadOnlyDictionary<string, string>? namesHe = null){+ if (RemainingKeys.Contains(cause.Key)) return Remaining(cause, c, text, namesHe);var key = "why.cause." + cause.Key;switch (cause.Key){@@ -80,6 +81,167 @@ namespace Statecraft.Game.UI}}+ // #1682: these branches use captured ids, values and resident flags, never the live GameState.+ static readonly HashSet<string> RemainingKeys = new HashSet<string>+ {+ CauseKeys.WorkersAssigned, CauseKeys.WagesPaid, CauseKeys.ImmigrantsHoused, CauseKeys.HousingShortage, CauseKeys.ImmigrantsWaiting, CauseKeys.RecruitsVeteran, CauseKeys.CorridorStarted, CauseKeys.CorridorCancelled, CauseKeys.CorridorCompleted, CauseKeys.PioneersVeteran, CauseKeys.MapBorrowed, CauseKeys.MapBuilt, CauseKeys.LandWorkStarted, CauseKeys.SiteStarted, CauseKeys.SiteCancelled, CauseKeys.SiteCompleted, CauseKeys.ProjectStarted, CauseKeys.ProjectCancelled, CauseKeys.ProjectCompleted, CauseKeys.ArmsBought, CauseKeys.FoodHarvest, CauseKeys.FoodShortage, CauseKeys.FoodWithoutImports, CauseKeys.PrisonerFood, CauseKeys.PrisonerFoodShortage, CauseKeys.CraftsmenReturned, CauseKeys.CraftsmenReassigned, CauseKeys.PioneerReturned, CauseKeys.PioneersReassigned, CauseKeys.TrainingStarted, CauseKeys.TrainingArms, CauseKeys.TrainingCancelled, CauseKeys.TrainingArmsReturned, CauseKeys.ReplacementsStopped, CauseKeys.ReplacementsJoined, CauseKeys.MilitaryTrained, CauseKeys.PioneersTrained, CauseKeys.CraftsmenTrained, CauseKeys.Appointed, CauseKeys.Reshuffle, CauseKeys.AppointmentsEnded, CauseKeys.ApprovalStability, CauseKeys.CoalitionCollapsed, CauseKeys.LegislatureConvened, CauseKeys.GovernmentTookOffice, CauseKeys.CoalitionChanged, CauseKeys.EraEnded, CauseKeys.AdvisoryPolicyRejected, CauseKeys.PolicyRejected, CauseKeys.PolicySet, CauseKeys.AdvisoryBudgetRejected, CauseKeys.BudgetRejected, CauseKeys.PlaceCaptured, CauseKeys.EnemyRegained, CauseKeys.PlaceAnnexed, CauseKeys.PlaceWithdrawn, CauseKeys.PlaceDeported, CauseKeys.DeportEffect, CauseKeys.DeportCost, CauseKeys.OccupationStarted, CauseKeys.PendingBecameRaid, CauseKeys.OccupationLostUnit, CauseKeys.OccupationCountdown, CauseKeys.DepopulationSupport+ };++ static string Remaining(Cause cause, Content c, UiText text, IReadOnlyDictionary<string, string>? namesHe)+ {+ string A(int i) => cause.Args[i];+ string Pick(string en, string he) => text["ui.lang"] == UiLanguage.Hebrew && he != "" ? he : en;+ string Settlement(string id) => ContentNames.Settlement(text, c, id, namesHe);+ string Site(string id) { var x = c.Sites.First(s => s.Id == id); return Pick(x.Name, x.NameHe); }+ string Groups(string count) => text["ui.lang"] == UiLanguage.Hebrew ? count+ : count == "1" ? "1 group" : count + " groups";+ string Course(string id) => text["why.cause.course." + id];+ string Residents(string fled) => text["why.cause.residents." + fled];+ string Parties(string ids) => string.Join(", ", ids.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)+ .Select(id => ContentNames.Of(text, c.Parties.First(x => x.Id == id))));+ string Coalition(string leaves, string joins) => string.Join("; ", new[] {+ leaves == "" ? "" : text.Format("why.cause.parties_left", Parties(leaves)),+ joins == "" ? "" : text.Format("why.cause.parties_joined", Parties(joins)) }.Where(x => x != ""));+ string Segment(string id, string number) { var x = c.Corridors.First(s => s.Id == id);+ return text.Format("why.cause.segment", Pick(x.Name, x.NameHe), number); }+ string Elected(Legislature x) => x.Elected.HasValue+ ? text.Format("why.cause.elected", text.Format("date.day_month_year", x.Elected.Value.Day, text["date.month_" + x.Elected.Value.Month.ToString(CultureInfo.InvariantCulture)], x.Elected.Value.Year)) : "";+ var key = "why.cause." + cause.Key;+ switch (cause.Key)+ {+ case CauseKeys.WorkersAssigned:+ return text.Format(key, Settlement(cause.Target), A(0));+ case CauseKeys.WagesPaid:+ return text.Format(key, Settlement(cause.Target), PlayerText.MoneyChange(c, "treasury", cause.Delta));+ case CauseKeys.ImmigrantsHoused:+ return text.Format(key, Settlement(cause.Target), A(0));+ case CauseKeys.HousingShortage:+ return text.Format(key, Settlement(cause.Target), A(0));+ case CauseKeys.ImmigrantsWaiting:+ return text.Format(key, Settlement(cause.Target), A(0));+ case CauseKeys.RecruitsVeteran:+ return text.Format(key);+ case CauseKeys.CorridorStarted:+ return text.Format(key, Segment(A(0), A(1)), Money(c, "treasury", A(2)));+ case CauseKeys.CorridorCancelled:+ return text.Format(key, Segment(A(0), A(1)));+ case CauseKeys.CorridorCompleted:+ return text.Format(key, Segment(A(0), A(1)));+ case CauseKeys.PioneersVeteran:+ return text.Format(key);+ case CauseKeys.MapBorrowed:+ return text.Format(key, PlayerText.Money(c, "debt", cause.Delta), text["info.map_action." + A(0)]);+ case CauseKeys.MapBuilt:+ return text.Format(key, text["info.map_action." + cause.Target], Money(c, "treasury", A(0)), Name(text, "housing"), Change(c, "housing", Number(A(1))), Name(text, "morale"), Change(c, "morale", Number(A(2))));+ case CauseKeys.LandWorkStarted:+ return text.Format(key, Site(cause.Target), text["why.cause.work." + A(0)], Money(c, "treasury", A(1)));+ case CauseKeys.SiteStarted:+ return text.Format(key, Site(cause.Target), text["why.cause.work." + A(0)], Money(c, "treasury", A(1)));+ case CauseKeys.SiteCancelled:+ return text.Format(key, Site(cause.Target));+ case CauseKeys.SiteCompleted:+ return text.Format(key, Site(cause.Target), text["why.cause.work." + A(0)]);+ case CauseKeys.ProjectStarted:+ return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))), Money(c, "treasury", A(1)));+ case CauseKeys.ProjectCancelled:+ return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));+ case CauseKeys.ProjectCompleted:+ return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));+ case CauseKeys.ArmsBought:+ return text.Format(key, cause.Delta, Money(c, "treasury", A(0)));+ case CauseKeys.FoodHarvest:+ return text.Format(key, Site(A(0)), cause.Delta);+ case CauseKeys.FoodShortage:+ return text.Format(key, -cause.Delta, A(0));+ case CauseKeys.FoodWithoutImports:+ return text.Format(key, A(0));+ case CauseKeys.PrisonerFood:+ return text.Format(key, -cause.Delta);+ case CauseKeys.PrisonerFoodShortage:+ return text.Format(key, A(0), Name(text, cause.Target), Change(c, cause.Target, cause.Delta));+ case CauseKeys.CraftsmenReturned:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));+ case CauseKeys.CraftsmenReassigned:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)));+ case CauseKeys.PioneerReturned:+ return text.Format(key, cause.Target, Settlement(A(0)));+ case CauseKeys.PioneersReassigned:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), text["why.cause.trained." + A(1)]);+ case CauseKeys.TrainingStarted:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)), A(2) == "" ? "" : text.Format("why.cause.replacements", A(2)), Money(c, "treasury", A(3)));+ case CauseKeys.TrainingArms:+ return text.Format(key, Settlement(A(0)), Course(A(1)), -cause.Delta);+ case CauseKeys.TrainingCancelled:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)));+ case CauseKeys.TrainingArmsReturned:+ return text.Format(key, Settlement(A(0)), Course(A(1)), cause.Delta);+ case CauseKeys.ReplacementsStopped:+ return text.Format(key, Settlement(cause.Target), A(0));+ case CauseKeys.ReplacementsJoined:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)), A(2));+ case CauseKeys.MilitaryTrained:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)), text["why.cause.trained." + A(2)]);+ case CauseKeys.PioneersTrained:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)));+ case CauseKeys.CraftsmenTrained:+ return text.Format(key, Settlement(cause.Target), Groups(A(0)), Course(A(1)));+ case CauseKeys.Appointed:+ return text.Format(key, ContentNames.Of(text, c.People.First(x => x.Id == A(0))), Pick(c.Offices.First(x => x.Id == cause.Target).Title, A(1)), A(2) == "" ? "" : text.Format("why.cause.replacing", ContentNames.Of(text, c.People.First(x => x.Id == A(2)))));+ case CauseKeys.Reshuffle:+ return text.Format(key, Change(c, cause.Target, cause.Delta), A(0) == "" ? ContentNames.Of(text, c.People.First(x => x.Id == A(1))) : ContentNames.Of(text, c.Parties.First(x => x.Id == A(0))), A(2) == "same" ? text["why.cause.resented"] : text.Format("why.cause.lost_office", Pick(A(3), A(4))));+ case CauseKeys.AppointmentsEnded:+ return text.Format(key);+ case CauseKeys.ApprovalStability:+ return text.Format(key, Change(c, cause.Target, cause.Delta));+ case CauseKeys.CoalitionCollapsed:+ return text.Format(key);+ case CauseKeys.LegislatureConvened:+ return text.Format(key, ContentNames.Of(text, c.Legislatures.First(x => x.Id == cause.Target)), c.Legislatures.First(x => x.Id == cause.Target).Size, Elected(c.Legislatures.First(x => x.Id == cause.Target)), A(0), A(1));+ case CauseKeys.GovernmentTookOffice:+ return text.Format(key, ContentNames.Of(text, c.Governments.First(x => x.Id == cause.Target)), Parties(A(0)));+ case CauseKeys.CoalitionChanged:+ return text.Format(key, Coalition(A(0), A(1)), A(2), A(3));+ case CauseKeys.EraEnded:+ return text.Format(key, text["why.cause.ending." + cause.Target]);+ case CauseKeys.AdvisoryPolicyRejected:+ return text.Format(key, ContentNames.Of(text, c.Legislatures.First(x => x.Id == A(0))), Name(text, cause.Target), PlayerText.Percent(Number(A(1))));+ case CauseKeys.PolicyRejected:+ return text.Format(key, ContentNames.Of(text, c.Legislatures.First(x => x.Id == A(0))), Name(text, cause.Target), PlayerText.Percent(Number(A(1))));+ case CauseKeys.PolicySet:+ return text.Format(key, Name(text, cause.Target), PlayerText.Percent(cause.Delta));+ case CauseKeys.AdvisoryBudgetRejected:+ return text.Format(key, ContentNames.Of(text, c.Legislatures.First(x => x.Id == A(0))));+ case CauseKeys.BudgetRejected:+ return text.Format(key, ContentNames.Of(text, c.Legislatures.First(x => x.Id == A(0))));+ case CauseKeys.PlaceCaptured:+ return text.Format(key, Settlement(cause.Target), A(0) == "1" ? text["why.cause.fled_capture"] : "");+ case CauseKeys.EnemyRegained:+ return text.Format(key, Settlement(cause.Target), A(0) == "1" ? ". " + Residents(A(0)) : "");+ case CauseKeys.PlaceAnnexed:+ return text.Format(key, Settlement(cause.Target), text["why.cause.annexed." + A(0)]);+ case CauseKeys.PlaceWithdrawn:+ return text.Format(key, Settlement(cause.Target), text["why.cause.withdrew." + A(0)], Residents(A(1)));+ case CauseKeys.PlaceDeported:+ return text.Format(key, Settlement(cause.Target));+ case CauseKeys.DeportEffect:+ return text.Format(key, Name(text, cause.Target), Change(c, cause.Target, cause.Delta), Settlement(A(0)));+ case CauseKeys.DeportCost:+ return text.Format(key, Name(text, cause.Target), Change(c, cause.Target, cause.Delta), Settlement(A(0)));+ case CauseKeys.OccupationStarted:+ return text.Format(key, Settlement(cause.Target), cause.Delta, Residents(A(0)));+ case CauseKeys.PendingBecameRaid:+ return text.Format(key, Settlement(cause.Target));+ case CauseKeys.OccupationLostUnit:+ return text.Format(key, Settlement(cause.Target), Residents(A(0)));+ case CauseKeys.OccupationCountdown:+ if (cause.Delta == 0) return text.Format(key + "_ended", Settlement(cause.Target));+ return text.Format(key, Settlement(cause.Target), cause.Delta);+ case CauseKeys.DepopulationSupport:+ return text.Format(key, Name(text, cause.Target), Change(c, cause.Target, cause.Delta));+ default: throw new InvalidOperationException("Unknown remaining Cause key: " + cause.Key);+ }+ }+static string Local(string english, string hebrew, UiText text) =>text["ui.lang"] == UiLanguage.Hebrew && hebrew != "" ? hebrew : english;diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.csindex 33a961f34..e8a99738e 100644--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs@@ -63,15 +63,31 @@ public class CauseTextTestspublic void EveryKeyedLineIsHebrewInHebrew(){var he = He; var seen = new HashSet<string>();+ // GameRoot passes the map's sourced Hebrew settlement names to every report renderer.+ var names = Statecraft.Game.Map.SettlementPlacer.Parse(System.IO.File.ReadAllText(+ System.IO.Path.Combine(Paths.Content, "map", "settlements_1948.yaml"))).ToDictionary(s => s.Id, s => s.NameHe);foreach (var turn in Turns())foreach (var w in turn.Why.Where(w => CauseKeys.All.Contains(w.Key))){- AssertHebrew(CauseText.Line(w, C, NoRows, he), w.Key);+ AssertHebrew(CauseText.Line(w, C, NoRows, he, names), w.Key);seen.Add(w.Key);}Assert.GreaterOrEqual(seen.Count, 8, "precondition: the game reaches most keys: " + string.Join(", ", seen));}+ [Test]+ public void MissingHebrewPlaceNamesKeepTheMarkedEnglishFallback()+ {+ var row = new Cause("city", "hadera", 0, "Hadera: jobs paid IL 0.0m", key: CauseKeys.WagesPaid);+ var missing = new Dictionary<string, string>();+ var line = CauseText.Line(row, C, NoRows, He);+ Assert.AreEqual(line, CauseText.Line(row, C, NoRows, He, missing));+ StringAssert.Contains(UiText.LeftToRightMark + "Hadera" + UiText.LeftToRightMark, line);+ StringAssert.Contains("תשלום מעבודה", line);+ var unmarked = Regex.Replace(line, UiText.LeftToRightMark + "[^" + UiText.LeftToRightMark + "]*" + UiText.LeftToRightMark, "");+ Assert.IsFalse(Regex.IsMatch(unmarked, "[A-Za-z]"));+ }+/// <summary>The keyed lines the seeded game does not reach: a call-up order, a situation that ends, civilian upkeep and/// its borrowing, the currency crisis on both sides, and the legacy loop's food cut and UN ceasefire.</summary>[Test]@@ -234,4 +250,241 @@ public class CauseTextTestsvar unmarked = Regex.Replace(line, UiText.LeftToRightMark + "[^" + UiText.LeftToRightMark + "]*" + UiText.LeftToRightMark, "");Assert.IsFalse(Regex.IsMatch(unmarked, "[A-Za-z]"), $"{key}: '{line}' has Latin text outside a marked value");}++ // Synthetic identities/titles are fixture text, native-review-pending; no content record is edited.+ [Test]+ public void ActualAppointmentRowsKeepDatedTitlesAfterHolderAndDateChange()+ {+ var c = RemainingFixture();+ var date = new DateTime(1948, 5, 15);+ c.Governments[0].From = date.AddDays(-1);+ c.Governments[0].Coalition.Add("party");+ c.Rules.AppointStabilityCostOtherParty = 0.1;+ c.Rules.AppointStabilityCostSameParty = 0.03;+ var office = c.Offices[0];+ office.TitleHe = "תפקיד קודם"; office.TitleHeFrom = date; office.TitleHeUntil = date.AddDays(1);+ c.People[1].Offices.Add(new OfficeTerm { Office = office.Id, From = date.AddDays(-1) });+ c.People[0].Party = "party";+ c.People.Add(new Person { Id = "next", Name = "Next", NameHe = "הבא", Party = "party" });+ var s = new GameState { Date = date, CoalitionStability = 1 };+ var why = new List<Cause>();+ Assert.IsNull(Cabinet.Appoint(c, s, office.Id, "person", why));+ Assert.IsNull(Cabinet.Appoint(c, s, office.Id, "next", why));+ var appointments = why.Where(x => x.Key == "appointed").ToArray();+ var reshuffles = why.Where(x => x.Key == "reshuffle").ToArray();+ Assert.AreEqual(2, appointments.Length); Assert.AreEqual(2, reshuffles.Length);+ CollectionAssert.AreEqual(new[] { "person", "תפקיד קודם", "former" }, appointments[0].Args);+ CollectionAssert.AreEqual(new[] { "", "former", "other", "Office", "תפקיד קודם" }, reshuffles[0].Args);+ CollectionAssert.AreEqual(new[] { "party", "person", "same", "Office", "תפקיד קודם" }, reshuffles[1].Args);+ Assert.AreEqual("Person appointed Office, replacing Former", appointments[0].Message);+ s.Date = date.AddDays(2); office.TitleHe = "תפקיד חדש";+ Assert.AreEqual("next", Cabinet.Holder(c, s, office.Id)!.Id);+ foreach (var row in why)+ {+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, En), row.Key);+ var he = CauseText.Line(row, c, NoRows, He);+ AssertHebrew(he, row.Key);+ StringAssert.DoesNotContain("תפקיד חדש", he);+ if (row.Key == "appointed" || row.Args[2] == "other") StringAssert.Contains("תפקיד קודם", he);+ }+ }++ [TestCase(false)] [TestCase(true)]+ public void ActualResidentRowsRenderAfterSettlementRecordsAreRemoved(bool fled)+ {+ // Existing CaptureDialog fixture pattern: real rules/map, synthetic capture eligibility and resident facts.+ var events = System.IO.Directory.GetFiles(System.IO.Path.Combine(Paths.Content, "events"), "*.yaml")+ .Select(f => "events/" + System.IO.Path.GetFileName(f));+ var c = ContentLoader.Load(rel => {+ var path = System.IO.Path.Combine(Paths.Content, rel);+ if (!System.IO.File.Exists(path)) return null;+ if (rel == "settlement_targets.yaml") return "targets:\n - { id: lod, q: -3, r: 21, operation: Fixture, sources: [{ url: \"https://example.org/fixture\", checked: 2026-10-21 }], residents: stayed, residents_sources: [{ url: \"https://example.org/fixture\", checked: 2026-10-21 }], annexation: { people: { value: 60, status: sourced, date: 1948-11-08, sources: [{ url: \"https://example.org/fixture\", checked: 2026-10-21 }] }, employed_share: { value: 0.5, status: design } }, status: draft }\n";+ return System.IO.File.ReadAllText(path);+ }, events);+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);+ s.Units.Clear(); s.Units.Add(100, new Unit(100, "veteran_soldier", -3, 21, side: Movement.PlayerSide, strength: 3));+ s.Settlements["lod"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingChoice, s.Date, fled: fled);+ // Preview shares RunOrders with Step and invokes the real producers, without unrelated monthly effects.+ var occupied = Simulation.Preview(c, s, new Command[] { new ResolveCapture("lod", SettlementControl.Occupy) });+ Assert.IsEmpty(occupied.Rejected);+ var why = new List<Cause> { occupied.Why.Single(x => x.Key == "occupation_started") };+ s = occupied.State;+ s.Settlements["lod"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingEnd, s.Date, fled: fled);+ s.Cities.Remove("lod");+ var annexed = Simulation.Preview(c, s, new Command[] { new EndOccupation("lod", SettlementControl.Annex) });+ Assert.IsEmpty(annexed.Rejected);+ why.Add(annexed.Why.Single(x => x.Key == "place_annexed"));+ annexed.State.Settlements.Clear();+ Assert.AreEqual(2, why.Count);+ CollectionAssert.AreEqual(new[] { "occupation_started", "place_annexed" }, why.Select(x => x.Key));+ s.Settlements.Clear();+ var names = new Dictionary<string, string> { ["lod"] = "לוד" };+ foreach (var row in why)+ {+ CollectionAssert.AreEqual(new[] { fled ? "1" : "0" }, row.Args);+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, En), row.Key);+ var he = CauseText.Line(row, c, NoRows, He, names);+ AssertHebrew(he, row.Key);+ StringAssert.Contains(fled ? "נמלטו" : row.Key == "place_annexed" ? "מצטרפים" : "לא השתנה", he);+ }+ }++ // #1682 synthetic content is deliberately not historical. These values exercise every new formatter branch,+ // including large counts, money rounding and Hebrew names. Actual producer metadata is gated in managed tests.+ static Content RemainingFixture() => new Content+ {+ Money = new List<MoneyAccount> { new MoneyAccount { Id = "treasury", Name = "Money", Prefix = "IL " }, new MoneyAccount { Id = "debt", Name = "Debt", Prefix = "IL " } },+ SettlementNames = new Dictionary<string, string> { ["town"] = "Town" },+ Sites = new List<Site> { new Site { Id = "site", Name = "Site", NameHe = "אתר" } },+ Corridors = new List<CorridorDef> { new CorridorDef { Id = "road", Name = "Road", NameHe = "דרך" } },+ ProjectKinds = new List<ProjectKind> { new ProjectKind { Id = "housing", Name = "Housing", NameHe = "דיור" } },+ People = new List<Person> { new Person { Id = "person", Name = "Person", NameHe = "אדם" }, new Person { Id = "former", Name = "Former", NameHe = "קודם" } },+ Offices = new List<Office> { new Office { Id = "office", Title = "Office", TitleHe = "תפקיד נוכחי" } },+ Parties = new List<Party> { new Party { Id = "party", Name = "Party", NameHe = "מפלגה" }, new Party { Id = "other", Name = "Other", NameHe = "אחרת" } },+ Governments = new List<Government> { new Government { Id = "gov", Name = "Government", NameHe = "ממשלה" } },+ Legislatures = new List<Legislature> { new Legislature { Id = "leg", Body = "Body", BodyHe = "מועצה", Size = 120, Elected = new DateTime(1948, 5, 15) } },+ };++ static Cause[] RemainingRows() => new[]+ {+ new Cause("draft", "town", 1, "Town: 2000000000 groups in work", key: CauseKeys.WorkersAssigned, args: new[] { "2000000000" }),+ new Cause("draft", "town", 1.25, "Town: jobs paid IL +1.3m", key: CauseKeys.WagesPaid),+ new Cause("draft", "town", 3, "Town: 3 groups of immigrants housed", key: CauseKeys.ImmigrantsHoused, args: new[] { "3" }),+ new Cause("draft", "town", 3, "Town: 3 groups more than its homes hold", key: CauseKeys.HousingShortage, args: new[] { "3" }),+ new Cause("draft", "town", 3, "Town: 3 groups of immigrants arrived and wait for homes", key: CauseKeys.ImmigrantsWaiting, args: new[] { "3" }),+ new Cause("draft", "units", 3, "Recruits became veteran soldiers", key: CauseKeys.RecruitsVeteran),+ new Cause("draft", "road", 1, "Road, segment 2: a group of halutzim began building, cost IL 1.3m", key: CauseKeys.CorridorStarted, args: new[] { "road", "2", "1.25" }),+ new Cause("draft", "road", -1, "Road, segment 2: the halutzim stopped building; the Money spent is not returned", key: CauseKeys.CorridorCancelled, args: new[] { "road", "2" }),+ new Cause("draft", "road", 1, "Road, segment 2 built", key: CauseKeys.CorridorCompleted, args: new[] { "road", "2" }),+ new Cause("draft", "site", 1, "A group of halutzim became veteran pioneers", key: CauseKeys.PioneersVeteran),+ new Cause("draft", "debt", 1.25, "Borrowed IL 1.3m to build a housing project", key: CauseKeys.MapBorrowed, args: new[] { "housing" }),+ new Cause("draft", "housing", 1, "Built a housing project: cost IL 1.3m, Housing +2.5%, Social cohesion -2.5%", key: CauseKeys.MapBuilt, args: new[] { "1.25", "0.025", "-0.025" }),+ new Cause("draft", "site", 1, "Site: a group of halutzim began plowing, cost IL 1.3m", key: CauseKeys.LandWorkStarted, args: new[] { "plow", "1.25" }),+ new Cause("draft", "site", 1, "Site: a group of halutzim began building a yishuv, cost IL 1.3m", key: CauseKeys.SiteStarted, args: new[] { "yishuv", "1.25" }),+ new Cause("draft", "site", -1, "Site: the halutzim stopped building; the Money spent is not returned", key: CauseKeys.SiteCancelled),+ new Cause("draft", "site", 1, "Site founded", key: CauseKeys.SiteCompleted, args: new[] { "founded" }),+ new Cause("draft", "town", 1, "Town: Housing began, cost IL 1.3m", key: CauseKeys.ProjectStarted, args: new[] { "housing", "1.25" }),+ new Cause("draft", "town", -1, "Town: Housing was cancelled; the Money spent is not returned", key: CauseKeys.ProjectCancelled, args: new[] { "housing" }),+ new Cause("draft", "town", 1, "Town: Housing was finished", key: CauseKeys.ProjectCompleted, args: new[] { "housing" }),+ new Cause("draft", "arms", 2000000000, "Bought 2000000000 Arms, cost IL 1.3m", key: CauseKeys.ArmsBought, args: new[] { "1.25" }),+ new Cause("draft", "food", 2000000000, "Site: the plowed land yielded 2000000000 units of Food", key: CauseKeys.FoodHarvest, args: new[] { "site" }),+ new Cause("draft", "food", -2000000000, "Food ran out: 2000000000 of 2000000001 units of the month's need went unmet", key: CauseKeys.FoodShortage, args: new[] { "2000000001" }),+ new Cause("draft", "food", -1, "No Food imported (foreign currency crisis): the stock fell to 2000000000 units", key: CauseKeys.FoodWithoutImports, args: new[] { "2000000000" }),+ new Cause("draft", "food", -2000000000, "The prisoners held ate 2000000000 units of Food", key: CauseKeys.PrisonerFood),+ new Cause("draft", "morale", -0.025, "The prisoners held went short of 2000000000 units of Food: Social cohesion -2.5%", key: CauseKeys.PrisonerFoodShortage, args: new[] { "2000000000" }),+ new Cause("draft", "town", 1, "Town: 1 group of craftsmen returned to civilian life and keep their training", key: CauseKeys.CraftsmenReturned, args: new[] { "1" }),+ new Cause("draft", "town", -3, "Town: 3 groups of qualified craftsmen are craftsmen again", key: CauseKeys.CraftsmenReassigned, args: new[] { "3" }),+ new Cause("draft", "42", 1, "Unit 42 returned to civilian life in Town and keeps its training", key: CauseKeys.PioneerReturned, args: new[] { "town" }),+ new Cause("draft", "town", -3, "Town: 3 groups of qualified veteran pioneers are units again", key: CauseKeys.PioneersReassigned, args: new[] { "3", "veteran" }),+ new Cause("draft", "town", -3, "Town: 3 groups began basic training as replacements for unit 42, cost IL 1.3m", key: CauseKeys.TrainingStarted, args: new[] { "3", "basic", "42", "1.25" }),+ new Cause("draft", "arms", -3, "Town: basic training took 3 Arms", key: CauseKeys.TrainingArms, args: new[] { "town", "basic" }),+ new Cause("draft", "town", 3, "Town: 3 groups left basic training; the Money spent is not returned", key: CauseKeys.TrainingCancelled, args: new[] { "3", "basic" }),+ new Cause("draft", "arms", 3, "Town: basic training returned 3 Arms", key: CauseKeys.TrainingArmsReturned, args: new[] { "town", "basic" }),+ new Cause("draft", "town", 0, "Town: unit 42 is no longer in Town, so its replacements stop training", key: CauseKeys.ReplacementsStopped, args: new[] { "42" }),+ new Cause("draft", "town", 3, "Town: 3 groups finished basic training and joined unit 42", key: CauseKeys.ReplacementsJoined, args: new[] { "3", "basic", "42" }),+ new Cause("draft", "town", 3, "Town: 3 groups finished artillery training and are artillery", key: CauseKeys.MilitaryTrained, args: new[] { "3", "artillery", "artillery" }),+ new Cause("draft", "town", 3, "Town: 3 groups finished pioneer training and are halutzim", key: CauseKeys.PioneersTrained, args: new[] { "3", "pioneer" }),+ new Cause("draft", "town", 3, "Town: 3 groups finished craft training and are craftsmen", key: CauseKeys.CraftsmenTrained, args: new[] { "3", "craft" }),+ new Cause("draft", "office", 0, "Person appointed Office, replacing Former", key: CauseKeys.Appointed, args: new[] { "person", "התפקיד שנשמר", "former" }),+ new Cause("draft", "coalition_stability", -0.025, "Coalition stability -2.5% (Party lost the Office)", key: CauseKeys.Reshuffle, args: new[] { "party", "former", "other", "Office", "התפקיד שנשמר" }),+ new Cause("draft", "appointments", -1, "A new government took office with its own ministers; your appointments ended", key: CauseKeys.AppointmentsEnded),+ new Cause("draft", "coalition_stability", -0.025, "Coalition stability -2.5% (public approval)", key: CauseKeys.ApprovalStability),+ new Cause("draft", "game_over", 0, "The coalition collapsed. Your premiership is over.", key: CauseKeys.CoalitionCollapsed),+ new Cause("draft", "leg", 0, "Body convened (120 seats, elected 15 May 1948); coalition holds 61/120", key: CauseKeys.LegislatureConvened, args: new[] { "61", "120" }),+ new Cause("draft", "gov", 0, "Government took office (Party)", key: CauseKeys.GovernmentTookOffice, args: new[] { "party" }),+ new Cause("draft", "gov", 0, "Party left the coalition; Other joined the coalition (coalition holds 61/120)", key: CauseKeys.CoalitionChanged, args: new[] { "party", "other", "61", "120" }),+ new Cause("draft", "era_ended", 0, "The chapter has ended", key: CauseKeys.EraEnded),+ new Cause("draft", "rationing", 0, "Body voted against Rationing at 25%, but its vote does not bind", key: CauseKeys.AdvisoryPolicyRejected, args: new[] { "leg", "0.25" }),+ new Cause("draft", "rationing", 0, "Body voted down Rationing at 25%", key: CauseKeys.PolicyRejected, args: new[] { "leg", "0.25" }),+ new Cause("draft", "rationing", 0.25, "Rationing set to 25%", key: CauseKeys.PolicySet),+ new Cause("draft", "budget", 0, "Body voted against the budget, but its vote does not bind", key: CauseKeys.AdvisoryBudgetRejected, args: new[] { "leg" }),+ new Cause("draft", "budget", 0, "Body voted the budget down", key: CauseKeys.BudgetRejected, args: new[] { "leg" }),+ new Cause("draft", "town", 0, "Town is captured: Israeli units hold it and no enemy unit is there. Its residents fled. It awaits a decision", key: CauseKeys.PlaceCaptured, args: new[] { "1" }),+ new Cause("draft", "town", 0, "Town is under enemy control again: enemy units hold it and no Israeli unit is there. Its residents fled when it was captured", key: CauseKeys.EnemyRegained, args: new[] { "1" }),+ new Cause("draft", "town", 0, "Town is annexed. Its residents fled when it was captured, so no people, homes or jobs are added", key: CauseKeys.PlaceAnnexed, args: new[] { "1" }),+ new Cause("draft", "town", 0, "Town: Israeli units withdrew and it is under enemy control again. Its residents fled when it was captured", key: CauseKeys.PlaceWithdrawn, args: new[] { "1", "1" }),+ new Cause("draft", "town", 0, "Town: Deport. Its residents are displaced and the place is depopulated", key: CauseKeys.PlaceDeported),+ new Cause("draft", "morale", -0.025, "Social cohesion -2.5% (Deport of Town)", key: CauseKeys.DeportEffect, args: new[] { "town" }),+ new Cause("draft", "treasury", -1.25, "Money IL -1.3m (Deport of Town)", key: CauseKeys.DeportCost, args: new[] { "town" }),+ new Cause("draft", "town", 3, "Town is occupied for 3 turns: an Israeli unit stays there. Its residents fled when it was captured", key: CauseKeys.OccupationStarted, args: new[] { "1" }),+ new Cause("draft", "town", 0, "Town: no decision was made before the end, so it counts as a raid", key: CauseKeys.PendingBecameRaid),+ new Cause("draft", "town", 0, "Town: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. Its residents fled when it was captured", key: CauseKeys.OccupationLostUnit, args: new[] { "1" }),+ new Cause("draft", "town", 3, "Town: 3 turns of occupation left", key: CauseKeys.OccupationCountdown),+ new Cause("draft", "intl_standing", -0.025, "International support -2.5% (the places depopulated by Deport)", key: CauseKeys.DepopulationSupport),+ };++ [Test]+ public void EveryRemainingKeyPreservesEnglishAndFormatsHebrewIncludingLargeCounts()+ {+ var c = RemainingFixture(); var en = En; var he = He;+ var names = new Dictionary<string, string> { ["town"] = "עיר" };+ var rows = RemainingRows();+ foreach (var row in rows)+ {+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, en), row.Key);+ AssertHebrew(CauseText.Line(row, c, NoRows, he, names), row.Key);+ }+ CollectionAssert.AreEquivalent(CauseKeys.All.Except(new[] {+ CauseKeys.MoneyFlows, CauseKeys.FxFlows, CauseKeys.Borrowed, CauseKeys.CivilianUpkeep,+ CauseKeys.FxCrisisBegan, CauseKeys.FxCrisisEased, CauseKeys.FxCrisisFood, CauseKeys.Arrived,+ CauseKeys.EffectChange, CauseKeys.SituationBegan, CauseKeys.SituationEnded, CauseKeys.RungChanged,+ CauseKeys.CallUpSet, CauseKeys.CallUpRaised, CauseKeys.CallUpLowered, CauseKeys.Ceasefire,+ CauseKeys.EventAmount, CauseKeys.EventChosen, CauseKeys.EventCity, CauseKeys.EventDelegated,+ CauseKeys.EventDelegatedPartial, CauseKeys.EventGrant, CauseKeys.EventNew, CauseKeys.EventPolicy,+ CauseKeys.EventRejoin, CauseKeys.EventSetRung, CauseKeys.EventStock, CauseKeys.EventUnlock,+ CauseKeys.MilitaryUpkeep, CauseKeys.ObjectiveCompleted, CauseKeys.PrisonersReturned, CauseKeys.SoldiersReturned }), rows.Select(x => x.Key), "all remaining keys");+ var appointed = rows.Single(x => x.Key == CauseKeys.Appointed);+ StringAssert.Contains("התפקיד שנשמר", CauseText.Line(appointed, c, NoRows, he, names), "historical title, not current title");+ }++ [Test]+ public void RemainingOptionalBranchesKeepExactEnglishAndResidentSnapshots()+ {+ var c = RemainingFixture(); var en = En; var he = He;+ var names = new Dictionary<string, string> { ["town"] = "עיר" };+ var rows = new[]+ {+ new Cause("draft", "town", 0, "Town is captured: Israeli units hold it and no enemy unit is there. It awaits a decision", key: CauseKeys.PlaceCaptured, args: new[] { "0" }),+ new Cause("draft", "town", 0, "Town is under enemy control again: enemy units hold it and no Israeli unit is there", key: CauseKeys.EnemyRegained, args: new[] { "0" }),+ new Cause("draft", "town", 0, "Town is annexed. Its residents join the population", key: CauseKeys.PlaceAnnexed, args: new[] { "0" }),+ new Cause("draft", "town", 0, "Town is under enemy control again. Its residents are unchanged", key: CauseKeys.PlaceWithdrawn, args: new[] { "0", "0" }),+ new Cause("draft", "town", 0, "Town: the occupation period has ended. It awaits a decision", key: CauseKeys.OccupationCountdown),+ new Cause("draft", "office", 0, "Person appointed Office", key: CauseKeys.Appointed, args: new[] { "person", "התפקיד שנשמר", "" }),+ new Cause("draft", "coalition_stability", -0.025, "Coalition stability -2.5% (Former resents the reshuffle)", key: CauseKeys.Reshuffle, args: new[] { "", "former", "same", "Office", "התפקיד שנשמר" }),+ new Cause("draft", "town", -1, "Town: 1 group began armoured car training, cost IL 1.3m", key: CauseKeys.TrainingStarted, args: new[] { "1", "armour", "", "1.25" }),+ new Cause("draft", "site", 1, "Site: a group of halutzim began draining the swamp, cost IL 1.3m", key: CauseKeys.LandWorkStarted, args: new[] { "drain", "1.25" }),+ new Cause("draft", "site", 1, "Site: a group of halutzim began building a training camp, cost IL 1.3m", key: CauseKeys.SiteStarted, args: new[] { "camp", "1.25" }),+ };+ // A renderer receives no live state: both resident variants must survive the settlement record's removal.+ foreach (var row in rows)+ {+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, en), row.Key);+ AssertHebrew(CauseText.Line(row, c, NoRows, he, names), row.Key);+ }+ var stayed = rows.Single(x => x.Key == CauseKeys.PlaceWithdrawn);+ StringAssert.Contains("מצב התושבים לא השתנה", CauseText.Line(stayed, c, NoRows, he, names));+ foreach (var verb in new[] { "built", "plowed", "drained", "founded" })+ {+ var row = new Cause("draft", "site", 1, "Site " + verb, key: CauseKeys.SiteCompleted, args: new[] { verb });+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, en));+ AssertHebrew(CauseText.Line(row, c, NoRows, he), row.Key);+ }+ }++ [Test]+ public void RemainingRowsPreserveTheWholeEnglishReportInBothLoops()+ {+ foreach (var c in new[] { C, SimBridgeGddTests.Legacy })+ {+ var state = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);+ for (var turn = 0; turn < 1000 && state.GameOver == null; turn++)+ {+ var result = Simulation.Step(c, state, GoldenRun.Orders(c, state));+ foreach (var row in result.Why.Where(x => CauseKeys.All.Contains(x.Key)))+ Assert.AreEqual(row.Message, CauseText.Line(row, c, NoRows, En), row.Key);+ state = result.State;+ }+ Assert.IsNotNull(state.GameOver);+ }+ }}diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex ed4da726b..0e1f37d63 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -230,7 +230,7 @@ public class HebrewUiTests/// <summary>Many texts a presenter builds after boot get their words before they are on the panel (new Label(text)), so/// no text change reaches UiDirection: they take their direction when it walks the tree again, on the next frame after/// a submit, a click or a turn. Here: a label added before a submit, one added before a click, and the Why rows End- /// Turn rebuilds (Hebrew headers, English lines).</summary>+ /// Turn rebuilds (localized rows plus an explicit legacy English fallback fixture).</summary>[UnityTest]public IEnumerator InHebrewTextsBuiltAfterBootTakeTheirDirectionAfterASubmitAClickOrATurn(){@@ -259,12 +259,16 @@ public class HebrewUiTests// A turn: End Turn rebuilds the Why rows.game.Bridge!.EndTurn();+ // #1682 localizes the actual causes. Keep mixed-direction coverage through the supported unkeyed fallback.+ Ui.Q<ScrollView>("why-rows").contentContainer.Add(new Label(CauseText.Line(+ new Statecraft.Sim.Cause("fixture", "fixture", 0, "Legacy fallback"), game.Bridge.Content,+ Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), He)));var built = Ui.Q<ScrollView>("why-rows").contentContainer.Query<TextElement>().ToList();Assert.IsTrue(built.All(t => t.languageDirection == LanguageDirection.Inherit), "the new rows have no direction before the next frame");for (int i = 0; i < 2; i++) yield return null;Directed(built, "a turn");Assert.IsTrue(built.Any(t => t.languageDirection == LanguageDirection.RTL) && built.Any(t => t.languageDirection == LanguageDirection.LTR),- "the rows mix Hebrew (the headers) and English (the lines, #55)");+ "the rebuilt rows mix Hebrew and the explicit legacy English fallback");}finally { restore(); }}diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 47fd5780d..963d30cb0 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -895,3 +895,108 @@ why.cause.soldiers_returned: "Prisoners exchanged: {0:N0} of our soldiers came hunit.artillery_move_missing: "Artillery cannot move yet: its movement points have not been set"unit.fire_ready: "Fire available"unit.fire_spent: "Fired this turn"++# #1682 remaining Cause producers. English report wording preserved.+why.cause.workers_assigned: "{0}: {1} groups in work"+why.cause.wages_paid: "{0}: jobs paid {1}"+why.cause.immigrants_housed: "{0}: {1} groups of immigrants housed"+why.cause.housing_shortage: "{0}: {1} groups more than its homes hold"+why.cause.immigrants_waiting: "{0}: {1} groups of immigrants arrived and wait for homes"+why.cause.recruits_veteran: "Recruits became veteran soldiers"+why.cause.corridor_started: "{0}: a group of halutzim began building, cost {1}"+why.cause.corridor_cancelled: "{0}: the halutzim stopped building; the Money spent is not returned"+why.cause.corridor_completed: "{0} built"+why.cause.pioneers_veteran: "A group of halutzim became veteran pioneers"+why.cause.map_borrowed: "Borrowed {0} to build {1}"+why.cause.map_built: "Built {0}: cost {1}, {2} {3}, {4} {5}"+why.cause.land_work_started: "{0}: a group of halutzim began {1}, cost {2}"+why.cause.site_started: "{0}: a group of halutzim began building {1}, cost {2}"+why.cause.site_cancelled: "{0}: the halutzim stopped building; the Money spent is not returned"+why.cause.site_completed: "{0} {1}"+why.cause.project_started: "{0}: {1} began, cost {2}"+why.cause.project_cancelled: "{0}: {1} was cancelled; the Money spent is not returned"+why.cause.project_completed: "{0}: {1} was finished"+why.cause.arms_bought: "Bought {0} Arms, cost {1}"+why.cause.food_harvest: "{0}: the plowed land yielded {1} units of Food"+why.cause.food_shortage: "Food ran out: {0} of {1} units of the month's need went unmet"+why.cause.food_without_imports: "No Food imported (foreign currency crisis): the stock fell to {0} units"+why.cause.prisoner_food: "The prisoners held ate {0} units of Food"+why.cause.prisoner_food_shortage: "The prisoners held went short of {0} units of Food: {1} {2}"+why.cause.craftsmen_returned: "{0}: {1} of craftsmen returned to civilian life and keep their training"+why.cause.craftsmen_reassigned: "{0}: {1} of qualified craftsmen are craftsmen again"+why.cause.pioneer_returned: "Unit {0} returned to civilian life in {1} and keeps its training"+why.cause.pioneers_reassigned: "{0}: {1} of qualified {2} are units again"+why.cause.training_started: "{0}: {1} began {2}{3}, cost {4}"+why.cause.training_arms: "{0}: {1} took {2} Arms"+why.cause.training_cancelled: "{0}: {1} left {2}; the Money spent is not returned"+why.cause.training_arms_returned: "{0}: {1} returned {2} Arms"+why.cause.replacements_stopped: "{0}: unit {1} is no longer in {0}, so its replacements stop training"+why.cause.replacements_joined: "{0}: {1} finished {2} and joined unit {3}"+why.cause.military_trained: "{0}: {1} finished {2} and are {3}"+why.cause.pioneers_trained: "{0}: {1} finished {2} and are halutzim"+why.cause.craftsmen_trained: "{0}: {1} finished {2} and are craftsmen"+why.cause.appointed: "{0} appointed {1}{2}"+why.cause.reshuffle: "Coalition stability {0} ({1} {2})"+why.cause.appointments_ended: "A new government took office with its own ministers; your appointments ended"+why.cause.approval_stability: "Coalition stability {0} (public approval)"+why.cause.coalition_collapsed: "The coalition collapsed. Your premiership is over."+why.cause.legislature_convened: "{0} convened ({1} seats{2}); coalition holds {3}/{4}"+why.cause.government_took_office: "{0} took office ({1})"+why.cause.coalition_changed: "{0} (coalition holds {1}/{2})"+why.cause.era_ended: "{0}"+why.cause.advisory_policy_rejected: "{0} voted against {1} at {2}, but its vote does not bind"+why.cause.policy_rejected: "{0} voted down {1} at {2}"+why.cause.policy_set: "{0} set to {1}"+why.cause.advisory_budget_rejected: "{0} voted against the budget, but its vote does not bind"+why.cause.budget_rejected: "{0} voted the budget down"+why.cause.place_captured: "{0} is captured: Israeli units hold it and no enemy unit is there. {1}It awaits a decision"+why.cause.enemy_regained: "{0} is under enemy control again: enemy units hold it and no Israeli unit is there{1}"+why.cause.place_annexed: "{0} is annexed. {1}"+why.cause.place_withdrawn: "{0}{1} {2}"+why.cause.place_deported: "{0}: Deport. Its residents are displaced and the place is depopulated"+why.cause.deport_effect: "{0} {1} (Deport of {2})"+why.cause.deport_cost: "{0} {1} (Deport of {2})"+why.cause.occupation_started: "{0} is occupied for {1} turns: an Israeli unit stays there. {2}"+why.cause.pending_became_raid: "{0}: no decision was made before the end, so it counts as a raid"+why.cause.occupation_lost_unit: "{0}: no Israeli unit holds it any more, so the occupation ended as a raid. It is under enemy control again. {1}"+why.cause.occupation_countdown: "{0}: {1} turns of occupation left"+why.cause.depopulation_support: "{0} {1} (the places depopulated by Deport)"+why.cause.work.plow: "plowing"+why.cause.work.drain: "draining the swamp"+why.cause.work.camp: "a training camp"+why.cause.work.yishuv: "a yishuv"+why.cause.work.built: "built"+why.cause.work.plowed: "plowed"+why.cause.work.drained: "drained"+why.cause.work.founded: "founded"+why.cause.course.artillery: "artillery training"+why.cause.course.armour: "armoured car training"+why.cause.course.basic: "basic training"+why.cause.course.craft: "craft training"+why.cause.course.pioneer: "pioneer training"+why.cause.trained.artillery: "artillery"+why.cause.trained.armour: "armoured cars"+why.cause.trained.recruit: "recruits"+why.cause.trained.veteran: "veteran pioneers"+why.cause.trained.halutz: "halutzim"+why.cause.replacements: " as replacements for unit {0}"+why.cause.replacing: ", replacing {0}"+why.cause.resented: "resents the reshuffle"+why.cause.lost_office: "lost the {0}"+why.cause.parties_left: "{0} left the coalition"+why.cause.parties_joined: "{0} joined the coalition"+why.cause.segment: "{0}, segment {1}"+why.cause.elected: ", elected {0}"+why.cause.fled_capture: "Its residents fled. "+why.cause.residents.1: "Its residents fled when it was captured"+why.cause.residents.0: "Its residents are unchanged"+why.cause.annexed.1: "Its residents fled when it was captured, so no people, homes or jobs are added"+why.cause.annexed.0: "Its residents join the population"+why.cause.withdrew.1: ": Israeli units withdrew and it is under enemy control again."+why.cause.withdrew.0: " is under enemy control again."+why.cause.occupation_countdown_ended: "{0}: the occupation period has ended. It awaits a decision"+why.cause.ending.era_ended: "The chapter has ended"+why.cause.ending.mvp_ended: "The game has reached its last turn"+why.cause.ending.coalition_collapse: "The coalition collapsed"+why.cause.ending.defeat_economy: "Money and Food ran out"+why.cause.ending.defeat_war: "The enemy holds a city"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex b3d716737..44cae8049 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -994,3 +994,109 @@ why.cause.soldiers_returned: "חילופי שבויים: {0:N0} מחיילינוunit.artillery_move_missing: "לא ניתן להזיז ארטילריה עדיין: נקודות התנועה שלה טרם נקבעו"unit.fire_ready: "ניתן לירות"unit.fire_spent: "הירי בוצע בתור הזה"++# #1682 remaining Cause producers. Agent-drafted Hebrew: native-review-pending (#564).+# SENSITIVE: capture, displacement, Deport, annexation and occupation also await sensitivity review.+why.cause.workers_assigned: "{0}: קבוצות בעבודה: {1}" # native-review-pending (#564)+why.cause.wages_paid: "{0}: תשלום מעבודה: {1}" # native-review-pending (#564)+why.cause.immigrants_housed: "{0}: קבוצות עולים שקיבלו דיור: {1}" # native-review-pending (#564)+why.cause.housing_shortage: "{0}: קבוצות מעבר לקיבולת הדיור: {1}" # native-review-pending (#564)+why.cause.immigrants_waiting: "{0}: קבוצות עולים שהגיעו וממתינות לדיור: {1}" # native-review-pending (#564)+why.cause.recruits_veteran: "המגויסים הפכו לחיילים ותיקים" # native-review-pending (#564)+why.cause.corridor_started: "{0}: קבוצת חלוצים החלה בבנייה, עלות {1}" # native-review-pending (#564)+why.cause.corridor_cancelled: "{0}: החלוצים הפסיקו את הבנייה; הכסף שהוצא לא יוחזר" # native-review-pending (#564)+why.cause.corridor_completed: "{0}: הבנייה הושלמה" # native-review-pending (#564)+why.cause.pioneers_veteran: "קבוצת חלוצים הפכה לחלוצים ותיקים" # native-review-pending (#564)+why.cause.map_borrowed: "הלוואה של {0} לבניית {1}" # native-review-pending (#564)+why.cause.map_built: "הושלמה בניית {0}: עלות {1}, {2}: שינוי {3}, {4}: שינוי {5}" # native-review-pending (#564)+why.cause.land_work_started: "{0}: קבוצת חלוצים החלה ב{1}, עלות {2}" # native-review-pending (#564)+why.cause.site_started: "{0}: קבוצת חלוצים החלה בבניית {1}, עלות {2}" # native-review-pending (#564)+why.cause.site_cancelled: "{0}: החלוצים הפסיקו את הבנייה; הכסף שהוצא לא יוחזר" # native-review-pending (#564)+why.cause.site_completed: "{0}: מצב האתר: {1}" # native-review-pending (#564)+why.cause.project_started: "{0}: תחילת {1}, עלות {2}" # native-review-pending (#564)+why.cause.project_cancelled: "{0}: ביטול {1}; הכסף שהוצא לא יוחזר" # native-review-pending (#564)+why.cause.project_completed: "{0}: הושלם {1}" # native-review-pending (#564)+why.cause.arms_bought: "נשק שנרכש: {0}, עלות {1}" # native-review-pending (#564)+why.cause.food_harvest: "{0}: יחידות מזון שהניבה הקרקע החרושה: {1}" # native-review-pending (#564)+why.cause.food_shortage: "המזון אזל: מחסור של {0} מתוך {1} יחידות שנדרשו החודש" # native-review-pending (#564)+why.cause.food_without_imports: "לא יובא מזון (משבר מטבע חוץ): יחידות שנותרו במלאי: {0}" # native-review-pending (#564)+why.cause.prisoner_food: "יחידות מזון שאכלו השבויים המוחזקים: {0}" # native-review-pending (#564)+why.cause.prisoner_food_shortage: "לשבויים המוחזקים חסרו {0} יחידות מזון: {1}: שינוי {2}" # native-review-pending (#564)+why.cause.craftsmen_returned: "{0}: חזרה לחיים אזרחיים תוך שמירת ההכשרה, בעלי מלאכה: {1}" # native-review-pending (#564)+why.cause.craftsmen_reassigned: "{0}: חזרה לעבודה במלאכה, בעלי הכשרה: {1}" # native-review-pending (#564)+why.cause.pioneer_returned: "יחידה {0}: חזרה לחיים אזרחיים ב{1} תוך שמירת ההכשרה" # native-review-pending (#564)+why.cause.pioneers_reassigned: "{0}: חזרה ליחידות, קבוצות בעלות הכשרה ({2}): {1}" # native-review-pending (#564)+why.cause.training_started: "{0}: תחילת {2}{3}, קבוצות: {1}, עלות {4}" # native-review-pending (#564)+why.cause.training_arms: "{0}: {1}, נשק שנצרך: {2}" # native-review-pending (#564)+why.cause.training_cancelled: "{0}: הפסקת {2}, קבוצות: {1}; הכסף שהוצא לא יוחזר" # native-review-pending (#564)+why.cause.training_arms_returned: "{0}: {1}, נשק שהוחזר: {2}" # native-review-pending (#564)+why.cause.replacements_stopped: "{0}: יחידה {1} כבר אינה ב{0}, ולכן הופסק אימון התגבורת שלה" # native-review-pending (#564)+why.cause.replacements_joined: "{0}: סיום {2} והצטרפות ליחידה {3}, קבוצות: {1}" # native-review-pending (#564)+why.cause.military_trained: "{0}: סיום {2}, קבוצות: {1}, הכשרה: {3}" # native-review-pending (#564)+why.cause.pioneers_trained: "{0}: סיום {2}, קבוצות חלוצים: {1}" # native-review-pending (#564)+why.cause.craftsmen_trained: "{0}: סיום {2}, קבוצות בעלי מלאכה: {1}" # native-review-pending (#564)+why.cause.appointed: "מינוי {0} לתפקיד {1}{2}" # native-review-pending (#564)+why.cause.reshuffle: "יציבות הקואליציה: שינוי {0} ({1}: {2})" # native-review-pending (#564)+why.cause.appointments_ended: "ממשלה חדשה נכנסה לתפקיד עם שריה; המינויים שלכם הסתיימו" # native-review-pending (#564)+why.cause.approval_stability: "יציבות הקואליציה: שינוי {0} (שביעות רצון הציבור)" # native-review-pending (#564)+why.cause.coalition_collapsed: "הקואליציה התפרקה. כהונתכם בראשות הממשלה הסתיימה." # native-review-pending (#564)+why.cause.legislature_convened: "התכנסות {0} ({1} מושבים{2}); לקואליציה {3}/{4}" # native-review-pending (#564)+why.cause.government_took_office: "כניסת {0} לתפקיד ({1})" # native-review-pending (#564)+why.cause.coalition_changed: "{0} (לקואליציה {1}/{2})" # native-review-pending (#564)+why.cause.era_ended: "{0}" # native-review-pending (#564)+why.cause.advisory_policy_rejected: "הצבעת {0} נגד {1} ברמה {2}, אך ההצבעה אינה מחייבת" # native-review-pending (#564)+why.cause.policy_rejected: "דחיית {1} ברמה {2} בהצבעת {0}" # native-review-pending (#564)+why.cause.policy_set: "{0}: הרמה שנקבעה: {1}" # native-review-pending (#564)+why.cause.advisory_budget_rejected: "הצבעת {0} נגד התקציב, אך ההצבעה אינה מחייבת" # native-review-pending (#564)+why.cause.budget_rejected: "דחיית התקציב בהצבעת {0}" # native-review-pending (#564)+why.cause.place_captured: "{0}: המקום נכבש ומוחזק בידי יחידות ישראליות ללא יחידת אויב. {1}המקום ממתין להחלטה" # native-review-pending (#564)+why.cause.enemy_regained: "{0}: המקום שוב בשליטת האויב ומוחזק בידי יחידות אויב ללא יחידה ישראלית{1}" # native-review-pending (#564)+why.cause.place_annexed: "{0}: המקום סופח. {1}" # native-review-pending (#564)+why.cause.place_withdrawn: "{0}{1} {2}" # native-review-pending (#564)+why.cause.place_deported: "{0}: גירוש. התושבים נעקרו והמקום התרוקן מתושביו" # native-review-pending (#564)+why.cause.deport_effect: "{0}: שינוי {1} (גירוש מתושבי {2})" # native-review-pending (#564)+why.cause.deport_cost: "{0}: שינוי {1} (גירוש מתושבי {2})" # native-review-pending (#564)+why.cause.occupation_started: "{0}: המקום תחת כיבוש למשך {1} תורות, ויחידה ישראלית נשארת בו. {2}" # native-review-pending (#564)+why.cause.pending_became_raid: "{0}: לא התקבלה החלטה לפני הסיום, ולכן הדבר נחשב לפשיטה" # native-review-pending (#564)+why.cause.occupation_lost_unit: "{0}: אין עוד יחידה ישראלית המחזיקה במקום, ולכן הכיבוש הסתיים כפשיטה. המקום שוב בשליטת האויב. {1}" # native-review-pending (#564)+why.cause.occupation_countdown: "{0}: תורות כיבוש שנותרו: {1}" # native-review-pending (#564)+why.cause.depopulation_support: "{0}: שינוי {1} (המקומות שהתרוקנו מתושביהם בעקבות גירוש)" # native-review-pending (#564)+why.cause.work.plow: "חריש" # native-review-pending (#564)+why.cause.work.drain: "ייבוש הביצה" # native-review-pending (#564)+why.cause.work.camp: "מחנה אימונים" # native-review-pending (#564)+why.cause.work.yishuv: "יישוב" # native-review-pending (#564)+why.cause.work.built: "הבנייה הושלמה" # native-review-pending (#564)+why.cause.work.plowed: "החריש הושלם" # native-review-pending (#564)+why.cause.work.drained: "הייבוש הושלם" # native-review-pending (#564)+why.cause.work.founded: "היישוב הוקם" # native-review-pending (#564)+why.cause.course.artillery: "אימון תותחנים" # native-review-pending (#564)+why.cause.course.armour: "אימון שריוניות" # native-review-pending (#564)+why.cause.course.basic: "אימון בסיסי" # native-review-pending (#564)+why.cause.course.craft: "הכשרת בעלי מלאכה" # native-review-pending (#564)+why.cause.course.pioneer: "הכשרת חלוצים" # native-review-pending (#564)+why.cause.trained.artillery: "תותחנים" # native-review-pending (#564)+why.cause.trained.armour: "שריוניות" # native-review-pending (#564)+why.cause.trained.recruit: "מגויסים" # native-review-pending (#564)+why.cause.trained.veteran: "חלוצים ותיקים" # native-review-pending (#564)+why.cause.trained.halutz: "חלוצים" # native-review-pending (#564)+why.cause.replacements: " כתגבורת ליחידה {0}" # native-review-pending (#564)+why.cause.replacing: ", במקום {0}" # native-review-pending (#564)+why.cause.resented: "תרעומת על חילופי התפקידים" # native-review-pending (#564)+why.cause.lost_office: "אובדן תפקיד {0}" # native-review-pending (#564)+why.cause.parties_left: "עזיבת הקואליציה: {0}" # native-review-pending (#564)+why.cause.parties_joined: "הצטרפות לקואליציה: {0}" # native-review-pending (#564)+why.cause.segment: "{0}, קטע {1}" # native-review-pending (#564)+why.cause.elected: ", בחירות ב{0}" # native-review-pending (#564)+why.cause.fled_capture: "תושבי המקום נמלטו. " # native-review-pending (#564)+why.cause.residents.1: "תושבי המקום נמלטו בעת כיבושו" # native-review-pending (#564)+why.cause.residents.0: "מצב התושבים לא השתנה" # native-review-pending (#564)+why.cause.annexed.1: "תושבי המקום נמלטו בעת כיבושו, ולכן לא נוספו אנשים, בתים או מקומות עבודה" # native-review-pending (#564)+why.cause.annexed.0: "תושבי המקום מצטרפים לאוכלוסייה" # native-review-pending (#564)+why.cause.withdrew.1: ": היחידות הישראליות נסוגו והמקום שוב בשליטת האויב." # native-review-pending (#564)+why.cause.withdrew.0: ": המקום שוב בשליטת האויב." # native-review-pending (#564)+why.cause.occupation_countdown_ended: "{0}: תקופת הכיבוש הסתיימה. המקום ממתין להחלטה" # native-review-pending (#564)+why.cause.ending.era_ended: "הפרק הסתיים" # native-review-pending (#564)+why.cause.ending.mvp_ended: "המשחק הגיע לתור האחרון" # native-review-pending (#564)+why.cause.ending.coalition_collapse: "הקואליציה התפרקה" # native-review-pending (#564)+why.cause.ending.defeat_economy: "הכסף והמזון אזלו" # native-review-pending (#564)+why.cause.ending.defeat_war: "האויב מחזיק בעיר" # native-review-pending (#564)