Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

UI: event cards list each option's effects from the sim preview (Refs #1125, #811) (#1839)

Berif849c0d48610
diff --git a/changelog.d/laneKT-1125.md b/changelog.d/laneKT-1125.md
new file mode 100644
index 000000000..71bae3d13
--- /dev/null
+++ b/changelog.d/laneKT-1125.md
@@ -0,0 +1,2 @@
+- Each option on an event card lists what it does under its label, in English and Hebrew: one line per effect, from the
+ simulation's preview (#1125, Refs #811). The option's label, price and selection are unchanged.
diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.cs
index 4b57e31d8..1bf1e229e 100644
--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs
+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs
@@ -32,6 +32,8 @@ namespace Statecraft.Game.UI
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";
+ /// <summary>One line under an option for one of its effects, from the sim's preview (#1125, R-EVT-005; Statecraft.uss).</summary>
+ public const string EffectClass = "event-effect";
readonly VisualElement card; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;
readonly EventImageCatalog? photos;
@@ -285,6 +287,15 @@ namespace Statecraft.Game.UI
b.AddToClassList(OptionClass);
b.SetEnabled(!unpaid);
options.Add(b);
+ // What the option does, one line per effect, from the sim's preview (#1125, R-EVT-005): Unity only words it. Under
+ // the option like the rejoin line, so a Label takes no Tab stop. The rejoin effect has that line already, below.
+ foreach (var preview in EventSystem.OptionEffectPreviews(c, s, o))
+ {
+ if (preview.Kind == OptionEffectPreviewKind.Rejoin) continue;
+ var effect = new Label(EffectLine(c, preview, text));
+ effect.AddToClassList("muted"); effect.AddToClassList(EffectClass);
+ options.Add(effect);
+ }
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"]);
@@ -296,6 +307,24 @@ namespace Statecraft.Game.UI
if (shown && focusedFor != e.Id) FocusCard(e.Id, force: false);
}
+ /// <summary>One option-effect row in the UI's language. An indicator, money or policy is named as the top bar and the Why
+ /// panel name it (why.name.&lt;id&gt;, Hebrew in Hebrew), the sim's English name where the strings have none; a project
+ /// unlock takes the kind's own Hebrew name (ContentNames).</summary>
+ public static string EffectLine(Content c, OptionEffectPreview row, UiText text)
+ {
+ var key = "why.name." + row.ContextId;
+ var name = row.Kind switch
+ {
+ OptionEffectPreviewKind.Amount or OptionEffectPreviewKind.SetPolicy => text.Has(key) ? text[key] : null,
+ OptionEffectPreviewKind.ProjectUnlock => HebrewKindName(text, c.ProjectKinds.First(k => k.Id == row.ContextId)),
+ _ => null,
+ };
+ return EventEffectText.Format(row, text, name);
+ }
+
+ /// <summary>The kind's Hebrew name in Hebrew; null otherwise, so the sim's capitalised English row stands.</summary>
+ static string? HebrewKindName(UiText text, ProjectKind k) { var n = ContentNames.Of(text, k); return n == k.Name ? null : n; }
+
/// <summary>An objective card's line under its text (#380; the owner's wording, #379): completed early, "Completed on
/// {date}; historically {date}; n months early."; in the same calendar month, "Completed on time, as in history.";
/// later, "Completed n months later than in history.". The dates are the recorded completion (GameState.Objectives)
diff --git a/unity/Assets/Scripts/UI/EventEffectText.cs b/unity/Assets/Scripts/UI/EventEffectText.cs
index 78ba3ace8..1a286728f 100644
--- a/unity/Assets/Scripts/UI/EventEffectText.cs
+++ b/unity/Assets/Scripts/UI/EventEffectText.cs
@@ -4,7 +4,7 @@ using Statecraft.Sim;
namespace Statecraft.Game.UI
{
- /// <summary>Localized words around the sim's already formatted option-effect amounts. Not yet wired to the card.</summary>
+ /// <summary>Localized words around the sim's already formatted option-effect amounts. The event card shows these under each option (EventCardPresenter, #1125).</summary>
public static class EventEffectText
{
/// <param name="contextName">Optional localized indicator, money, city, project kind, policy or event name from the caller.
diff --git a/unity/Assets/Tests/EditMode/EventCardTests.cs b/unity/Assets/Tests/EditMode/EventCardTests.cs
index b78e497a4..01ad63455 100644
--- a/unity/Assets/Tests/EditMode/EventCardTests.cs
+++ b/unity/Assets/Tests/EditMode/EventCardTests.cs
@@ -772,4 +772,75 @@ sources: [{ url: ""https://example.org/record"", checked: 2026-10-17 }]
else Assert.AreEqual(remaining == 1 ? "1 more decision waiting" : "2 more decisions waiting", actual);
}
+ /// <summary>The Altalena card on 15 June 1948 with its content and state, so a test can ask the sim what each option does.
+ /// <c>before</c> is the state's hash taken before the presenter is built, so a test can prove that rendering the card changes nothing.</summary>
+ static (UiTestKit ui, Content c, GameState s, GameEvent e, string before) AltalenaWithState(UiText text)
+ {
+ var c = ContentLoader.Load(Paths.Content);
+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);
+ g.State.Date = new System.DateTime(1948, 6, 15);
+ g.State.PendingEvents.Clear(); g.State.PendingEvents.Add("altalena");
+ var before = g.State.Hash();
+ var ui = new UiTestKit();
+ new EventCardPresenter(ui.Root, new SimBridge(g, text), text, null);
+ return (ui, c, g.State, c.Events.First(x => x.Id == "altalena"), before);
+ }
+
+ /// <summary>R-EVT-005, #1125: under each option the card lists what the option does, the sim's preview rows (the same
+ /// list OptionEffects walks) put into words by EventEffectText, in either language. The option's own label and price stay
+ /// in the button; the rows sit beside it as plain labels, so Tab still reaches only the options.</summary>
+ [TestCase(false)] [TestCase(true)]
+ public void EachOptionListsItsEffectsUnderItFromTheSimPreview(bool hebrew)
+ {
+ var text = hebrew ? He : Text;
+ var (ui, c, s, e, before) = AltalenaWithState(text);
+ using (ui)
+ {
+ var children = ui.Q<VisualElement>("event-options").Children().ToList();
+ var listed = 0;
+ foreach (var o in e.Options)
+ {
+ var button = ui.Q<Button>("option-" + o.Id);
+ var rows = EventSystem.OptionEffectPreviews(c, s, o).Where(r => r.Kind != OptionEffectPreviewKind.Rejoin)
+ .Select(r => EventCardPresenter.EffectLine(c, r, text)).ToList();
+ var shown = children.Skip(children.IndexOf(button) + 1).TakeWhile(x => !(x is Button)).OfType<Label>()
+ .Where(x => x.ClassListContains(EventCardPresenter.EffectClass)).ToList();
+ Assert.AreEqual(rows, shown.Select(x => x.text).ToList(), o.Id);
+ Assert.IsTrue(shown.All(x => !x.focusable), "Tab still reaches only the options");
+ Assert.IsTrue(button.enabledSelf);
+ listed += rows.Count;
+ }
+ Assert.Greater(listed, 0, "precondition: the card has effects to show");
+ Assert.AreEqual(before, s.Hash(), "showing the preview changes nothing in the game");
+ }
+ }
+
+ /// <summary>The wording itself, pinned in both languages: the first row of the first two options.
+ /// The Hebrew rows name the indicator as the top bar does (why.name.*), not the sim's English name.</summary>
+ [TestCase(false, "Security +1.5%", "Security -2.5%")]
+ [TestCase(true, "ביטחון: שינוי +1.5%", "ביטחון: שינוי -2.5%")]
+ public void TheEffectRowsReadInTheUiLanguage(bool hebrew, string enforceFirst, string compromiseFirst)
+ {
+ var (ui, _, _, _, _) = AltalenaWithState(hebrew ? He : Text);
+ using (ui)
+ {
+ var children = ui.Q<VisualElement>("event-options").Children().ToList();
+ string First(string option) => ((Label)children[children.IndexOf(ui.Q<Button>("option-" + option)) + 1]).text.Replace(UiText.LeftToRightMark.ToString(), "");
+ Assert.AreEqual(enforceFirst, First("enforce"));
+ Assert.AreEqual(compromiseFirst, First("compromise"));
+ }
+ }
+
+ /// <summary>An option that rejoins the record already has its own line (R-ALT-009); the preview does not say it twice.</summary>
+ [Test]
+ public void ARejoinOptionGetsNoSecondRejoinRowFromThePreview()
+ {
+ var bridge = OnTheRoad(WithRoad(), "banner_after", Text);
+ using var ui = new UiTestKit();
+ new EventCardPresenter(ui.Root, bridge, Text, null);
+ Assert.AreEqual(1, ui.Q<VisualElement>("event-options").Query<Label>(className: EventCardPresenter.RejoinClass).ToList().Count);
+ var joined = string.Join("|", ui.Q<VisualElement>("event-options")
+ .Query<Label>(className: EventCardPresenter.EffectClass).ToList().Select(x => x.text));
+ Assert.IsFalse(joined.Contains("recorded course:", System.StringComparison.Ordinal), joined);
+ }
}
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 52404a5ad..618bb42fb 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -352,12 +352,12 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* 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). */
+ ink, set off by a thin gold rule at its start edge. The rejoin line and the effect lines (#1125) under an
+ option are 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; }
+.event-rejoin, .event-effect { white-space: normal; margin: -1px 0 4px 46px; }
+.lang-he .event-rejoin, .lang-he .event-effect { 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); }
/* The capture dialog (CaptureDialogPresenter): under each option its plain description, then the sim's preview of what