A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Event card: a consequence card names the road it follows, beside the record (Fixes #954, refs #939) (#1152)
Beria51ff8de2231
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f1445042b..140b561e4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -126,6 +126,11 @@ checks this (see `CONTRIBUTING.md`).info panel's actions. Covering screens and the start screen take the stop out of reach, and mouse and touch clicks passthrough it as before. The empty info panel's hint says so in English and Hebrew, and keeps the right-drag (Hebrewflagged for a native speaker's review; Fixes #1116, refs #41).+- Event card: a consequence card names the road it follows and the record beside it ("Alternative course. It follows+ the government's decision: [option] ([card]). In the record: [historical option]."), from the sim's `Timeline.Origin` and+ `Timeline.HistoricalOption`; a card chained on a consequence card, which has no record of its own, leaves the+ comparison out. An option that rejoins the record says "Returns to the recorded course." under it. Ordinary cards are+ unchanged; English and Hebrew, the Hebrew flagged for a native speaker's review (#564) (refs #939, #954).### Fixed- Hebrew budget vote labels use the legislature as their subject, following the native review, so names beginning with ה no longer follow an uninflected ב־ prefix (refs #564).- Keep the opt-in hex terrain overlay out of automatic neighboring with the real map terrain.diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.csindex d1fde0273..b6649a7d4 100644--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs@@ -30,6 +30,8 @@ namespace Statecraft.Game.UI/// <summary>On End Turn while the shown card cannot be answered with the Attention left (#1034): Statecraft.uss/// highlights it, as ending the turn is then the way on (EventSystem.Delegate hands the card to its minister).</summary>public const string EndTurnWaitingClass = "end-turn-waiting";+ /// <summary>The line under an option that returns the course to the record (EventOption.Rejoin, #954; Statecraft.uss).</summary>+ public const string RejoinClass = "event-rejoin";readonly VisualElement card; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;readonly EventImageCatalog? photos;@@ -249,6 +251,9 @@ namespace Statecraft.Game.UIbool hebrew = text["ui.lang"] == UiLanguage.Hebrew;string Local(string english, string he) => hebrew && he != "" ? Cabinet.Fill(c, s, he, date, p => ContentNames.Of(text, p)) : english;card.Q<Label>("event-title").text = Local(EventSystem.Title(c, s, e), variant == null || variant.Title == "" ? e.TitleHe : "");+ var banner = card.Q<Label>("event-alt-banner"); // a consequence card's road (#954); none on any other card+ banner.text = OriginLine(c, s, e, text);+ banner.style.display = banner.text.Length == 0 ? DisplayStyle.None : DisplayStyle.Flex;var office = holder == null ? null : c.Offices.First(o => o.Id == e.Office);card.Q<Label>("event-office").text = holder == null ? "" : text.Format("event.office", ContentNames.Of(text, office!, holder), ContentNames.Of(text, holder));card.Q<Label>("event-text").text = Local(EventSystem.Render(c, s, e), variant == null ? e.TextHe : "");@@ -269,6 +274,11 @@ namespace Statecraft.Game.UIb.AddToClassList(OptionClass);b.SetEnabled(!unpaid);options.Add(b);+ if (o.Rejoin == "") continue;+ // Under the option, not in it: the button's label stays the choice itself, and a Label takes no Tab stop.+ var rejoin = new Label(text["event.rejoin"]);+ rejoin.AddToClassList("muted"); rejoin.AddToClassList(RejoinClass);+ options.Add(rejoin);}card.Q<Label>("event-count").text = open.Count > 1 ? text.Format("event.more", open.Count - 1) : "";if (shown && !photoWaits && layer.enabledInHierarchy && openedFor != e.Id) { openedFor = e.Id; Opened?.Invoke(e.Id); }@@ -294,6 +304,32 @@ namespace Statecraft.Game.UI: t.Format("event.objective_early", Date(done), Date(o.ReferenceDate), early);}+ /// <summary>A consequence card's banner (#954; plan 2026-10-17-alternate-timelines.md, A.4.7): the road it follows as+ /// the player took it (Timeline.Origin: that card's option and title, through the same text pipeline as that card's+ /// own labels) and, where that card has one, the record's option beside it (Timeline.HistoricalOption). A chained+ /// card follows a consequence card, which has no historical option: the comparison is left out, never made up.+ /// Empty for any other card.</summary>+ public static string OriginLine(Content c, GameState s, GameEvent e, UiText t)+ {+ var origin = Timeline.Origin(c, s, e);+ if (origin == null) return "";+ // The loader checks every requirement names an event, but a save from older content may hold an option the card+ // no longer has: then no banner rather than a broken card.+ var road = c.Events.FirstOrDefault(x => x.Id == origin.Value.Event);+ var option = road?.Options.FirstOrDefault(o => o.Id == origin.Value.Option);+ if (road == null || option == null) return "";+ var date = EventSystem.FillDate(road, s.Date);+ // Use the road card's own per-field fallback and name/date routing (#1064), not the consequence's date.+ bool hebrew = t["ui.lang"] == UiLanguage.Hebrew;+ string Local(string english, string he) => hebrew && he != "" ? Cabinet.Fill(c, s, he, date, p => ContentNames.Of(t, p)) : english;+ var variant = Timeline.Variant(c, s, road);+ var took = Local(Cabinet.Fill(c, s, option.Text, date), option.TextHe);+ var title = Local(EventSystem.Title(c, s, road), variant == null || variant.Title == "" ? road.TitleHe : "");+ var record = Timeline.HistoricalOption(road);+ return record == null ? t.Format("event.alt_origin_no_record", took, title)+ : t.Format("event.alt_origin", took, title, Local(Cabinet.Fill(c, s, record.Text, date), record.TextHe));+ }+/// <summary>A newly shown event puts the keyboard focus on the card (keyboard play, #41): the next Tab reaches its/// first option, and no option is lit before the player picks. Not while the layer is out of reach (the start screen/// or a screen covers it): then nothing is recorded, and the card takes the focus when the cover closesdiff --git a/unity/Assets/Tests/EditMode/EventCardTests.cs b/unity/Assets/Tests/EditMode/EventCardTests.csindex c42e4772b..bc1120442 100644--- a/unity/Assets/Tests/EditMode/EventCardTests.cs+++ b/unity/Assets/Tests/EditMode/EventCardTests.cs@@ -1,3 +1,5 @@+using System.Collections.Generic;+using System.IO;using System.Linq;using NUnit.Framework;using Statecraft.Game;@@ -529,4 +531,225 @@ public class EventCardTestsnew EventCardPresenter(ui.Root, new SimBridge(g, text), text, null);Assert.AreEqual(line, ui.Q<Label>("event-delegate").text);}++ // ---- The consequence card's banner (#954; plan docs/superpowers/plans/2026-10-17-alternate-timelines.md, A.4.7) ----++ /// <summary>A test-only road, never shipped (the example.org sources say so): a hard card on the game's first day whose+ /// second option was proposed; a consequence card that follows that road, with an option that rejoins the record; and a+ /// card chained on the consequence card, which has no historical option of its own. Schema-valid+ /// (content/schema/event.schema.json); loaded beside the real content through the loader's own checks.</summary>+ static readonly Dictionary<string, string> RoadFixture = new Dictionary<string, string>+ {+ ["events/zz_banner_parent.yaml"] = @"id: banner_parent+title: 'The road of {prime_minister}'+title_he: 'הדרך של {prime_minister}'+text: 'A decision with a record.'+text_he: 'החלטה שיש לה תיעוד.'+text_he_review: agent-checked+anchor: hard+from: 1948-05-15+to: 1948-06-11+options:+ - id: record+ text: What happened+ text_he: מה שקרה+ historical: true+ - id: road+ text: The road not taken+ text_he: הדרך שלא נבחרה+ alternative:+ basis: proposed+ by: the opposition benches+ date: 1948-05-20+ sources: [{ url: ""https://example.org/minutes"", checked: 2026-10-17 }]+sources: [{ url: ""https://example.org/record"", checked: 2026-10-17 }]+",+ ["events/zz_banner_after.yaml"] = @"id: banner_after+kind: consequence+title: After the road+text: 'What was feared.'+from: 1948-06-15+to: 1948-08-15+requires: [{ event: banner_parent, option: road }]+options:+ - id: hold+ text: Hold the course+ alternative: { basis: debated, by: the cabinet, date: 1948-06-20, sources: [{ url: ""https://example.org/cabinet"", checked: 2026-10-17 }] }+ - id: back+ text: Go back+ rejoin: banner_parent+ alternative: { basis: design }+sources: [{ url: ""https://example.org/record"", checked: 2026-10-17 }]+",+ ["events/zz_banner_second.yaml"] = @"id: banner_second+kind: consequence+title: Further along+text: 'Later still.'+from: 1948-07-15+to: 1948-08-15+requires: [{ event: banner_after, option: hold }]+options:+ - id: go_on+ text: Go on+ alternative: { basis: design }+sources: [{ url: ""https://example.org/record"", checked: 2026-10-17 }]+",+ };++ static Content WithRoad()+ {+ string Read(string rel) => RoadFixture.TryGetValue(rel, out var yaml) ? yaml+ : File.Exists(Path.Combine(Paths.Content, rel)) ? File.ReadAllText(Path.Combine(Paths.Content, rel)) : null;+ var files = Directory.GetFiles(Path.Combine(Paths.Content, "events"), "*.yaml").Select(f => "events/" + Path.GetFileName(f));+ return ContentLoader.Load(Read, files.Concat(RoadFixture.Keys));+ }++ /// <summary>The historical game with the fixture's road taken (banner_parent: road, banner_after: hold, ahead of the+ /// reference player's orders), played until <paramref name="until"/> waits for a decision.</summary>+ static SimBridge OnTheRoad(Content c, string until, UiText text)+ {+ var answers = new Dictionary<string, string> { ["banner_parent"] = "road", ["banner_after"] = "hold" };+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);+ for (int turn = 0; turn < 6 && !g.State.PendingEvents.Contains(until); turn++)+ {+ var mine = answers.Where(a => g.State.PendingEvents.Contains(a.Key)).Select(a => (Command)new ChooseEventOption(a.Key, a.Value));+ var rest = GoldenRun.Orders(c, g.State).Where(o => !(o is ChooseEventOption ch && answers.ContainsKey(ch.EventId)));+ g.Step(mine.Concat(rest).ToArray());+ }+ Assert.Contains(until, g.State.PendingEvents.ToList(), "precondition: the road's card waits");+ return new SimBridge(g, text);+ }++ [Test]+ public void AConsequenceCardSaysWhichRoadItFollows()+ {+ var c = WithRoad();+ var bridge = OnTheRoad(c, "banner_after", Text);+ using var ui = new UiTestKit();+ var card = new EventCardPresenter(ui.Root, bridge, Text, null);+ Assert.AreEqual("banner_after", card.Shown!.Id);+ var banner = ui.Q<Label>("event-alt-banner");+ Assert.AreEqual(DisplayStyle.Flex, banner.style.display.value);+ // The option the player took and its card's title, then the record's option on that card (Timeline.Origin, HistoricalOption).+ Assert.AreEqual("Alternative course. It follows the government's decision: The road not taken (The road of David Ben-Gurion). In the record: What happened.", banner.text);+ // The card itself is as before: its title, text and priced options.+ Assert.AreEqual("After the road", ui.Q<Label>("event-title").text);+ Assert.AreEqual("What was feared.", ui.Q<Label>("event-text").text);+ Assert.AreEqual(new[] { "option-hold", "option-back" }, ui.Q<VisualElement>("event-options").Query<Button>().ToList().Select(b => b.name).ToArray());+ StringAssert.EndsWith("(costs 2.0 Attention)", ui.Q<Button>("option-hold").text);+ Assert.IsTrue(ui.Q<VisualElement>("event-options").Query<Button>().ToList().All(b => b.enabledSelf));+ }++ [Test]+ public void AChainedCardOmitsTheRecordItDoesNotHave()+ {+ var c = WithRoad();+ var bridge = OnTheRoad(c, "banner_second", Text);+ using var ui = new UiTestKit();+ var card = new EventCardPresenter(ui.Root, bridge, Text, null);+ Assert.AreEqual("banner_second", card.Shown!.Id);+ Assert.IsNull(Timeline.HistoricalOption(c.Events.First(e => e.Id == "banner_after")), "precondition: the card it follows has no record");+ var banner = ui.Q<Label>("event-alt-banner");+ Assert.AreEqual(DisplayStyle.Flex, banner.style.display.value);+ Assert.AreEqual("Alternative course. It follows the government's decision: Hold the course (After the road).", banner.text);+ }++ [Test]+ public void AnOrdinaryCardHasNoBanner()+ {+ using var ui = new UiTestKit();+ new EventCardPresenter(ui.Root, AtArmistice(), Text, null);+ Assert.AreEqual(DisplayStyle.None, ui.Q<Label>("event-alt-banner").style.display.value);+ Assert.AreEqual("", ui.Q<Label>("event-alt-banner").text);+ Assert.AreEqual(0, ui.Q<VisualElement>("event-options").Query<Label>(className: EventCardPresenter.RejoinClass).ToList().Count);+ }++ [Test]+ public void ARejoinOptionSaysItReturnsToTheRecord()+ {+ var bridge = OnTheRoad(WithRoad(), "banner_after", Text);+ using var ui = new UiTestKit();+ new EventCardPresenter(ui.Root, bridge, Text, null);+ var lines = ui.Q<VisualElement>("event-options").Query<Label>(className: EventCardPresenter.RejoinClass).ToList();+ Assert.AreEqual(1, lines.Count, "only the option with `rejoin` has the line");+ Assert.AreEqual("Returns to the recorded course.", lines[0].text);+ var children = ui.Q<VisualElement>("event-options").Children().ToList();+ Assert.AreEqual(children.IndexOf(ui.Q<Button>("option-back")) + 1, children.IndexOf(lines[0]), "the line sits under its option");+ Assert.IsFalse(lines[0].focusable, "Tab still reaches only the options");+ }++ /// <summary>The banner belongs to the card it is on: Hide and "Decision waiting" bring it back unchanged, and once the+ /// consequence card is answered the next, ordinary card shows none.</summary>+ [Test]+ public void TheBannerFollowsItsCardThroughHideAndAnAnswer()+ {+ var bridge = OnTheRoad(WithRoad(), "banner_after", Text);+ using var ui = new UiTestKit();+ var card = new EventCardPresenter(ui.Root, bridge, Text, null);+ var banner = ui.Q<Label>("event-alt-banner");+ var shown = banner.text;+ card.Collapse();+ Assert.IsTrue(card.Collapsed);+ card.Reopen();+ Assert.AreEqual("banner_after", card.Shown!.Id);+ Assert.AreEqual(shown, banner.text);+ Assert.AreEqual(DisplayStyle.Flex, banner.style.display.value);+ UiTestKit.Press(ui.Q<Button>("option-hold"));+ Assert.AreNotEqual("banner_after", card.Shown!.Id, "the answer is queued and the next card shows");+ Assert.AreEqual(DisplayStyle.None, banner.style.display.value);+ Assert.AreEqual(0, ui.Q<VisualElement>("event-options").Query<Label>(className: EventCardPresenter.RejoinClass).ToList().Count);+ }++ /// <summary>A save from older content can name an option the road card no longer has: the card shows, with no banner.</summary>+ [Test]+ public void AStaleOptionOnTheRoadShowsNoBanner()+ {+ var bridge = OnTheRoad(WithRoad(), "banner_after", Text);+ bridge.State.ChosenOptions["banner_parent"] = "gone";+ using var ui = new UiTestKit();+ var card = new EventCardPresenter(ui.Root, bridge, Text, null);+ Assert.AreEqual("banner_after", card.Shown!.Id);+ Assert.AreEqual(DisplayStyle.None, ui.Q<Label>("event-alt-banner").style.display.value);+ }++ [Test]+ public void InHebrewTheBannerUsesTheRoadCardsHebrewFieldsAndTheRejoinLineUsesHebrew()+ {+ var c = WithRoad();+ var bridge = OnTheRoad(c, "banner_after", He);+ using var ui = new UiTestKit();+ new EventCardPresenter(ui.Root, bridge, He, null);+ Assert.AreEqual(He.Format("event.alt_origin", "הדרך שלא נבחרה", "הדרך של דוד בן-גוריון", "מה שקרה"), ui.Q<Label>("event-alt-banner").text);+ StringAssert.StartsWith("מסלול חלופי.", ui.Q<Label>("event-alt-banner").text);+ Assert.AreEqual(He["event.rejoin"], ui.Q<VisualElement>("event-options").Q<Label>(className: EventCardPresenter.RejoinClass).text);+ var chained = OnTheRoad(c, "banner_second", He);+ using var ui2 = new UiTestKit();+ new EventCardPresenter(ui2.Root, chained, He, null);+ Assert.AreEqual(He.Format("event.alt_origin_no_record", "Hold the course", "After the road"), ui2.Q<Label>("event-alt-banner").text);+ }++ [Test]+ public void InHebrewTheBannerFallsBackPerFieldAndKeepsAnEnglishVariantTitle()+ {+ var c = WithRoad();+ var bridge = OnTheRoad(c, "banner_after", He);+ var parent = c.Events.First(e => e.Id == "banner_parent");+ var taken = parent.Options.First(o => o.Id == "road");+ using var ui = new UiTestKit();+ var card = new EventCardPresenter(ui.Root, bridge, He, null);++ taken.TextHe = "";+ card.Render();+ Assert.AreEqual(He.Format("event.alt_origin", "The road not taken", "הדרך של דוד בן-גוריון", "מה שקרה"), ui.Q<Label>("event-alt-banner").text);++ taken.TextHe = "הדרך שלא נבחרה";+ parent.Variants.Add(new EventVariant+ {+ When = { new EventRequirement { Event = "banner_parent", Option = "road" } },+ Title = "A different road title",+ Text = "A different road text"+ });+ card.Render();+ Assert.AreEqual(He.Format("event.alt_origin", "הדרך שלא נבחרה", "A different road title", "מה שקרה"), ui.Q<Label>("event-alt-banner").text);+ }}diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex f360e0f7d..565b57aee 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -181,7 +181,9 @@</ui:VisualElement></ui:VisualElement><ui:VisualElement class="gold-rule" />- <ui:ScrollView name="event-scroll" class="event-scroll"><ui:Label name="event-text" class="event-text" /><ui:Label name="event-objective" class="muted event-objective" /></ui:ScrollView>+ <!-- event-alt-banner: a consequence card's road and the record beside it (#954), hidden on every other card;+ inside the scroll, so on a short window it scrolls with the text and never pushes the options away. -->+ <ui:ScrollView name="event-scroll" class="event-scroll"><ui:Label name="event-alt-banner" class="muted event-alt-banner" /><ui:Label name="event-text" class="event-text" /><ui:Label name="event-objective" class="muted event-objective" /></ui:ScrollView><!-- Shown only when the turn's Attention cannot pay for an answer (#1034): End Turn hands the card to its minister. --><ui:Label name="event-delegate" class="event-delegate" /><ui:VisualElement name="event-options" />diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex c32d304f9..3294ab90f 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -335,6 +335,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.event-text { white-space: normal; margin-bottom: 8px; }/* An objective card's line under its text (#380): when it was completed against history. */.event-objective { white-space: normal; margin-bottom: 8px; }+/* A consequence card's banner (#954): which road it follows and the record beside it, above the text; sober, in the muted+ ink, set off by a thin gold rule at its start edge. The rejoin line under an option is in the same muted ink,+ indented 46 px to line up with the option's text after its round sign (.event-option padding). */+.event-alt-banner { display: none; white-space: normal; margin: 0 0 8px 0; padding: 2px 0 2px 10px; border-left-width: 2px; border-color: var(--gold); }+.lang-he .event-alt-banner { border-left-width: 0; border-right-width: 2px; padding: 2px 10px 2px 0; }+.event-rejoin { white-space: normal; margin: -1px 0 4px 46px; }+.lang-he .event-rejoin { margin: -1px 46px 4px 0; }/* The line over the greyed-out options when the Attention left cannot pay for an answer (#1034). */.event-delegate { display: none; white-space: normal; margin: 4px 0; color: var(--gold-light); }.draft { display: none; color: var(--down); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); -unity-text-align: middle-center; }diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex afe2f28b6..5fc1dd75b 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -138,6 +138,12 @@ event.objective_early_one: "Completed on {0}; historically {1}; 1 month early."event.objective_on_time: "Completed on time, as in history."event.objective_late: "Completed {0} months later than in history."event.objective_late_one: "Completed 1 month later than in history."+# A consequence card's banner (#954; plan 2026-10-17-alternate-timelines.md, A.4.7): {0} the option the player took,+# {1} that card's title, {2} the record's option on it. A card chained on a consequence card has no record to compare:+# event.alt_origin_no_record. event.rejoin sits under an option that returns the course to the record (R-ALT-009).+event.alt_origin: "Alternative course. It follows the government's decision: {0} ({1}). In the record: {2}."+event.alt_origin_no_record: "Alternative course. It follows the government's decision: {0} ({1})."+event.rejoin: "Returns to the recorded course."start.listen: "Play the recording"start.stop: "Stop the recording"start.loading: "Loading the recording…"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 9e932ebe4..191c9a3fd 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -138,6 +138,10 @@ event.objective_early_one: "הושלם ב־{0}; בהיסטוריה ב־{1}; מוevent.objective_on_time: "הושלם בזמן, כמו בהיסטוריה."event.objective_late: "הושלם באיחור של {0} חודשים לעומת ההיסטוריה."event.objective_late_one: "הושלם באיחור של חודש אחד לעומת ההיסטוריה."+# A consequence card's banner and the rejoin line (#954). For the native reviewer (#564).+event.alt_origin: "מסלול חלופי. הוא נובע מהחלטת הממשלה: {0} ({1}). בהיסטוריה: {2}."+event.alt_origin_no_record: "מסלול חלופי. הוא נובע מהחלטת הממשלה: {0} ({1})."+event.rejoin: "חוזר למסלול ההיסטורי."start.listen: "השמעת ההקלטה"start.stop: "עצירת ההקלטה"start.loading: "טוען את ההקלטה…"