A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Tour: the gdd-0.3 opening tour skips the Attention step (Refs #1688) (#1828)
Eyal Golan82b23ad59b6b
diff --git a/changelog.d/1688-tour-slice2.md b/changelog.d/1688-tour-slice2.mdnew file mode 100644index 000000000..8578a74ab--- /dev/null+++ b/changelog.d/1688-tour-slice2.md@@ -0,0 +1 @@+- Skip the Attention lesson in the gdd-0.3 opening tour while preserving its remaining steps and the full legacy/gdd-0.1 tour.diff --git a/unity/Assets/Scripts/UI/AdvisorPresenter.cs b/unity/Assets/Scripts/UI/AdvisorPresenter.csindex 6a9de17b0..5ceaa970c 100644--- a/unity/Assets/Scripts/UI/AdvisorPresenter.cs+++ b/unity/Assets/Scripts/UI/AdvisorPresenter.cs@@ -407,6 +407,7 @@ namespace Statecraft.Game.UIreturn local;}+ // Original catalogue position, retained for existing callers; runtime routing uses message identity.public const int EventStep = 5;public IReadOnlyList<AdvisorCatalog.Message> Chain => chain;public bool InChain => session.Chain.Step >= 0 && IsOpen;@@ -426,7 +427,12 @@ namespace Statecraft.Game.UIreturn line;}- bool InTour(AdvisorCatalog.Message message) => message.ApprovedIn(hebrew) && AdvisorSignals.When(Context(), message.When);+ // R-GOV-002 / #1688: keep the complete requires chain, but omit the obsolete resource lesson in 0.3.+ // A skip is not Queue.Done: it must never write Attention into the shared seen preferences.+ bool IncludedInTour(AdvisorCatalog.Message message) =>+ bridge.Content.Ruleset != SaveGame.Gdd03Ruleset || message.Id != "opening.attention";+ static bool IsEventStep(AdvisorCatalog.Message message) => message.Id == "opening.event";+ bool InTour(AdvisorCatalog.Message message) => IncludedInTour(message) && message.ApprovedIn(hebrew) && AdvisorSignals.When(Context(), message.When);int NextChainStep(int after){for (int i = after + 1; i < chain.Count; i++) if (InTour(chain[i])) return i;@@ -458,7 +464,7 @@ namespace Statecraft.Game.UI{int step = session.Chain.Step;if (disposed || step < 0 || step >= chain.Count || !chain[step].ApprovedIn(hebrew)) return;- session.Queue.Done(chain[step], Turn, bridge.State.Date);+ if (IncludedInTour(chain[step])) session.Queue.Done(chain[step], Turn, bridge.State.Date);int next = NextChainStep(step);if (next < 0) CloseChain(); else ShowStep(next);}@@ -482,15 +488,22 @@ namespace Statecraft.Game.UIvoid ShowStep(int step){session.Chain.Step = step;+ // A retained original index can be restored on a presenter rebuild. Route before Fill/targets/media.+ if (!IncludedInTour(chain[step]))+ {+ int next = NextChainStep(step);+ if (next < 0) CloseChain(); else ShowStep(next);+ return;+ }if (!chain[step].ApprovedIn(hebrew)) { Shown = null; Hide(); return; }if (Covered(hudRoot)) { Hide(); return; }// The same step drawn again (the game changed under it, or a layer over it closed): its city or unit stays as// the player has it now, rather than being put back and shown again on every change.bool same = ReferenceEquals(Shown, chain[step]) && target != null;if (!same) ClearTarget();- if (step == EventStep) session.Chain.EventShown = true;+ if (IsEventStep(chain[step])) session.Chain.EventShown = true;Fill(chain[step]);- bool Counted(int i) => chain[i].ApprovedIn(hebrew) && (i == EventStep ? session.Chain.EventShown || InTour(chain[i]) : InTour(chain[i]));+ bool Counted(int i) => IncludedInTour(chain[i]) && chain[i].ApprovedIn(hebrew) && (IsEventStep(chain[i]) ? session.Chain.EventShown || InTour(chain[i]) : InTour(chain[i]));int number = Enumerable.Range(0, step + 1).Count(Counted), total = Enumerable.Range(0, chain.Count).Count(Counted);count.text = text.Format("advisor.step", number, total);gotIt.text = text[NextChainStep(step) < 0 ? "advisor.done" : "advisor.next"];@@ -504,9 +517,10 @@ namespace Statecraft.Game.UI{if (session.Chain.Step < 0) return;if (Turn != session.Chain.OpenTurn) { CloseChain(hooks.Card?.Shown?.Id == session.Chain.CardEvent); return; }+ if (!IncludedInTour(chain[session.Chain.Step])) { ShowStep(session.Chain.Step); return; }if (!chain[session.Chain.Step].ApprovedIn(hebrew)) { Shown = null; Hide(); return; }if (Covered(hudRoot)) { Hide(); return; }- if (session.Chain.Step == EventStep && hooks.Card?.Shown == null)+ if (IsEventStep(chain[session.Chain.Step]) && hooks.Card?.Shown == null){NextStep(); // the card was answered: on to the next stepif (InChain) TakeFocusFromTheCard();diff --git a/unity/Assets/Tests/EditMode/AdvisorGameTests.cs b/unity/Assets/Tests/EditMode/AdvisorGameTests.csindex cbaeb50d7..cd2b1da89 100644--- a/unity/Assets/Tests/EditMode/AdvisorGameTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorGameTests.cs@@ -105,3 +105,42 @@ public class AdvisorGameTestsAssert.AreEqual(save, store.ReadAutosave(), "the save file");}}+++public class AdvisorGameNoAttentionTests+{+ // R-GOV-002: replacement on the same bridge consults the current session ruleset.+ [TestCase(Statecraft.Sim.SaveGame.LegacyRuleset)] [TestCase(Statecraft.Sim.SaveGame.GddRuleset)]+ public void NewSessionRestoresOldTourWithoutLeakingSkippedSeenState(string olderRuleset)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(); rig.Advisor.OpenChain(); rig.Advisor.NextStep();+ Assert.AreEqual("opening.city", rig.Advisor.Shown?.Id);+ rig.Bridge.Replace(Statecraft.Sim.GameSession.New(AdvisorTour1688Fixture.Content(olderRuleset), 1, Statecraft.Sim.Mode.Historical));+ rig.Advisor.NewGame(); rig.Advisor.OpenChain(); rig.Advisor.NextStep();+ Assert.AreEqual("opening.attention", rig.Advisor.Shown?.Id);+ Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ rig.Advisor.NextStep(); Assert.IsTrue(rig.Session.Settings.Seen("opening.attention"));+ rig.Bridge.Replace(Statecraft.Sim.GameSession.New(AdvisorTour1688Fixture.Content(), 1, Statecraft.Sim.Mode.Historical));+ rig.Advisor.NewGame(); rig.Advisor.OpenChain(); rig.Advisor.NextStep();+ Assert.AreEqual("opening.city", rig.Advisor.Shown?.Id);+ Assert.IsEmpty(System.Linq.Enumerable.Where(rig.Session.Queue.History, e => e.Id == "opening.attention"));+ }++ // R-GOV-002: load gets a fresh advisor session, no automatic/persisted traversal.+ [Test]+ public void LoadDoesNotResumeTourButManualReplayStillSkipsAttention()+ {+ var c = AdvisorTour1688Fixture.Content(); var game = Statecraft.Sim.GameSession.New(c, 1, Statecraft.Sim.Mode.Historical);+ var save = game.Save.Write();+ using (var first = new AdvisorTour1688Fixture.Rig(game: game))+ {+ first.Advisor.OpenChain(); first.Advisor.NextStep(); Assert.AreEqual("opening.city", first.Advisor.Shown?.Id);+ }+ var loaded = Statecraft.Sim.GameSession.Load(c, save, out var warnings); Assert.IsEmpty(warnings);+ using var rig = new AdvisorTour1688Fixture.Rig(game: loaded);+ rig.Advisor.Resume(); Assert.IsFalse(rig.Advisor.InChain);+ rig.Advisor.OpenChain(); rig.Advisor.NextStep(); Assert.AreEqual("opening.city", rig.Advisor.Shown?.Id);+ rig.Advisor.CloseChain(); Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ Assert.AreEqual(save, loaded.Save.Write()); Assert.IsEmpty(rig.Bridge.Queued);+ }+}diff --git a/unity/Assets/Tests/EditMode/AdvisorOpeningParityTests.cs b/unity/Assets/Tests/EditMode/AdvisorOpeningParityTests.csindex 49fdfd0bf..5311bbeb7 100644--- a/unity/Assets/Tests/EditMode/AdvisorOpeningParityTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorOpeningParityTests.cs@@ -1021,3 +1021,218 @@ public class AdvisorOpeningParityTests}}}+++public class AdvisorOpeningNoAttentionParityTests+{+ // R-GOV-002: both language rebuild directions preserve indices and visible positions.+ [TestCase(false)] [TestCase(true)]+ public void RebuildKeepsEveryVisibleStepAndItsPosition(bool startsHebrew)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(startsHebrew); rig.Advisor.OpenChain();+ for (int n = 0; n < AdvisorTour1688Fixture.Visible.Length; n++)+ {+ var id = AdvisorTour1688Fixture.Visible[n]; Assert.AreEqual(id, rig.Advisor.Shown?.Id);+ var index = rig.Session.Chain.Step; rig.Rebuild(!startsHebrew);+ Assert.AreEqual(id, rig.Advisor.Shown?.Id); Assert.AreEqual(index, rig.Advisor.ChainStep);+ Assert.AreEqual(AdvisorTour1688Fixture.Text(!startsHebrew).Format("advisor.step", n + 1, 6), rig.Ui.Q<Label>("advisor-count").text);+ rig.Rebuild(startsHebrew); Assert.AreEqual(id, rig.Advisor.Shown?.Id); rig.Advisor.NextStep();+ }+ Assert.IsFalse(rig.Advisor.InChain); Assert.AreEqual("player", rig.Selection);+ Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ }++ // R-GOV-002: base has no Back control. Restore earlier retained steps, including+ // the original Attention index; it must route forward without being marked seen.+ [Test]+ public void BackwardRetainedStepRestorationNeverRendersAttention()+ {+ using var rig = new AdvisorTour1688Fixture.Rig(); rig.Advisor.OpenChain();+ rig.Advisor.NextStep(); Assert.AreEqual("opening.city", rig.Advisor.Shown?.Id);+ foreach (var index in new[] { 0, 1, 0, 2 })+ {+ rig.Advisor.Dispose(); rig.Session.Chain.Step = index; rig.Rebuild(false);+ Assert.AreEqual(index < 1 ? "opening.greeting" : "opening.city", rig.Advisor.Shown?.Id);+ Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ }+ }++ // R-GOV-002: the event message opens the card, after four visible predecessors.+ [TestCase(false)] [TestCase(true)]+ public void EventMessageOpensTheCardAndResumesAfterBothSyntheticDecisions(bool he)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(he); rig.Advisor.OpenChain();+ foreach (var id in AdvisorTour1688Fixture.Visible.Take(4))+ {+ Assert.AreEqual(id, rig.Advisor.Shown?.Id); Assert.IsTrue(rig.Card.Collapsed); rig.Advisor.NextStep();+ }+ Assert.AreEqual("opening.event", rig.Advisor.Shown?.Id); Assert.IsTrue(rig.Card.Collapsed);+ rig.Ui.Press("advisor-show-me"); Assert.IsFalse(rig.Card.Collapsed); Assert.IsFalse(rig.Advisor.IsOpen);+ rig.Card.Collapse(); Assert.AreEqual("opening.event", rig.Advisor.Shown?.Id); Assert.IsTrue(rig.Advisor.IsOpen);+ rig.Ui.Press("advisor-show-me"); UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ Assert.AreEqual("tour_test_b", rig.Card.Shown?.Id); Assert.IsFalse(rig.Advisor.IsOpen);+ UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ Assert.IsNull(rig.Card.Shown); Assert.AreEqual("opening.objectives", rig.Advisor.Shown?.Id);+ Assert.AreEqual(AdvisorTour1688Fixture.Text(he).Format("advisor.step", 6, 6), rig.Ui.Q<Label>("advisor-count").text);+ Assert.IsTrue(rig.Advisor.IsOpen); Assert.AreEqual("player", rig.Selection);+ }++ // R-GOV-002: a missing decision is another skip; requires cannot block objectives.+ [Test]+ public void NoDecisionSkipsEventWithoutBlockingObjectives()+ {+ using var rig = new AdvisorTour1688Fixture.Rig();+ UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ rig.Advisor.OpenChain(); var ids = new List<string>();+ while (rig.Advisor.InChain) { ids.Add(rig.Advisor.Shown!.Id); Assert.LessOrEqual(ids.Count, 5); rig.Advisor.NextStep(); }+ CollectionAssert.AreEqual(AdvisorTour1688Fixture.Visible.Where(id => id != "opening.event"), ids);+ }+}+++public class AdvisorOpeningEventIdentityTests+{+ // R-GOV-002: shift the catalogue event index with a synthetic, condition-skipped step.+ // A positional EventStep check would lose the event from the total after its card is answered.+ [Test]+ public void EventIdentitySurvivesAnAdditionalSkippedPredecessor()+ {+ var yaml = File.ReadAllText(AdvisorCatalog.Path).Replace("he_review: pending", "he_review: approved")+ .Replace("requires: [opening.move]", "requires: [opening.detour]")+ .Replace("pages: []", " - { id: opening.detour, advisor: ben_gurion, signal: opening, level: new, he_review: approved, requires: [opening.move], when: { cards_waiting_at_least: 99 } }\n\npages: []");+ using var rig = new AdvisorTour1688Fixture.Rig(catalog: AdvisorCatalog.Parse(yaml));+ rig.Advisor.OpenChain();+ for (int i = 0; i < 4; i++) rig.Advisor.NextStep();+ Assert.AreEqual("opening.event", rig.Advisor.Shown?.Id);+ Assert.AreNotEqual(AdvisorPresenter.EventStep, rig.Advisor.ChainStep, "shifted catalogue precondition");+ rig.Ui.Press("advisor-show-me");+ UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ UiTestKit.Press(rig.Ui.Root.Q("event-options").Query<Button>().First());+ Assert.AreEqual("opening.objectives", rig.Advisor.Shown?.Id);+ Assert.AreEqual(AdvisorTour1688Fixture.Text(false).Format("advisor.step", 6, 6), rig.Ui.Q<Label>("advisor-count").text);+ Assert.IsTrue(rig.Advisor.IsOpen);+ }++ // R-GOV-002: close restores the initially collapsed card too.+ [Test]+ public void ClosingEventRestoresTheOriginallyCollapsedCard()+ {+ using var rig = new AdvisorTour1688Fixture.Rig(); rig.Card.Collapse(); rig.Advisor.OpenChain();+ for (int i = 0; i < 4; i++) rig.Advisor.NextStep();+ Assert.AreEqual("opening.event", rig.Advisor.Shown?.Id);+ rig.Ui.Press("advisor-show-me"); Assert.IsFalse(rig.Card.Collapsed);+ rig.Advisor.CloseChain(); Assert.IsTrue(rig.Card.Collapsed);+ Assert.AreEqual("player", rig.Selection);+ }+}+++public class AdvisorOpeningNoAttentionGameRootTests+{+ readonly List<string> dirs = new List<string>();+ static VisualElement Ui => Object.FindFirstObjectByType<UIDocument>().rootVisualElement;+ string TempDir()+ {+ var dir = Path.Combine(Path.GetTempPath(), "statecraft-tour1688-root-" + Guid.NewGuid().ToString("N"));+ dirs.Add(dir); return dir;+ }+ [TearDown]+ public void Clean()+ {+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ foreach (var dir in dirs) if (Directory.Exists(dir)) Directory.Delete(dir, true);+ dirs.Clear();+ }++ // R-GOV-002 / #1688 S1: Settings invokes GameRoot.SwitchLanguage -> Begin(keep: Bridge),+ // rebuilding the HUD, localized bridge, card and advisor, not just the advisor presenter.+ // Red-first: base reaches opening.attention instead of opening.city after the first Next.+ [Test]+ public void SettingsRebuildKeepsGdd03TourIdentityAndRestoresCardAndSelection()+ {+ var inputs = new GameInputs { Content = AdvisorTour1688Fixture.Content(),+ Map = GameInputs.MapFromDisk(Paths.Content, Paths.StreamingMap), Goldens = new GoldenData() };+ var settings = new SettingsStore(TempDir());+ var game = AdvisorGameTests.OpenScene(new SaveStore(TempDir()), settings);+ game.Language = UiLanguage.English;+ game.AdvisorCatalogForTests = AdvisorCatalog.Parse(File.ReadAllText(AdvisorCatalog.Path)+ .Replace("he_review: pending", "he_review: approved"));+ game.Begin(inputs, 0, startScreen: true);+ UiTestKit.Press(Ui.Q<Button>("start-new-game"));+ game.Advisor!.CloseChain();+ Assert.AreEqual(SaveGame.Gdd03Ruleset, game.Bridge!.Content.Ruleset);+ Assert.AreEqual("tour_test_a", game.Card!.Shown?.Id);+ Assert.IsFalse(game.Card.Collapsed, "the card the tour must put back");+ Assert.IsFalse(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass));++ var map = Object.FindFirstObjectByType<MapScene>();+ var city = AdvisorTargets.CityHex(game.Bridge.Content, game.Bridge.State)!.Value;+ var hex = game.Bridge.Content.Hexes.Where(h => h.Land).Select(h => (h.Q, h.R))+ .First(h => h != city && game.Units!.UnitToSelectAt(h.Item1, h.Item2) == null);+ GameRoot.OnHexClicked(map, game.Units!, game.Info!, hex.Item1, hex.Item2);+ Assert.AreEqual(hex, game.Info!.Selected, "the player's selection before the tour");+ game.Advisor.OpenChain(); game.Advisor.NextStep();+ Assert.AreEqual("opening.city", game.Advisor.Shown?.Id);+ Assert.AreEqual(city, game.Info.Selected, "the tour temporarily selects its city");+ RoundTrip("opening.city", 2);+ Assert.AreEqual(city, game.Info!.Selected, "the rebuilt city step selects its city again");+ game.Advisor!.CloseChain();+ Assert.AreEqual(hex, game.Info.Selected, "closing restores the player's selection in the rebuilt info panel");+ Assert.AreEqual("tour_test_a", game.Card!.Shown?.Id);+ Assert.IsFalse(game.Card.Collapsed, "closing restores the previously open card in the rebuilt UI");++ game.Advisor.OpenChain();+ foreach (var id in AdvisorTour1688Fixture.Visible)+ {+ Assert.AreEqual(id, game.Advisor!.Shown?.Id);+ Assert.AreNotEqual("opening.attention", game.Advisor.Shown?.Id);+ Assert.IsFalse(game.AdvisorSession!.Settings.Seen("opening.attention"));+ if (id == "opening.event")+ {+ RoundTrip(id, 5);+ UiTestKit.Press(Ui.Q<Button>("advisor-show-me"));+ Assert.AreEqual("tour_test_a", game.Card!.Shown?.Id);+ Assert.IsFalse(game.Card.Collapsed, "the rebuilt event action opens the same decision by identity");+ game.Card.Collapse();+ Assert.AreEqual(id, game.Advisor!.Shown?.Id);+ }+ game.Advisor.NextStep();+ }+ Assert.IsFalse(game.Advisor!.InChain);+ Assert.AreEqual("tour_test_a", game.Card!.Shown?.Id);+ Assert.IsFalse(game.Card.Collapsed, "finishing restores the initially open decision");+ AssertNoAttention();++ void AssertNoAttention()+ {+ Assert.IsFalse(game.AdvisorSession!.Settings.Seen("opening.attention"));+ Assert.IsFalse(new AdvisorSettings(settings).Seen("opening.attention"), "no shared preference was written");+ Assert.IsFalse(game.AdvisorSession.Queue.History.Any(e => e.Id == "opening.attention"));+ }+ void RoundTrip(string id, int position)+ {+ var session = game.AdvisorSession;+ var sim = game.Bridge!.Session;+ var index = game.Advisor!.ChainStep;+ foreach (var language in new[] { UiLanguage.Hebrew, UiLanguage.English })+ {+ var oldAdvisor = game.Advisor; var oldCard = game.Card; var oldBridge = game.Bridge;+ UiTestKit.Press(Ui.Q<Button>("nav-settings"));+ UiTestKit.Press(Ui.Q<Button>("settings-language-" + language));+ Assert.AreEqual(language == UiLanguage.Hebrew, Ui.Q("root").ClassListContains(UiLanguage.HebrewClass));+ Assert.AreNotSame(oldAdvisor, game.Advisor); Assert.AreNotSame(oldCard, game.Card);+ Assert.AreNotSame(oldBridge, game.Bridge, "Begin rebuilds the localized bridge over the retained game");+ Assert.AreSame(sim, game.Bridge!.Session); Assert.AreSame(session, game.AdvisorSession);+ if (Ui.Q("root").ClassListContains(ScreenNav.ScreenOpenClass)) UiTestKit.Press(Ui.Q<Button>("nav-settings"));+ Assert.IsTrue(game.Advisor!.InChain);+ Assert.AreEqual(id, game.Advisor.Shown?.Id); Assert.AreEqual(index, game.Advisor.ChainStep);+ Assert.AreNotEqual("opening.attention", game.Advisor.Shown?.Id);+ Assert.AreEqual(AdvisorTour1688Fixture.Text(language == UiLanguage.Hebrew).Format("advisor.step", position, 6),+ Ui.Q<Label>("advisor-count").text);+ Assert.AreEqual("tour_test_a", game.Card!.Shown?.Id); Assert.IsTrue(game.Card.Collapsed);+ AssertNoAttention();+ }+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/AdvisorOpeningTests.cs b/unity/Assets/Tests/EditMode/AdvisorOpeningTests.csindex 56ae6d0bb..6eb186cd5 100644--- a/unity/Assets/Tests/EditMode/AdvisorOpeningTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorOpeningTests.cs@@ -179,3 +179,143 @@ public class AdvisorOpeningTestsAssert.IsFalse(rig.Advisor.InChain); Assert.AreEqual(state, rig.Bridge.State.Hash()); Assert.AreEqual(save, rig.Bridge.Session.Save.Write()); Assert.IsEmpty(rig.Bridge.Queued);}}+++// R-GOV-002 / #1688: isolated test sessions; no shipped selector is changed.+internal static class AdvisorTour1688Fixture+{+ internal static readonly string[] Visible = { "opening.greeting", "opening.city", "opening.training", "opening.move", "opening.event", "opening.objectives" };+ internal static UiText Text(bool he) => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(he ? UiPaths.StringsHebrew : UiPaths.Strings).text);+ internal static Content Content(string ruleset = SaveGame.Gdd03Ruleset)+ {+ // Borrow existing topology/rules but replace ALL historical cards before creating any session.+ // None of the gdd03-events exclusion manifest becomes a synthetic 0.3 card.+ var c = ContentLoader.Load(Paths.Content);+ foreach (var era in c.Eras)+ {+ era.Systems.Loop = ruleset == SaveGame.LegacyRuleset ? EraSystems.Legacy : EraSystems.Gdd;+ era.Systems.Ruleset = ruleset;+ }+ c.Events.Clear(); c.Objectives.Clear();+ foreach (var id in new[] { "tour_test_a", "tour_test_b" })+ c.Events.Add(new GameEvent { Id = id, From = c.Rules.Start, Title = "Synthetic decision", Text = "Test only",+ Options = new List<EventOption> { new EventOption { Id = "yes", Text = "Continue" } } });+ return c;+ }+ internal sealed class Rig : IDisposable+ {+ internal readonly UiTestKit Ui = new UiTestKit();+ internal readonly SimBridge Bridge;+ internal readonly EventCardPresenter Card;+ internal readonly AdvisorSession Session;+ internal readonly AdvisorHooks Hooks;+ internal AdvisorPresenter Advisor;+ readonly HudPresenter hud;+ internal string Selection = "player";+ internal Rig(bool he = false, SettingsStore? store = null, string ruleset = SaveGame.Gdd03Ruleset, GameSession? game = null, AdvisorCatalog? catalog = null)+ {+ Ui.Root.Q("root").RemoveFromClassList("loading");+ var text = Text(he);+ Bridge = new SimBridge(game ?? GameSession.New(Content(ruleset), 1, Mode.Historical), text);+ hud = new HudPresenter(Ui.Root, Bridge, text);+ Card = new EventCardPresenter(Ui.Root, Bridge, text, null);+ Session = new AdvisorSession(catalog ?? AdvisorCatalog.Parse(File.ReadAllText(AdvisorCatalog.Path).Replace("he_review: pending", "he_review: approved")), new AdvisorSettings(store), true);+ Hooks = new AdvisorHooks { Card = Card, ShowCity = () => Selection = "city", ShowUnit = () => Selection = "unit",+ KeepSelection = () => { var previous = Selection; return () => Selection = previous; } };+ Advisor = new AdvisorPresenter(Ui.Root, Bridge, text, Session, hooks: Hooks);+ }+ internal void Rebuild(bool he)+ {+ Advisor.Dispose();+ Advisor = new AdvisorPresenter(Ui.Root, Bridge, Text(he), Session, hooks: Hooks);+ }+ public void Dispose() { Advisor.Dispose(); Card.Dispose(); hud.Dispose(); Ui.Dispose(); }+ }+}++public class AdvisorOpeningNoAttentionTests+{+ readonly List<string> dirs = new List<string>();+ SettingsStore Store()+ {+ var path = Path.Combine(Path.GetTempPath(), "statecraft-tour1688-" + Guid.NewGuid().ToString("N"));+ dirs.Add(path); return new SettingsStore(path);+ }+ [TearDown] public void Clean() { foreach (var d in dirs) if (Directory.Exists(d)) Directory.Delete(d, true); dirs.Clear(); }++ // R-GOV-002: traverse requires:[opening.attention] without recording it as watched.+ [TestCase(false, false)] [TestCase(true, false)] [TestCase(false, true)] [TestCase(true, true)]+ public void AutoStartAndManualReplaySkipAttentionWithoutChangingItsPreference(bool he, bool alreadySeen)+ {+ var store = Store(); if (alreadySeen) store.Write(AdvisorSettings.SeenKey, "opening.attention");+ using var rig = new AdvisorTour1688Fixture.Rig(he, store);+ rig.Advisor.NewGame(); Assert.IsTrue(rig.Advisor.InChain);+ var state = rig.Bridge.State.Hash(); var save = rig.Bridge.Session.Save.Write();+ for (int replay = 0; replay < 2; replay++)+ {+ if (replay > 0) rig.Advisor.OpenChain();+ var visited = new List<string>();+ while (rig.Advisor.InChain)+ {+ visited.Add(rig.Advisor.Shown!.Id); Assert.LessOrEqual(visited.Count, 6, "requires must not dead-end or loop");+ Assert.AreEqual(AdvisorTour1688Fixture.Text(he).Format("advisor.step", visited.Count, 6), rig.Ui.Q<Label>("advisor-count").text);+ rig.Advisor.NextStep();+ }+ CollectionAssert.AreEqual(AdvisorTour1688Fixture.Visible, visited);+ Assert.AreEqual(alreadySeen, rig.Session.Settings.Seen("opening.attention"));+ Assert.IsFalse(rig.Session.Queue.History.Any(e => e.Id == "opening.attention"));+ }+ Assert.AreEqual(alreadySeen, new AdvisorSettings(store).Seen("opening.attention"));+ Assert.AreEqual(state, rig.Bridge.State.Hash()); Assert.AreEqual(save, rig.Bridge.Session.Save.Write());+ Assert.IsEmpty(rig.Bridge.Queued);+ rig.Advisor.NewGame(); Assert.IsFalse(rig.Advisor.InChain, "profile already opened the tour");+ }++ // R-GOV-002: closing each visible step restores card/selection; replay starts at greeting.+ [TestCase(false)] [TestCase(true)]+ public void EveryVisibleStepCanCloseAndReopen(bool he)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(he);+ foreach (var id in AdvisorTour1688Fixture.Visible)+ {+ rig.Advisor.OpenChain();+ for (int n = 0; rig.Advisor.Shown?.Id != id && n < 6; n++) rig.Advisor.NextStep();+ Assert.AreEqual(id, rig.Advisor.Shown?.Id);+ rig.Ui.Press("advisor-close"); Assert.IsFalse(rig.Advisor.InChain);+ Assert.AreEqual("player", rig.Selection); Assert.IsFalse(rig.Card.Collapsed);+ }+ Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ }++ // R-GOV-002: new controls; every original old-mode test above is untouched.+ [TestCase(SaveGame.LegacyRuleset)] [TestCase(SaveGame.GddRuleset)]+ public void OlderSessionsStillTraverseAndRememberAttention(string ruleset)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(ruleset: ruleset);+ rig.Advisor.OpenChain(); var ids = new List<string>();+ while (rig.Advisor.InChain) { ids.Add(rig.Advisor.Shown!.Id); Assert.LessOrEqual(ids.Count, 7); rig.Advisor.NextStep(); }+ CollectionAssert.AreEqual(AdvisorPresenter.ChainIds(rig.Session.Catalog), ids);+ Assert.IsTrue(rig.Session.Settings.Seen("opening.attention"));+ Assert.IsTrue(rig.Session.Queue.History.Any(e => e.Id == "opening.attention"));+ }+}+++public class AdvisorOpeningNoAttentionPreferenceTests+{+ // R-GOV-002: an already-opened profile still has manual replay, with no Attention seen mark.+ [Test]+ public void AlreadyOpenedProfileReplaysManuallyWithoutAttention()+ {+ var path = Path.Combine(Path.GetTempPath(), "statecraft-tour1688-seen-" + Guid.NewGuid().ToString("N"));+ try+ {+ var store = new SettingsStore(path); store.Write(AdvisorSettings.OpeningKey, "seen");+ using var rig = new AdvisorTour1688Fixture.Rig(store: store);+ rig.Advisor.NewGame(); Assert.IsFalse(rig.Advisor.InChain);+ rig.Advisor.OpenChain(); rig.Advisor.NextStep(); Assert.AreEqual("opening.city", rig.Advisor.Shown?.Id);+ Assert.IsFalse(new AdvisorSettings(store).Seen("opening.attention"));+ }+ finally { if (Directory.Exists(path)) Directory.Delete(path, true); }+ }+}diff --git a/unity/Assets/Tests/EditMode/AdvisorShowMeTests.cs b/unity/Assets/Tests/EditMode/AdvisorShowMeTests.csindex 13770f9b2..6f177822c 100644--- a/unity/Assets/Tests/EditMode/AdvisorShowMeTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorShowMeTests.cs@@ -80,3 +80,62 @@ public class AdvisorShowMeTests});}}+++public class AdvisorShowMeNoAttentionTests+{+ sealed class Picture : AdvisorMedia.IPicture+ {+ internal readonly List<string> Loaded = new List<string>();+ public bool Ready => true;+ public double Time => 0;+ public void Load(string url, VisualElement target, System.Action<string> failed) => Loaded.Add(url);+ public void Start() { }+ public void Stop() { }+ public void Seek(double time) { }+ }+ sealed class Output : DeclarationRecording.IOutput+ {+ public bool IsPlaying { get; private set; }+ public float Position => 0;+ public bool? Ready(AudioClip clip) => true;+ public void Play(AudioClip clip) => IsPlaying = true;+ public void Stop() => IsPlaying = false;+ public void Dispose() { }+ }+ sealed class Request : DeclarationRecording.IRequest { public ulong Bytes => 0; public void Abort() { } }++ // R-GOV-002: exercise Watch with in-memory fakes, never shipped media playback.+ [TestCase(false)] [TestCase(true)]+ public void TourNeverLoadsAttentionPictureNarrationCaptionOrTarget(bool he)+ {+ using var rig = new AdvisorTour1688Fixture.Rig(he);+ var picture = new Picture(); var audio = new List<string>(); rig.Advisor.ForceInline = true;+ rig.Advisor.Media = new AdvisorMedia(AdvisorTour1688Fixture.Text(he), picture, null, (url, done) =>+ {+ audio.Add(url); done(AudioClip.Create("tour-test", 1, 1, 44100, false), null); return new Request();+ }, new Output());+ rig.Advisor.OpenChain(); int steps = 0;+ while (rig.Advisor.InChain)+ {+ Assert.Less(++steps, 7); Assert.AreNotEqual("opening.attention", rig.Advisor.Shown?.Id);+ Assert.IsFalse(rig.Advisor.Shown!.Actions.Any(a => a.ShowMe == AdvisorTargets.Attention));+ var caption = rig.Ui.Q<Label>("advisor-text");+ Assert.AreNotEqual(AdvisorTour1688Fixture.Text(he)["advisor.opening.attention.text"], caption.text);+ if (rig.Ui.Q<Button>("advisor-watch").style.display.value != DisplayStyle.None)+ {+ rig.Ui.Press("advisor-watch"); rig.Advisor.Media.Tick();+ Assert.AreNotEqual(AdvisorTour1688Fixture.Text(he)["advisor.opening.attention.cue.1"], caption.text);+ Assert.AreNotEqual(AdvisorTour1688Fixture.Text(he)["advisor.opening.attention.cue.2"], caption.text);+ }+ rig.Advisor.NextStep();+ }+ Assert.AreEqual(6, steps);+ if (!he) { Assert.IsNotEmpty(picture.Loaded); Assert.IsNotEmpty(audio); }+ Assert.IsFalse(picture.Loaded.Concat(audio).Any(url => url.Contains("opening.attention")));+ Assert.IsFalse(rig.Ui.Root.Q("root").ClassListContains(AdvisorPresenter.RingClass));+ Assert.AreEqual(DisplayStyle.None, rig.Ui.Q<Label>("attention").style.display.value);+ Assert.AreEqual("player", rig.Selection); Assert.IsEmpty(rig.Bridge.Queued);+ Assert.IsFalse(rig.Session.Settings.Seen("opening.attention"));+ }+}