A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
End screen: history-note code path; armistice string held until the person's check (Refs #812) (#1966)
Beri2e940eead780
diff --git a/changelog.d/laneMG-812.md b/changelog.d/laneMG-812.mdnew file mode 100644index 000000000..265f2b114--- /dev/null+++ b/changelog.d/laneMG-812.md@@ -0,0 +1,3 @@+- The end screen can show a cause's sourced history note under its line (Q-DEF-4 (b)); a cause without a note goes+ straight from its line to the score. The armistice note for a war loss is held out of the strings until the person's+ check of the history note is recorded, so no ending shows a note yet (Refs #812).diff --git a/unity/Assets/Scripts/UI/EndScreenPresenter.cs b/unity/Assets/Scripts/UI/EndScreenPresenter.csindex 285cc2ad8..671f217cd 100644--- a/unity/Assets/Scripts/UI/EndScreenPresenter.cs+++ b/unity/Assets/Scripts/UI/EndScreenPresenter.cs@@ -68,9 +68,9 @@ namespace Statecraft.Game.UI/// <summary>True in the frame the screen closed (GameRoot's Escape poll, as TurnReportPresenter.ClosedThisFrame).</summary>public bool ClosedThisFrame => closedAt == UnityEngine.Time.frameCount;- /// <summary>The screen's lines for an ended game, in order: the outcome, the score, one per objective, Social cohesion,- /// International Support, the population with its CBS anchor and, when some went home, the prisoners returned. Every- /// value is the report's.</summary>+ /// <summary>The screen's lines for an ended game, in order: the outcome, its history note when it has one, the score,+ /// one per objective, Social cohesion, International Support, the population with its CBS anchor and, when some went+ /// home, the prisoners returned. Every value is the report's.</summary>public static IReadOnlyList<(string Name, string Text)> Lines(Content c, GameState s, UiText t){var r = EndReport.For(c, s);@@ -80,8 +80,12 @@ namespace Statecraft.Game.UIvar lines = new List<(string, string)>{("outcome", t.Has(outcome) ? t[outcome] : t["order.game_over"]),- ("score", t.Format("hud.score", r.Score)),};+ // The sourced history note under the cause's line (Q-DEF-4 (b)); only a cause whose note is in the strings has one,+ // and only under that cause's own line, never under the generic one.+ var note = "end.note." + r.Outcome;+ if (t.Has(outcome) && t.Has(note)) lines.Add(("note", t[note]));+ lines.Add(("score", t.Format("hud.score", r.Score)));foreach (var o in r.Objectives){var title = EventSystem.Title(c, s, c.Events.First(e => e.Id == o.Card)); // as the objective's card shows it@@ -105,7 +109,7 @@ namespace Statecraft.Game.UIforeach (var (name, line) in Lines(bridge.Content, bridge.State, text)){var label = new Label(line) { name = "end-screen-" + name };- label.AddToClassList(name == "outcome" ? "end-screen-outcome" : "end-screen-line");+ label.AddToClassList(name == "outcome" ? "end-screen-outcome" : name == "note" ? "end-screen-note" : "end-screen-line");rows.Add(label);}screen.style.display = DisplayStyle.Flex;diff --git a/unity/Assets/Tests/EditMode/EndScreenTests.cs b/unity/Assets/Tests/EditMode/EndScreenTests.csindex 42647568e..f89b8fbbb 100644--- a/unity/Assets/Tests/EditMode/EndScreenTests.cs+++ b/unity/Assets/Tests/EditMode/EndScreenTests.cs@@ -132,6 +132,50 @@ public class EndScreenTestsDate(anchor.Date), anchor.Jews.ToString("N0", System.Globalization.CultureInfo.InvariantCulture)), k.Line("population"));}+ /// <summary>A cause's history note (Q-DEF-4 (b)) sits right under its line when the strings carry one, and nowhere else.+ /// The armistice note is held out of the strings until the person's check is recorded, so a fixture string stands in.</summary>+ [Test]+ public void AWarLossShowsItsHistoryNoteUnderItsLineAndOtherOutcomesShowNone()+ {+ var withNote = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text + "\nend.note.defeat_war: \"Fixture note.\"\n");+ using var k = new Kit(withNote, s => { s.Date = C.End; s.GameOver = GameOverCodes.DefeatWar; });+ var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();+ CollectionAssert.AreEqual(new[] { "end-screen-outcome", "end-screen-note", "end-screen-score" }, names.Take(3), "the note follows the outcome line");+ Assert.AreEqual("Fixture note.", k.Line("note"));+ Assert.IsTrue(k.Ui.Q<Label>("end-screen-note").ClassListContains("end-screen-note"));+ using var ended = new Kit(withNote, Ended);+ Assert.IsFalse(ended.Ui.Q<ScrollView>("end-screen-rows").Children().Any(x => x.name == "end-screen-note"), "no note for the MVP end");+ }++ /// <summary>A regression guard (it passes without the note change too): with no note in the strings (the shipped EN and HE+ /// files, until the person's check), a war loss goes straight from its line to the score: no note row, no empty gap.+ /// Adding the note string back means updating this test too.</summary>+ [Test]+ public void AWarLossWithNoNoteStringGoesStraightFromItsLineToTheScore()+ {+ foreach (var text in new[] { En, He })+ {+ using var k = new Kit(text, s => { s.Date = C.End; s.GameOver = GameOverCodes.DefeatWar; });+ var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();+ CollectionAssert.AreEqual(new[] { "end-screen-outcome", "end-screen-score" }, names.Take(2), "the score follows the outcome line");+ CollectionAssert.DoesNotContain(names, "end-screen-note");+ }+ }++ /// <summary>A note follows only its own cause's line: an outcome with no line of its own (a legacy code, shown as the+ /// generic game-over line) gets no note even when the strings carry one for it.</summary>+ [Test]+ public void ANoteNeverFollowsTheGenericGameOverLine()+ {+ var withNote = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text + "\nend.note.coalition_collapse: \"Fixture note.\"\n");+ Assert.IsFalse(withNote.Has("end.outcome." + GameOverCodes.CoalitionCollapse), "precondition: the legacy code has no outcome line");+ using var k = new Kit(withNote, s => { s.Date = C.End; s.GameOver = GameOverCodes.CoalitionCollapse; });+ Assert.AreEqual(withNote["order.game_over"], k.Line("outcome"), "precondition: the generic line shows");+ var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();+ CollectionAssert.AreEqual(new[] { "end-screen-outcome", "end-screen-score" }, names.Take(2), "the score follows the generic line");+ CollectionAssert.DoesNotContain(names, "end-screen-note");+ }+// Q-END-3: the prisoners returned, worded as Defence words them, only when some went home (no zero row).[Test]public void ShowsThePrisonersReturnedOnlyWhenSomeWentHome()diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 80be77fa2..db0eb5867 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -558,6 +558,8 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas/* The end screen (#812) reuses the report's backdrop and panel: its outcome in the heading face, one line per part. */.end-screen-outcome { white-space: normal; margin-bottom: 10px; color: var(--gold-light); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); }.end-screen-line { white-space: normal; margin-bottom: 6px; }+/* The history note under a defeat line: quieter than the line above it, still above the contrast floor (--ink-dim on --navy). */+.end-screen-note { white-space: normal; margin-bottom: 14px; color: var(--ink-dim); }.turn-report-actions { justify-content: flex-end; margin-top: 8px; flex-shrink: 0; }.turn-report-actions > Button { margin-left: 8px; }/* How to play's button that opens the opening advice again: under the lines, never squeezed by them. */