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: the score's parts follow the score (Refs #812) (#3078)
Eyal Golan9546f0cc1e44
diff --git a/changelog.d/e6-812-end-score-parts.md b/changelog.d/e6-812-end-score-parts.mdnew file mode 100644index 000000000..7cf4db91a--- /dev/null+++ b/changelog.d/e6-812-end-score-parts.md@@ -0,0 +1,3 @@+- The end screen shows the score's parts right after the score (Refs #812; R-SCORE-001): the score from objectives and+ from early completion, each even at 0, and the score from prisoners returned when there is one, so the rows add up to+ the score. The numbers are the sim's own (the end report's score parts), in English and Hebrew.diff --git a/unity/Assets/Scripts/UI/EndScreenPresenter.cs b/unity/Assets/Scripts/UI/EndScreenPresenter.csindex c007f6b8d..0fb652728 100644--- a/unity/Assets/Scripts/UI/EndScreenPresenter.cs+++ b/unity/Assets/Scripts/UI/EndScreenPresenter.cs@@ -78,7 +78,8 @@ namespace Statecraft.Game.UIpublic bool ClosedThisFrame => closedAt == UnityEngine.Time.frameCount;/// <summary>The screen's lines for an ended game, in order: the outcome, its history note when it has one, the end- /// date, the score, the reference score, one per objective, each Deport card that never fired (its title, then its+ /// date, the score, its parts (objective points and early-completion bonuses, each even at 0, then prisoner points when+ /// some were scored), the reference score, one per objective, each Deport card that never fired (its title, then its/// text), Social cohesion, International Support, the population with its CBS anchor, that anchor's sources 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)@@ -105,6 +106,12 @@ namespace Statecraft.Game.UIif (t.Has(outcome) && t.Has(note)) lines.Add(("note", t[note]));lines.Add(("date", t.Format("end.date", Date(r.Date)))); // R-END-005 (#2545)lines.Add(("score", t.Format("hud.score", r.Score)));+ // #812 (GDD Phase 7 PR 9, "the score and its parts"; R-SCORE-001): the parts as the sim recorded them, so the rows+ // add up to the score. Objectives and timing show even at 0; the prisoner points only when some were scored (the+ // #812 notice: "Do not invent zero/placeholder prisoner or war rows").+ lines.Add(("score-objectives", t.Format("end.score_objectives", r.ScoreParts.ObjectivePoints)));+ lines.Add(("score-timing", t.Format("end.score_timing", r.ScoreParts.TimingBonuses)));+ if (r.ScoreParts.PrisonerPoints > 0) lines.Add(("score-prisoners", t.Format("end.score_prisoners", r.ScoreParts.PrisonerPoints)));// Q-SCORE-2: beside the score, what a run on the historical dates scores (the sim's number; nothing computed here).if (r.ReferenceScore > 0) lines.Add(("score-reference", t.Format("end.reference_score", r.ReferenceScore)));foreach (var o in r.Objectives)diff --git a/unity/Assets/Tests/EditMode/EndScreenTests.cs b/unity/Assets/Tests/EditMode/EndScreenTests.csindex 8134015c5..039e7a207 100644--- a/unity/Assets/Tests/EditMode/EndScreenTests.cs+++ b/unity/Assets/Tests/EditMode/EndScreenTests.cs@@ -247,7 +247,7 @@ public class EndScreenTestsAssert.IsTrue(k.End.IsOpen, "a loaded ended game opens on its end screen");var s = k.Bridge.State; var r = EndReport.For(C, s);var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();- var expected = new[] { "outcome", "date", "score", "score-reference" }.Concat(r.Objectives.Select(o => "objective-" + o.Id))+ var expected = new[] { "outcome", "date", "score", "score-objectives", "score-timing", "score-reference" }.Concat(r.Objectives.Select(o => "objective-" + o.Id)).Concat(new[] { "cohesion", "standing", "population", "population-sources" }).Select(n => "end-screen-" + n);CollectionAssert.AreEqual(expected, names, "the report's parts, in order");Assert.AreEqual(En["end.outcome.mvp_ended"], k.Line("outcome"));@@ -274,6 +274,63 @@ public class EndScreenTestsAssert.AreEqual(En.Format("unit.sources", "www.cbs.gov.il"), k.Line("population-sources"));}+ /// <summary>#812 (GDD Phase 7 PR 9: "the score and its parts"; R-SCORE-001): right after the score, one row per part of+ /// it as the sim recorded it (EndReport.ScoreParts): objective points, the early-completion bonuses and the prisoner+ /// points, so the rows add up to the score. Ended completes one objective a month early (100 + 5, rules.yaml+ /// objective_points, objective_bonus_per_month); 1,200 prisoner points are set directly with the score kept equal to the+ /// parts, since the screen formats the recorded parts and computes nothing. A part over 999 takes the invariant group+ /// separator in both languages (the Mac runs he_IL).</summary>+ [Test]+ public void ShowsEveryPartOfTheScore()+ {+ using var k = new Kit(En, s => { Ended(s); s.ScorePrisonerPoints += 1200; s.Score += 1200; });+ var st = k.Bridge.State; var parts = EndReport.For(C, st).ScoreParts;+ Assert.AreEqual(100, parts.ObjectivePoints, "precondition: one objective's points");+ Assert.AreEqual(5, parts.TimingBonuses, "precondition: one month early");+ Assert.AreEqual(1200, parts.PrisonerPoints, "precondition: the prisoner points set");+ Assert.AreEqual(st.Score, parts.ObjectivePoints + parts.TimingBonuses + parts.PrisonerPoints, "precondition: the parts sum to the score");+ var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();+ var at = names.IndexOf("end-screen-score");+ Assert.GreaterOrEqual(at, 0, "the score row: " + string.Join(", ", names));+ CollectionAssert.AreEqual(new[] { "end-screen-score", "end-screen-score-objectives", "end-screen-score-timing", "end-screen-score-prisoners" },+ names.Skip(at).Take(4), "the parts follow the score");+ Assert.AreEqual("Score from objectives: 100", k.Line("score-objectives"));+ Assert.AreEqual("Score from early completion: 5", k.Line("score-timing"));+ Assert.AreEqual("Score from prisoners returned: 1,200", k.Line("score-prisoners"));+ var he = EndScreenPresenter.Lines(C, st, He);+ Assert.AreEqual("ניקוד מיעדים: \u200e100\u200e", he.Single(l => l.Name == "score-objectives").Text);+ Assert.AreEqual("ניקוד מהשלמה מוקדמת: \u200e5\u200e", he.Single(l => l.Name == "score-timing").Text);+ Assert.AreEqual("ניקוד משבויים שהוחזרו: \u200e1,200\u200e", he.Single(l => l.Name == "score-prisoners").Text);+ }++ /// <summary>#812: the prisoner points show only when some were scored. The #812 notice: "Do not invent zero/placeholder+ /// prisoner or war rows". Objectives and timing still show, the zero one included: the objective is completed on its+ /// historical date, so it earns no timing bonus (R-SCORE-001, HistoricalDatesScoreNoBonus), and no prisoners went home.</summary>+ [Test]+ public void ShowsThePrisonerPointsOnlyWhenSomeWereScored()+ {+ using var k = new Kit(En, s =>+ {+ var first = C.Objectives.Single(o => o.Id == "absorb_immigrants"); // on its historical date: no timing bonus+ Objectives.Record(C, s, C.RulesAt(s.Date).Mvp!, first.Id, first.ReferenceDate, new List<Cause>());+ s.Date = C.End;+ s.GameOver = GameOverCodes.MvpEnded;+ });+ var parts = EndReport.For(C, k.Bridge.State).ScoreParts;+ Assert.AreEqual(0, parts.PrisonerPoints, "precondition: no prisoners returned");+ Assert.AreEqual(0, parts.TimingBonuses, "precondition: no timing bonus");+ var names = k.Ui.Q<ScrollView>("end-screen-rows").Children().Select(x => x.name).ToList();+ CollectionAssert.DoesNotContain(names, "end-screen-score-prisoners", "no prisoner row at 0");+ var at = names.IndexOf("end-screen-score");+ Assert.GreaterOrEqual(at, 0, "the score row: " + string.Join(", ", names));+ CollectionAssert.AreEqual(new[] { "end-screen-score", "end-screen-score-objectives", "end-screen-score-timing" },+ names.Skip(at).Take(3), "objectives and timing follow the score, a zero part included");+ Assert.AreEqual("Score from early completion: 0", k.Line("score-timing"));+ var he = EndScreenPresenter.Lines(C, k.Bridge.State, He);+ Assert.IsFalse(he.Any(l => l.Name == "score-prisoners"), "nor in Hebrew");+ Assert.AreEqual("ניקוד מהשלמה מוקדמת: \u200e0\u200e", he.Single(l => l.Name == "score-timing").Text);+ }+/// <summary>#2545 (R-END-006): the sources row follows the anchor. A game that ends before the first anchor has no/// comparison and so no sources row, and an anchor with no readable source URL gets no bare "Sources:" row either.</summary>[Test]diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex e0f9b634f..bfa382756 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -589,6 +589,10 @@ end.parameter: "{0}: {1}"end.population: "Population: {0}"end.population_history: "Population: {0}; CBS, Jewish population, {1}: {2}"end.date: "Ended on {0}"+# The score's parts (#812; R-SCORE-001), right after the score: EndReport.ScoreParts; the prisoner points only when above 0.+end.score_objectives: "Score from objectives: {0:N0}"+end.score_timing: "Score from early completion: {0:N0}"+end.score_prisoners: "Score from prisoners returned: {0:N0}"cabinet.coalition: "Coalition: {0} of {1} {3} · stability {2}"cabinet.vacant: "(vacant)"cabinet.person: "{0} · {1} · competence {2}, loyalty {3}"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 49fe134ae..849d3439f 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -694,6 +694,11 @@ end.population: "אוכלוסייה: {0}"end.population_history: "אוכלוסייה: {0}; האוכלוסייה היהודית לפי הלמ״ס ב־{1}: {2}"# For the native reviewer (#564): the end screen's end date (#2545).end.date: "הסתיים ב־{0}"+# For the native reviewer (#564): the score's parts on the end screen (#812); "ניקוד" as hud.score, "שבויים שהוחזרו" as+# defence.prisoners_returned, "השלמה מוקדמת" for the months-early bonus.+end.score_objectives: "ניקוד מיעדים: {0:N0}"+end.score_timing: "ניקוד מהשלמה מוקדמת: {0:N0}"+end.score_prisoners: "ניקוד משבויים שהוחזרו: {0:N0}"# For the native reviewer (#564)cabinet.coalition: "קואליציה: {0} מתוך {1} {3} · יציבות {2}"