A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Advisors S4: the help level and the warnings (Refs #1484) (#1602)
Eyal Golan65b8f4bacd58
diff --git a/changelog.d/advisors-s4.md b/changelog.d/advisors-s4.mdnew file mode 100644index 000000000..7e45a22e3--- /dev/null+++ b/changelog.d/advisors-s4.md@@ -0,0 +1,2 @@+### Added+- Advisor help levels in Settings, applied at once, and advisor warnings: a city under attack, Money and Food exhausted together, debt at its ceiling, a Food shortage, a budget left unsubmitted and low Arms. Critical warnings show at every help level. Every warning's Hebrew is approved by the owner; the Settings help-level labels and the war-loss line on the end screen await a native read. A loaded game hears the warnings that already hold. The end screen names a war loss (Refs #1484).diff --git a/unity/Assets/Resources/Advisors/advisor-messages.yaml b/unity/Assets/Resources/Advisors/advisor-messages.yamlindex 2d71c51fd..997e53a7a 100644--- a/unity/Assets/Resources/Advisors/advisor-messages.yaml+++ b/unity/Assets/Resources/Advisors/advisor-messages.yaml@@ -22,4 +22,26 @@ messages:- { id: opening.event, advisor: ben_gurion, signal: opening, level: new, he_review: approved, requires: [opening.move], when: { cards_waiting_at_least: 1 }, actions: [{ show_me: decision_waiting }, { open_card: true }] }- { id: opening.objectives, advisor: ben_gurion, signal: opening, level: new, he_review: approved, requires: [opening.event], actions: [{ show_me: nav_objectives }] }+# Spec 6's critical warnings (shown at every help level, Off included) and the defeat lines. Their words and speakers are the+# recorded clips' (owner, 24 October 2026: "Adopt clip words"; talking-v3/lines.csv): dayan.city_at_risk is+# warning.city_under_attack, meyerson.exhausted warning.economic_defeat_countdown.fix1, meyerson.debt_ceiling+# warning.debt_ceiling (so it waits for the ceiling itself, R-END-001: debt at or above it; owner, 24 October+# 2026, asked about an earlier warning: "No, at the ceiling is fine"), dayan.defeat_war+# warning.city_held_defeat and dayan.arms_out teach.arms, which fires when Arms are low (owner, 24 October 2026: "Fire+# when low"; the threshold, AdvisorSignals.ArmsReserve, is an owner-set DESIGN VALUE: "Approve 3 / costliest action", same day).+# The three critical warnings' Hebrew is approved by the owner, a native speaker (24 October 2026, asked what Hebrew players+# should see while the critical warnings wait for review: "Hebrew approved"), as worded in the S4 review sheet; any change+# to their Hebrew sets them back to pending. The other five rows' Hebrew is approved by the owner too (24 October 2026,+# asked about the S4 warning and teaching lines: "approved"), defeat_economy with the sheet's grammar fix (תורים, not+# תורות); any later change to their Hebrew sets them back to pending.+ - { id: dayan.city_at_risk, advisor: dayan, signal: city_at_risk, level: critical, he_review: approved, priority: 3, repeat: every, cooldown_turns: 1, actions: [{ open_screen: defence }] }+ - { id: meyerson.exhausted, advisor: meyerson, signal: exhausted, level: critical, he_review: approved, priority: 3, repeat: every, cooldown_turns: 1, actions: [{ open_screen: budget }] }+ - { id: meyerson.debt_ceiling, advisor: meyerson, signal: in_debt, when: { debt_ratio_at_least: 1 }, level: critical, he_review: approved, priority: 2, repeat: every, cooldown_turns: 3, actions: [{ open_screen: budget }] }+ - { id: meyerson.food_short, advisor: meyerson, signal: food_short, level: warnings, he_review: approved, priority: 2, repeat: every, cooldown_turns: 2 }+ - { id: dayan.defeat_war, advisor: dayan, signal: defeat_war, level: warnings, he_review: approved }+ - { id: ben_gurion.defeat_economy, advisor: ben_gurion, signal: defeat_economy, level: warnings, he_review: approved }+# Tasks 18 and 20's two warnings that need no encyclopedia page; the teaching rows wait for S3 (#1519).+ - { id: meyerson.budget_unsubmitted, advisor: meyerson, signal: budget_unsubmitted, level: warnings, he_review: approved, repeat: every, cooldown_turns: 1, actions: [{ open_screen: budget }] }+ - { id: dayan.arms_out, advisor: dayan, signal: arms_low, level: warnings, he_review: approved, repeat: every, cooldown_turns: 3, actions: [{ open_screen: defence }] }+pages: []diff --git a/unity/Assets/Scripts/UI/AdvisorCatalog.cs b/unity/Assets/Scripts/UI/AdvisorCatalog.csindex cb3377a0b..668bf7ff0 100644--- a/unity/Assets/Scripts/UI/AdvisorCatalog.cs+++ b/unity/Assets/Scripts/UI/AdvisorCatalog.cs@@ -140,7 +140,7 @@ namespace Statecraft.Game.UIpublic static Known Shipped() => new Known{Signals = AdvisorSignals.Names.ToList(), Conditions = AdvisorSignals.Measures.Keys.ToList(),- Screens = ScreenNav.Screens, Targets = AdvisorTargets.Names,+ Screens = ScreenNav.Screens, Targets = AdvisorTargets.Names, Quotes = AdvisorQuotes.Ids,StreamingFile = f => System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, MediaFolder, f)),};@@ -172,6 +172,11 @@ namespace Statecraft.Game.UIif (m.Actions.Count > 2) p.Add($"{at}: at most two actions");foreach (var a in m.Actions) CheckAct(p, at, a, known);if (m.Quote != "" && !known.Quotes.Contains(m.Quote)) p.Add($"{at}: quote '{m.Quote}' is not on the verified list (spec 3.3)");+ if (m.Quote != "")+ {+ Text(p, en, he, at, "advisor.quote." + m.Quote + ".text", 0);+ Text(p, en, he, at, "advisor.quote." + m.Quote + ".source", 0);+ }if (m.DisagreesWith != ""){var o = Find(m.DisagreesWith);diff --git a/unity/Assets/Scripts/UI/AdvisorPresenter.cs b/unity/Assets/Scripts/UI/AdvisorPresenter.csindex 0a6345a91..18bce9719 100644--- a/unity/Assets/Scripts/UI/AdvisorPresenter.cs+++ b/unity/Assets/Scripts/UI/AdvisorPresenter.cs@@ -29,9 +29,9 @@ namespace Statecraft.Game.UI{public const string OpenClass = "advisor-open", LayerName = "advisor-layer", CriticalClass = "advisor-critical",NoPortraitClass = "advisor-no-portrait";- /// <summary>Statecraft.uss sizes (.advisor-name, .advisor-role, .advisor-text, Button, .advisor-count), in panel px,+ /// <summary>Statecraft.uss sizes (.advisor-name, .advisor-role, .advisor-text, Button, .advisor-count, .advisor-quote, .advisor-quote-source), in panel px,/// raised where they would be under the text floor on screen (HudPresenter.FlooredTextSize).</summary>- public const float NamePx = 24f, RolePx = 15f, TextPx = 22f, ButtonPx = 19f, CountPx = 15f;+ public const float NamePx = 24f, RolePx = 15f, TextPx = 22f, ButtonPx = 19f, CountPx = 15f, QuotePx = 20f, QuoteSourcePx = 15f;/// <summary>The fade out (Statecraft.uss .advisor-popup.window-closing), in ms.</summary>public const long HideMs = 150;public const string RingClass = "advisor-ring-open";@@ -69,14 +69,14 @@ namespace Statecraft.Game.UIIVisualElementScheduledItem? ringOnly;readonly VisualElement hudRoot, layer, popup, portrait;- readonly Label name, role, words, count;+ readonly Label name, role, words, count, quote, quoteSource;readonly Button showMe, more, notNow, gotIt, close;readonly Button? reopen;readonly Action onReopen;GameSession? openingGame;readonly SimBridge bridge; readonly UiText text; readonly AdvisorSession session; readonly PortraitCatalog? portraits;readonly AdvisorHooks hooks; readonly bool hebrew;- readonly Action onChanged, onCover, onShowMe, onGotIt, onNotNow, onClose;+ readonly Action onChanged, onCover, onShowMe, onGotIt, onNotNow, onClose, onAttention, onLevel;readonly IReadOnlyList<AdvisorCatalog.Message> chain;readonly Action<IReadOnlyList<Rejection>> onTurn;readonly EventCallback<GeometryChangedEvent> onLaidOut;@@ -127,11 +127,12 @@ namespace Statecraft.Game.UIportrait = popup.Q<VisualElement>("advisor-portrait");name = popup.Q<Label>("advisor-name"); role = popup.Q<Label>("advisor-role");words = popup.Q<Label>("advisor-text"); count = popup.Q<Label>("advisor-count");+ quote = popup.Q<Label>("advisor-quote"); quoteSource = popup.Q<Label>("advisor-quote-source");showMe = popup.Q<Button>("advisor-show-me"); more = popup.Q<Button>("advisor-more");notNow = popup.Q<Button>("advisor-not-now"); gotIt = popup.Q<Button>("advisor-got-it"); close = popup.Q<Button>("advisor-close");showMe.text = text["advisor.show_me"]; more.text = text["advisor.more"]; notNow.text = text["advisor.not_now"];gotIt.text = text["advisor.got_it"]; close.text = text["advisor.close"];- floored = new (VisualElement, float)[] { (name, NamePx), (role, RolePx), (words, TextPx), (showMe, ButtonPx), (more, ButtonPx), (notNow, ButtonPx), (gotIt, ButtonPx), (close, ButtonPx), (count, CountPx), (mediaLabel, 15f), (mediaCredit, 15f), (overlayCaption, TextPx), (overlayLabel, 15f), (overlayCredit, 15f), (watch, 15f), (overlayClose, ButtonPx) };+ floored = new (VisualElement, float)[] { (name, NamePx), (role, RolePx), (words, TextPx), (showMe, ButtonPx), (more, ButtonPx), (notNow, ButtonPx), (gotIt, ButtonPx), (close, ButtonPx), (count, CountPx), (mediaLabel, 15f), (mediaCredit, 15f), (overlayCaption, TextPx), (overlayLabel, 15f), (overlayCredit, 15f), (watch, 15f), (overlayClose, ButtonPx), (quote, QuotePx), (quoteSource, QuoteSourcePx) };onShowMe = ShowMe; onGotIt = GotIt; onNotNow = NotNow;onClose = () => { if (session.Chain.Step >= 0) CloseChain(); else GotIt(); };reopen = root.Q<Button>("how-to-play-guide");@@ -142,8 +143,11 @@ namespace Statecraft.Game.UIDisplay(reopen, chain.Any(m => m.ApprovedIn(hebrew))); // no button that opens nothing (pending Hebrew)}showMe.clicked += onShowMe; gotIt.clicked += onGotIt; close.clicked += onClose; notNow.clicked += onNotNow;+ onAttention = () => Notice(AdvisorSignals.AttentionRefused);+ bridge.RefusedForAttention += onAttention;onChanged = Evaluate; onTurn = _ => Notice(AdvisorSignals.TurnEnded); onCover = CoverChanged; onLaidOut = PlaceWhenLaidOut;bridge.Changed += onChanged; bridge.TurnEnded += onTurn;+ onLevel = Evaluate; session.Settings.LevelChanged += onLevel; // a new help level applies at once (spec 6)layer.userData = onCover; // ScreenNav.DisableCovered calls it// The slot moves with the layout (a window resized, "Decision waiting" or the toast shown), so the popup follows// it while it shows, as its ring does.@@ -197,6 +201,22 @@ namespace Statecraft.Game.UI}}+ /// <summary>A loaded game (Continue closed the start screen): the warnings that already hold are offered at once, not+ /// only after the next change.</summary>+ public void Resume() => Evaluate();++ /// <summary>The Budget screen's unsubmitted state changed (BudgetPresenter.UnsubmittedChanged): an edit not submitted+ /// fires budget_unsubmitted; Submit takes it back.</summary>+ public void BudgetUnsubmitted(bool on)+ {+ if (on) { Notice(AdvisorSignals.BudgetUnsubmitted); return; }+ if (disposed) return;+ session.Fired.Remove(AdvisorSignals.BudgetUnsubmitted);+ session.Queue.Withdraw(AdvisorSignals.BudgetUnsubmitted, Turn, bridge.State.Date);+ if (covered?.Signal == AdvisorSignals.BudgetUnsubmitted) covered = null;+ Render();+ }+/// <summary>An event signal fired (spec 5): it holds for this turn.</summary>public void Notice(string signal){@@ -238,6 +258,11 @@ namespace Statecraft.Game.UIname.text = text[m.Advisor == "meyerson" && !session.Introduced(m.Advisor) ? "advisor.meyerson.name_first" : "advisor." + m.Advisor + ".name"];role.text = text["advisor." + m.Advisor + ".role"];if (!Captioning) words.text = text["advisor." + m.Id + ".text"];+ var quoteKey = "advisor.quote." + m.Quote;+ bool verifiedQuote = AdvisorQuotes.Ids.Contains(m.Quote) && text.Has(quoteKey + ".text") && text.Has(quoteKey + ".source");+ quote.text = verifiedQuote ? text[quoteKey + ".text"] : "";+ quoteSource.text = verifiedQuote ? text[quoteKey + ".source"] : "";+ Display(quote, verifiedQuote); Display(quoteSource, verifiedQuote);UpdateWatch();var picture = portraits?.Get(session.Catalog.AdvisorOf(m.Advisor).Person);popup.EnableInClassList(NoPortraitClass, picture == null);@@ -708,7 +733,9 @@ namespace Statecraft.Game.UIfollow.Pause();fading?.Pause();layer.UnregisterCallback(onLaidOut);+ bridge.RefusedForAttention -= onAttention;bridge.Changed -= onChanged; bridge.TurnEnded -= onTurn;+ session.Settings.LevelChanged -= onLevel;if (layer.userData == (object)onCover) layer.userData = null;if (reopen != null) reopen.clicked -= onReopen;showMe.clicked -= onShowMe; gotIt.clicked -= onGotIt; close.clicked -= onClose; notNow.clicked -= onNotNow;diff --git a/unity/Assets/Scripts/UI/AdvisorQueue.cs b/unity/Assets/Scripts/UI/AdvisorQueue.csindex c84eb5e49..65b0bfe77 100644--- a/unity/Assets/Scripts/UI/AdvisorQueue.cs+++ b/unity/Assets/Scripts/UI/AdvisorQueue.cs@@ -105,6 +105,17 @@ namespace Statecraft.Game.UIhistory.Add(new Entry(m.Id, turn, date, Outcome.Missed));}+ /// <summary>An event signal stopped being true this turn (the budget submitted): each message waiting on it, shown or not,+ /// goes to the history as missed, not seen, so the signal can bring it back.</summary>+ public void Withdraw(string signal, int turn, DateTime date)+ {+ foreach (var w in waiting.Where(w => w.M.Signal == signal).ToList())+ {+ waiting.Remove(w);+ history.Add(new Entry(w.M.Id, turn, date, Outcome.Missed));+ }+ }+void Take(AdvisorCatalog.Message m, int turn){Caps(turn);diff --git a/unity/Assets/Scripts/UI/AdvisorQuotes.cs b/unity/Assets/Scripts/UI/AdvisorQuotes.csnew file mode 100644index 000000000..93e89b350--- /dev/null+++ b/unity/Assets/Scripts/UI/AdvisorQuotes.cs@@ -0,0 +1,10 @@+namespace Statecraft.Game.UI+{+ /// <summary>Spec 3.3's verified quotes (Codex cx285, checked 23 October 2026): only these may show, each styled as a+ /// quote with its source line, and only as that list allows (Q1 and Q2 attributed to the Declaration, never to a person).+ /// Its text and source are advisor.quote.<id>.text and .source.</summary>+ public static class AdvisorQuotes+ {+ public static readonly string[] Ids = { "q1", "q2", "q3", "q4" };+ }+}diff --git a/unity/Assets/Scripts/UI/AdvisorQuotes.cs.meta b/unity/Assets/Scripts/UI/AdvisorQuotes.cs.metanew file mode 100644index 000000000..5f2fc3424--- /dev/null+++ b/unity/Assets/Scripts/UI/AdvisorQuotes.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 0f8cfabe9a71465cbd3fed3bb276b7dfdiff --git a/unity/Assets/Scripts/UI/AdvisorSettings.cs b/unity/Assets/Scripts/UI/AdvisorSettings.csindex 371799789..08fec2c1a 100644--- a/unity/Assets/Scripts/UI/AdvisorSettings.cs+++ b/unity/Assets/Scripts/UI/AdvisorSettings.cs@@ -34,12 +34,16 @@ namespace Statecraft.Game.UIpublic bool HasFile => store != null;public string Level { get; private set; }public int LevelRank => Array.IndexOf(Levels, Level);+ /// <summary>The help level changed (Settings): the popup applies it at once (spec 6).</summary>+ public event Action? LevelChanged;public void SetLevel(string level){if (Array.IndexOf(Levels, level) < 0) throw new ArgumentException("unknown help level: " + level, nameof(level));+ if (level == Level) return;Level = level;Write(LevelKey, level);+ LevelChanged?.Invoke();}public bool Seen(string id) => seen.Contains(id);diff --git a/unity/Assets/Scripts/UI/AdvisorSignals.cs b/unity/Assets/Scripts/UI/AdvisorSignals.csindex bead2b0e0..67547e96d 100644--- a/unity/Assets/Scripts/UI/AdvisorSignals.cs+++ b/unity/Assets/Scripts/UI/AdvisorSignals.cs@@ -2,6 +2,7 @@using System;using System.Collections.Generic;using System.Linq;+using Statecraft.Sim;namespace Statecraft.Game.UI{@@ -10,16 +11,57 @@ namespace Statecraft.Game.UI/// TurnEnded only, never each frame (spec 16). A `when` condition measures one number on the state.</summary>public static class AdvisorSignals{- public const string NewGame = "new_game", TurnEnded = "turn_ended", Opening = "opening";- public static readonly IReadOnlyCollection<string> Events = new[] { NewGame, TurnEnded, Opening };- public static readonly IReadOnlyDictionary<string, Func<AdvisorContext, bool>> States = new Dictionary<string, Func<AdvisorContext, bool>>();+ public const string NewGame = "new_game", TurnEnded = "turn_ended", Opening = "opening",+ AttentionRefused = "attention_refused", BudgetUnsubmitted = "budget_unsubmitted", CityShown = "city_shown", UnitShown = "unit_shown";+ public static readonly IReadOnlyCollection<string> Events = new[] { NewGame, TurnEnded, Opening, AttentionRefused, BudgetUnsubmitted, CityShown, UnitShown };+ public static readonly IReadOnlyDictionary<string, Func<AdvisorContext, bool>> States = new Dictionary<string, Func<AdvisorContext, bool>>+ {+ // Spec 6's critical warnings and the defeat lines (R-END-001 to R-END-003, docs/rules/mvp.md:377-381).+ ["city_at_risk"] = ctx => Threats.CitiesAtRisk(ctx.Content, ctx.State).Count > 0,+ ["exhausted"] = ctx => ctx.State.ExhaustedTurns > 0,+ ["in_debt"] = ctx => ctx.State.Debt > 0,+ ["food_short"] = ctx => ctx.State.FoodUnmet > 0,+ ["defeat_war"] = ctx => ctx.State.GameOver == GameOverCodes.DefeatWar,+ ["defeat_economy"] = ctx => ctx.State.GameOver == GameOverCodes.DefeatEconomy,+ ["project_unlocked"] = ctx => ctx.State.UnlockedProjects.Count > 0,+ // A halutz with no project (R-SITE-001, D-D6: one project per unit): pioneer work is waiting to be given.+ ["idle_pioneer"] = ctx => ctx.State.Units.Values.Any(u => u.Side == "" && Projects.IsPioneer(u.Type) && !Projects.IsBusy(ctx.State, u.Id)),+ ["corridor_started"] = ctx => ctx.State.Corridors.Count > 0,+ ["cabinet_vacancy"] = ctx => ctx.Bridge.Vacancies.Count > 0,+ ["situation_active"] = ctx => ctx.State.ActiveSituations.Count > 0,+ ["standing_order"] = ctx => ctx.State.Units.Values.Any(u => u.Side == Movement.PlayerSide && u.Order != ""),+ ["combat_seen"] = ctx => ctx.Bridge.Session.Last?.Why.Any(w => w.Key == WhyKeys.Engagement) == true,+ // Owner, 24 October 2026: "Fire when low". Owner-set DESIGN VALUE ("Approve 3 / costliest action", same day): low is+ // at or below the costliest single Arms action (ArmsReserve), so an empty stock is low too.+ ["arms_low"] = ctx => ctx.Content.IsGdd && ctx.State.Arms <= ArmsReserve(ctx),+ ["capture_waiting"] = ctx => ctx.State.Settlements.Values.Any(x => x.State == SettlementControl.AwaitingChoice),+ ["enemy_moved"] = ctx => ctx.Bridge.Session.Last?.Why.Any(w => w.EnemyOrder != "") == true,+ ["objective_done"] = ctx => ctx.State.Objectives.Count > 0,+ ["truce_active"] = ctx => Combat.TruceUntil(ctx.State) != null,+ };/// <summary>Each condition's measure; a name ends in _at_least or _at_most, which says how its bound reads.</summary>public static readonly IReadOnlyDictionary<string, Func<AdvisorContext, double>> Measures = new Dictionary<string, Func<AdvisorContext, double>>{+ ["debt_ratio_at_least"] = ctx => ctx.Content.RulesAt(ctx.State.Date).Mvp?.DebtCeiling is double ceiling && ceiling > 0 ? ctx.State.Debt / ceiling : 0,+ ["refugees_at_least"] = ctx => ctx.State.Cities.Values.Sum(x => x.Refugees),["cards_waiting_at_least"] = ctx => ctx.Card?.Shown != null ? 1 : 0,};public static IEnumerable<string> Names => Events.Concat(States.Keys);+ /// <summary>The Arms the costliest single Arms action takes under the rules in force: a recruit group+ /// (mvp.arms_per_recruit_group, R-ARMS-003), an attack (mvp.arms_per_attack, R-COMBAT-004), or one of our unit types'+ /// training_arms (R-UNIT-008) or arms_per_fire (R-COMBAT-007). At or below it, one such action may be all the stock+ /// pays for. There is no Arms upkeep or refill (R-ARMS-001, R-ARMS-002), so a per-turn burn rate would not be stable.+ /// Presentation only; the sim is not asked.</summary>+ public static int ArmsReserve(AdvisorContext ctx)+ {+ var mvp = ctx.Content.RulesAt(ctx.State.Date).Mvp;+ int reserve = Math.Max(mvp?.ArmsPerRecruitGroup ?? 0, mvp?.ArmsPerAttack ?? 0);+ foreach (var t in ctx.Content.UnitTypes)+ if (t.Side == Movement.PlayerSide) reserve = Math.Max(reserve, Math.Max(t.TrainingArms ?? 0, t.ArmsPerFire ?? 0));+ return reserve;+ }+/// <summary>Whether a message's `when` holds: each named measure against its bound (spec 4.1).</summary>public static bool When(AdvisorContext ctx, IReadOnlyDictionary<string, double> when) =>when.All(kv => kv.Key.EndsWith("_at_least", StringComparison.Ordinal)diff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.csindex 6709fc82f..a8de2563b 100644--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs@@ -13,6 +13,9 @@ namespace Statecraft.Game.UIpublic sealed class BudgetPresenter : IDisposable{public const double Step = 0.05;+ /// <summary>The unsubmitted badge changed, after its UI state was updated.</summary>+ public event Action<bool>? UnsubmittedChanged;+ bool lastUnsubmitted;readonly VisualElement screen; readonly SimBridge bridge; readonly UiText text;readonly Button reset, submit;/// <summary>The side menu's Budget disc, whose badge (#1109) this screen lights: only it knows the draft.</summary>@@ -167,6 +170,11 @@ namespace Statecraft.Game.UIbool unsubmitted = bridge.BudgetUnsubmitted(draft);nav.EnableInClassList(HudPresenter.ActionClass, unsubmitted);nav.tooltip = unsubmitted ? text["hud.nav.budget_unsubmitted"] : nav.text;+ if (unsubmitted != lastUnsubmitted)+ {+ lastUnsubmitted = unsubmitted;+ UnsubmittedChanged?.Invoke(unsubmitted);+ }}}}diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex d062049fd..3f64d4527 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -280,15 +280,24 @@ namespace Statecraft.Game.UIoutcomes = video == null ? null : Own(new OutcomePresenter(root, bridge, text, Own(new CardVideo()), mapping.outcomes,() => card?.Render(), () => nav?.Close()));Own(new DefencePresenter(root, bridge, text, portraits));- Own(new BudgetPresenter(root, bridge, text));+ var budget = Own(new BudgetPresenter(root, bridge, text));Own(new WhyPresenter(root, bridge, text));Own(new TimelinePresenter(root, bridge, text));Own(new HowToPlayPresenter(root, text));Own(new ObjectivesPresenter(root, bridge, text));+ // The advisors (spec 4.2): their session survives a rebuild over the same game (a language switch keeps the+ // queue, the history and the opening chain's place) and is new for any other Begin. They show by themselves only+ // on the first new game: the start screen shows and a settings file remembers what was seen. Made before+ // Settings, whose help-level row (spec 6) reads and sets the session's level.+ if (keep == null || AdvisorSession == null)+ {+ bool autoShow = showsStart && !FirstCardCheckRequested() && SettingsFile() != null;+ AdvisorSession = new AdvisorSession(AdvisorCatalogForTests ?? AdvisorCatalog.Load(), new AdvisorSettings(autoShow ? SettingsFile() : null), autoShow);+ }// Presentation only (#40): never the sim or the save. Outside Play mode (EditMode tests) no file: the developer's// own settings must not leak into a test. Each Begin (New Game too) reads the file again.// The language switch (#1036) builds every screen again in the new language over this game (SwitchLanguage).- Own(new SettingsPresenter(root, text, SettingsFile(), language => SwitchLanguage(inputs, language), panel: document.panelSettings, audio: audio));+ Own(new SettingsPresenter(root, text, SettingsFile(), language => SwitchLanguage(inputs, language), panel: document.panelSettings, audio: audio, advisors: AdvisorSession.Settings));// "Report a bug or idea" (#1169), from Settings and the start screen: the version line names the content GameBoot logged.feedback = Own(new FeedbackPresenter(root, text, ReportLinks.Version(Application.version, inputs.Content.Hash)));var feedbackPanel = feedback;@@ -386,7 +395,13 @@ namespace Statecraft.Game.UIcameraController.GroundTop = CameraController.GroundTopOf(terrain);pointer.Map = map;pointer.IsOverUi = overUi;- Action<int, int> onHex = (q, r) => OnHexClicked(map, unitLayer, info, q, r);+ Action<int, int> onHex = (q, r) =>+ {+ OnHexClicked(map, unitLayer, info, q, r);+ if (info.ShowsUnit) advisor?.Notice(AdvisorSignals.UnitShown);+ else if (info.Selected is (int sq, int sr) && bridge.Content.SettlementHexes.Any(h => h.Q == sq && h.R == sr && bridge.State.Cities.ContainsKey(h.Id)))+ advisor?.Notice(AdvisorSignals.CityShown);+ };pointer.HexClicked += onHex;// #1063: a click on a city's name pill is a click on the city's hex (its settlement hex, where the city panel opens).Func<Vector2, (int q, int r)?> pillHex = p =>@@ -465,7 +480,7 @@ namespace Statecraft.Game.UIstart = Own(new StartScreenPresenter(root, newGame!, resumed, shown =>{if (cam != null) cam.enabled = !shown;- if (!shown && start?.Resumed == false) { advisor?.NewGame(); }+ if (!shown) { if (start?.Resumed == false) advisor?.NewGame(); else advisor?.Resume(); }}, recording, text));start.Show();}@@ -519,15 +534,7 @@ namespace Statecraft.Game.UIelse { map.ClearSelection(); nowInfo.Clear(); }};};- // The advisors (spec 4.2): their session survives a rebuild over the same game (a language switch keeps the- // queue, the history and the opening chain's place) and is new for any other Begin. They show by themselves only- // on the first new game: the start screen shows and a settings file remembers what was seen.- if (keep == null || AdvisorSession == null)- {- bool autoShow = showsStart && !FirstCardCheckRequested() && SettingsFile() != null;- // Final S1 store isolation; S2 supplies only the catalogue test seam.- AdvisorSession = new AdvisorSession(AdvisorCatalogForTests ?? AdvisorCatalog.Load(), new AdvisorSettings(autoShow ? SettingsFile() : null), autoShow);- }+ // The advisors' popup, over the session made before Settings (above).advisor = Own(new AdvisorPresenter(root, bridge, text, AdvisorSession, portraits,new AdvisorHooks{@@ -551,6 +558,7 @@ namespace Statecraft.Game.UIreturn new Rect(at, Vector2.one);},}));+ budget.UnsubmittedChanged += advisor.BudgetUnsubmitted;if (video != null)advisor.Media = new AdvisorMedia(text, new ClipPicture(video), new StillPicture(), DeclarationRecording.WebFetch, new DeclarationRecording.SourceOutput());if (newGame != null) newGame.Started += advisor.NewGame;diff --git a/unity/Assets/Scripts/UI/SettingsPresenter.cs b/unity/Assets/Scripts/UI/SettingsPresenter.csindex 60135cc43..d04857c48 100644--- a/unity/Assets/Scripts/UI/SettingsPresenter.cs+++ b/unity/Assets/Scripts/UI/SettingsPresenter.cs@@ -35,6 +35,8 @@ namespace Statecraft.Game.UIreadonly (Button button, GraphicsQuality.Choice choice, Action pick)[] quality;readonly (Button button, string language, Action pick)[] languages;readonly (Button button, string level, Action pick)[] sound;+ readonly AdvisorSettings? advisors;+ readonly (Button button, string level, Action pick)[] helpLevels;readonly GameAudio? audio;string soundLevel;readonly Action<string>? switchLanguage;@@ -46,10 +48,11 @@ namespace Statecraft.Game.UI/// <param name="switchLanguage">Puts the UI in the language pressed (GameRoot builds the screens again); null changes/// nothing but the stored choice, read at the next start.</param>/// <param name="panel">The UI's panel, which the UI scale scales; null leaves the scale alone.</param>+ /// <param name="advisors">The live advisor settings; null hides its row.</param>/// <param name="audio">The sound effects the volume applies to; null keeps only the choice.</param>- public SettingsPresenter(VisualElement root, UiText text, SettingsStore? store, Action<string>? switchLanguage = null, PanelSettings? panel = null, GameAudio? audio = null)+ public SettingsPresenter(VisualElement root, UiText text, SettingsStore? store, Action<string>? switchLanguage = null, PanelSettings? panel = null, GameAudio? audio = null, AdvisorSettings? advisors = null){- this.store = store; this.text = text; this.switchLanguage = switchLanguage; this.root = root; this.audio = audio;+ this.store = store; this.text = text; this.switchLanguage = switchLanguage; this.root = root; this.audio = audio; this.advisors = advisors;screen = root.Q<VisualElement>("screen-settings");screen.Q<Label>("settings-screen-title").text = text["settings.title"];screen.Q<Label>("settings-tiltshift-label").text = text["settings.tiltshift"];@@ -96,6 +99,18 @@ namespace Statecraft.Game.UIb.clicked += pick;return (b, l.level, pick);});+ // The help level is presentation-only and read live by the advisor queue (spec6).+ var helpLabel = screen.Q<Label>("settings-advisors-label");+ helpLabel.text = text["settings.advisors"];+ if (advisors == null) helpLabel.parent.style.display = DisplayStyle.None;+ helpLevels = Array.ConvertAll(AdvisorSettings.Levels, level =>+ {+ var b = screen.Q<Button>("settings-advisors-" + level);+ b.text = text["settings.advisors." + level];+ Action pick = () => { advisors?.SetLevel(level); Show(); };+ b.clicked += pick;+ return (b, level, pick);+ });// UI scale (#40): the panel scales with the screen from its 1920x1080 reference (ScaleWithScreenSize); dividing the// reference by the choice multiplies that scale by it, whatever the window. The whole UI is one panel. Dispose// puts the reference back: in the editor the panel is a project asset, and a choice must not stay in it.@@ -133,6 +148,7 @@ namespace Statecraft.Game.UIforeach (var (b, _, pick) in languages) b.clicked -= pick;foreach (var (b, _, pick) in sound) b.clicked -= pick;foreach (var (b, _, pick) in scales) b.clicked -= pick;+ foreach (var (b, _, pick) in helpLevels) b.clicked -= pick;unbindStar();root.UnregisterCallback<GeometryChangedEvent>(OnGeometry);if (panel != null) panel.referenceResolution = reference;@@ -237,6 +253,7 @@ namespace Statecraft.Game.UIforeach (var (b, c, _) in quality) b.EnableInClassList(SelectedClass, c == GraphicsQuality.Current);foreach (var (b, l, _) in languages) b.EnableInClassList(SelectedClass, l == text["ui.lang"]);foreach (var (b, l, _) in sound) b.EnableInClassList(SelectedClass, l == soundLevel);+ foreach (var (b, level, _) in helpLevels) b.EnableInClassList(SelectedClass, level == advisors?.Level);foreach (var (b, p, _) in scales){b.EnableInClassList(SelectedClass, p == uiScale);diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex 5d1c2880b..ecf71c3f5 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -33,6 +33,8 @@ namespace Statecraft.Game.UIpublic event Action<IReadOnlyList<Rejection>>? TurnEnded;/// <summary>Raised when Queue refuses an order, with the player-facing reason.</summary>public event Action<string>? Refused;+ /// <summary>A validated order was refused specifically for Attention; presentation-only advice signal.</summary>+ public event Action? RefusedForAttention;readonly UiText text;readonly Func<GameSession, IReadOnlyList<Command>, StepResult> step;@@ -201,7 +203,10 @@ namespace Statecraft.Game.UIif (State.GameOver != null) return Refuse(text["order.game_over"]);if (c is AllocateBudget ab) c = new AllocateBudget(new Dictionary<string, double>(ab.Shares)); // a snapshot: later edits to the caller's dictionary must not change the orderif (!CanPay(c))+ {+ Notify(RefusedForAttention); // presentation only: a failing listener never changes the refusalreturn Refuse(text.Format("order.no_attention", Price(c), LeftFor(c)));+ }var old = QueuedLike(c);if (old != null) queue[queue.IndexOf(old)] = c; else queue.Add(c);Changed?.Invoke();diff --git a/unity/Assets/Tests/EditMode/AdvisorCatalogTests.cs b/unity/Assets/Tests/EditMode/AdvisorCatalogTests.csindex 4dd831fc4..801d6030f 100644--- a/unity/Assets/Tests/EditMode/AdvisorCatalogTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorCatalogTests.cs@@ -69,6 +69,17 @@ public class AdvisorCatalogTestsAssert.IsEmpty(c.Problems(Strings("advisor.x.text", "advisor.x.cue.1", "lab"), Strings("advisor.x.text", "advisor.x.cue.1", "lab"), known));}+ [Test]+ public void AVerifiedQuoteRequiresItsSourceInBothLanguages()+ {+ CollectionAssert.AreEqual(new[] { "q1", "q2", "q3", "q4" }, AdvisorQuotes.Ids);+ var c = AdvisorCatalog.Parse(Head + "messages:\n - { id: x, advisor: meyerson, signal: new_game, level: new, quote: q1 }\n");+ var text = Strings("advisor.x.text", "advisor.quote.q1.text");+ var problems = c.Problems(text, text, AdvisorCatalog.Shipped());+ Assert.IsTrue(problems.Any(p => p.Contains("no advisor.quote.q1.source in strings.en.yaml")));+ Assert.IsTrue(problems.Any(p => p.Contains("no advisor.quote.q1.source in strings.he.yaml")));+ }+[Test]public void ParsesAMessageWithEveryField(){diff --git a/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.cs b/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.csnew file mode 100644index 000000000..fd4bcf1ea--- /dev/null+++ b/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.cs@@ -0,0 +1,98 @@+#nullable enable+using System;+using System.Collections;+using System.Collections.Generic;+using System.IO;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Spec 6: four help levels in Settings, the one set marked, kept in the settings file, applied at once.</summary>+public class AdvisorLevelSettingTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");++ [Test]+ public void PickingALevelKeepsItAndMarksIt()+ {+ var dir = Path.Combine(Path.GetTempPath(), "statecraft-level-" + Guid.NewGuid().ToString("N"));+ try+ {+ var store = new SettingsStore(dir);+ var advisors = new AdvisorSettings(store);+ using var ui = new UiTestKit();+ using var settings = new SettingsPresenter(ui.Root, En, store, advisors: advisors);+ Assert.IsTrue(ui.Q<Button>("settings-advisors-new").ClassListContains(SettingsPresenter.SelectedClass), "the default");+ ui.Press("settings-advisors-warnings");+ Assert.AreEqual("warnings", advisors.Level, "the live setting, so the queue filters at once");+ Assert.AreEqual("warnings", store.Read(AdvisorSettings.LevelKey));+ Assert.IsTrue(ui.Q<Button>("settings-advisors-warnings").ClassListContains(SettingsPresenter.SelectedClass));+ Assert.IsFalse(ui.Q<Button>("settings-advisors-new").ClassListContains(SettingsPresenter.SelectedClass));+ Assert.AreEqual(En["settings.advisors.off"], ui.Q<Button>("settings-advisors-off").text);+ }+ finally { if (Directory.Exists(dir)) Directory.Delete(dir, true); }+ }++ /// <summary>"New to strategy games" is the longest choice: at a phone's width, in both languages, every choice stays in+ /// the Settings screen. The HUD sets the screen's tier for the window (HudPresenter), as in the game.</summary>+ [UnityTest]+ public IEnumerator TheRowFitsOnAPhoneInBothLanguages()+ {+ var problems = new List<string>();+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h) in new[] { (390, 844), (844, 390), (1280, 720) })+ {+ var rt = new RenderTexture(w, h, 0);+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel)); ps.targetTexture = rt;+ var go = new GameObject("LevelRow"); go.SetActive(false);+ var doc = go.AddComponent<UIDocument>(); doc.panelSettings = ps;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);+ go.SetActive(true);+ var root = doc.rootVisualElement; root.Q("root").RemoveFromClassList("loading");+ if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ var text = hebrew ? He : En;+ var hud = new HudPresenter(root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text), text);+ var nav = new ScreenNav(root);+ var settings = new SettingsPresenter(root, text, null, advisors: new AdvisorSettings(null));+ nav.Open("settings");+ try+ {+ for (int i = 0; i < 30 && !(root.Q("screen-settings").layout.width > 0); i++) yield return null;+ for (int i = 0; i < 3; i++) yield return null;+ var screen = root.Q("screen-settings").worldBound;+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";+ var placed = new List<(string name, Rect b)>();+ // Each choice, and the screen's last control (the row must not push it out), inside the screen on both axes.+ foreach (var name in new[] { "settings-advisors-new", "settings-advisors-experienced", "settings-advisors-warnings", "settings-advisors-off", "settings-share" })+ {+ var b = root.Q(name).worldBound;+ if (!(b.width > 0) || b.xMin < screen.xMin - 0.5f || b.xMax > screen.xMax + 0.5f || b.yMin < screen.yMin - 0.5f || b.yMax > screen.yMax + 0.5f)+ problems.Add($"{at}: {name} {b} leaves the screen {screen}");+ if (name.StartsWith("settings-advisors-", StringComparison.Ordinal)) placed.Add((name, b));+ }+ // Wrapped, the choices never overlap.+ for (int i = 0; i < placed.Count; i++)+ for (int j = i + 1; j < placed.Count; j++)+ {+ var x = placed[i].b; var y = placed[j].b;+ if (x.xMin < y.xMax - 0.5f && y.xMin < x.xMax - 0.5f && x.yMin < y.yMax - 0.5f && y.yMin < x.yMax - 0.5f)+ problems.Add($"{at}: {placed[i].name} {x} overlaps {placed[j].name} {y}");+ }+ }+ finally+ {+ settings.Dispose(); nav.Dispose(); hud.Dispose();+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);+ }+ }+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }+}diff --git a/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.cs.meta b/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.cs.metanew file mode 100644index 000000000..ef662db5f--- /dev/null+++ b/unity/Assets/Tests/EditMode/AdvisorLevelSettingTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 7dad9e82733a410686e651e718f15cafdiff --git a/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs b/unity/Assets/Tests/EditMode/AdvisorPopupTests.csindex fe9faccbe..3217c9ed3 100644--- a/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs+++ b/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs@@ -67,6 +67,29 @@ public class AdvisorPopupTestsstatic bool Displayed(Button b) => b.style.display.value != DisplayStyle.None;+ /// <summary>Spec 3.2: a real quote shows only from the verified list, styled as a quote with its source under it; the+ /// advisor's own line stays plain game dialogue.</summary>+ [Test]+ public void AQuoteShowsWithItsSourceAndOnlyThere()+ {+ using var rig = new Rig(catalog: Fixture.Replace("level: new, actions: [{ open_screen: budget }]", "level: new, quote: q1"));+ rig.Advisor.NewGame();+ Assert.AreEqual(En["advisor.quote.q1.text"], rig.Ui.Q<Label>("advisor-quote").text);+ Assert.AreEqual(En["advisor.quote.q1.source"], rig.Ui.Q<Label>("advisor-quote-source").text);+ Assert.AreEqual("Teach.", rig.Ui.Q<Label>("advisor-text").text, "the advisor's own line stays plain");+ rig.Ui.Press("advisor-got-it");+ rig.EndTurn();+ Assert.AreEqual(DisplayStyle.None, rig.Ui.Q<Label>("advisor-quote").style.display.value, "a message without a quote shows none");+ }+ [Test]+ public void AnUnverifiedQuoteNeverShowsEvenInAnUncheckedFixture()+ {+ using var rig = new Rig(catalog: Fixture.Replace("level: new, actions: [{ open_screen: budget }]", "level: new, quote: q9"));+ rig.Advisor.NewGame();+ Assert.AreEqual(DisplayStyle.None, rig.Ui.Q<Label>("advisor-quote").style.display.value);+ Assert.AreEqual("", rig.Ui.Q<Label>("advisor-quote-source").text);+ }+[Test]public void ATeachingMessageShowsItsAdvisorTextAndButtons(){diff --git a/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.csnew file mode 100644index 000000000..3cc1ca6c0--- /dev/null+++ b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs@@ -0,0 +1,400 @@+#nullable enable+using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using System.Text.RegularExpressions;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Boot;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Spec 5 and 6: each signal on built states, and the critical warnings at every help level.</summary>+public class AdvisorSignalsTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ static SimBridge Bridge() => new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En);+ static bool Holds(SimBridge b, string signal) => AdvisorSignals.States[signal](new AdvisorContext(b, null));+ static double Ceiling(SimBridge b) => C.RulesAt(b.State.Date).Mvp!.DebtCeiling!.Value;++ readonly List<string> temp = new List<string>();+ string TempDir()+ {+ var dir = Path.Combine(Path.GetTempPath(), "statecraft-signals-" + Guid.NewGuid().ToString("N"));+ temp.Add(dir);+ return dir;+ }++ [TearDown]+ public void Clean()+ {+ if (temp.Count == 0) return;+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); // after the scene test+ foreach (var d in temp) { try { if (Directory.Exists(d)) Directory.Delete(d, true); } catch (Exception) { } }+ temp.Clear();+ }++ /// <summary>The ids the queue would show now, in order, taking each as Got it would (the popup itself untouched).</summary>+ static List<string> Waiting(AdvisorSession session, SimBridge bridge)+ {+ var ids = new List<string>();+ while (session.Queue.Head(bridge.State.Turn, hebrew: false) is AdvisorCatalog.Message m) { ids.Add(m.Id); session.Queue.Done(m, bridge.State.Turn, bridge.State.Date); }+ return ids;+ }++ /// <summary>Review (must-fix 2): a game loaded with Continue already at the debt ceiling has its critical warning as the+ /// start screen closes, not only after the next change.</summary>+ [Test]+ public void AContinuedGameHearsItsWarningsAtOnce()+ {+ var store = new SaveStore(TempDir());+ var played = new SimBridge(GameSession.New(C, 9, Mode.Historical), En);+ played.EndTurn();+ store.WriteAutosave(played.Session.Save.Write());+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var inputs = GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);+ Object.FindFirstObjectByType<MapScene>().Build(inputs.Map);+ var game = Object.FindFirstObjectByType<GameRoot>();+ game.Store = store; game.Settings = new SettingsStore(TempDir()); game.Language = UiLanguage.English;+ game.Begin(inputs, 0, startScreen: true);+ var bridge = game.Bridge!;+ bridge.State.Debt = Ceiling(bridge); // as a save at the ceiling would load+ UiTestKit.Press(Object.FindFirstObjectByType<UIDocument>().rootVisualElement.Q<Button>("start-continue"));+ CollectionAssert.Contains(Waiting(game.AdvisorSession!, bridge), "meyerson.debt_ceiling");+ }++ /// <summary>Review (must-fix 3): Submit takes the unsubmitted-budget warning back, shown or waiting, as GameRoot wires the+ /// Budget screen to the advisor.</summary>+ [Test]+ public void SubmittingTheBudgetTakesItsWarningBack()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text);+ using var budget = new BudgetPresenter(rig.Ui.Root, rig.Bridge, text);+ budget.UnsubmittedChanged += rig.Advisor.BudgetUnsubmitted;+ rig.Ui.Press("budget-education_minister-up");+ Assert.AreEqual("meyerson.budget_unsubmitted", rig.Advisor.Shown?.Id, "an edit not submitted");+ rig.Ui.Press("budget-submit");+ Assert.AreNotEqual("meyerson.budget_unsubmitted", rig.Advisor.Shown?.Id, "submitted: no longer true");+ CollectionAssert.DoesNotContain(Drain(rig), "meyerson.budget_unsubmitted", "nor waiting");+ }++ /// <summary>Review (should 4): a new help level applies to the popup at once, both ways.</summary>+ [Test]+ public void ANewHelpLevelAppliesAtOnce()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text);+ rig.Session.Settings.SetLevel("off");+ rig.Advisor.Notice(AdvisorSignals.BudgetUnsubmitted);+ Assert.IsNull(rig.Advisor.Shown, "Off: no warning");+ rig.Session.Settings.SetLevel("warnings");+ Assert.AreEqual("meyerson.budget_unsubmitted", rig.Advisor.Shown?.Id, "Warnings only: shown at once");+ rig.Session.Settings.SetLevel("off");+ Assert.IsNull(rig.Advisor.Shown, "Off again: gone at once");+ }++ /// <summary>The owner approved these Hebrew lines word for word (24 October 2026: "Hebrew approved" for the critical three,+ /// "approved" for the rest; defeat_economy with the review sheet's grammar fix, תורים); a different text+ /// needs a new approval, so it must also set he_review back to pending.</summary>+ [TestCase("dayan.city_at_risk", "התקפת אויב מכוונת לאחת מערי המדינה. בדקו את מגיני העיר ואת תחזית הקרב לפני ששלב האויב מוכרע.")]+ [TestCase("meyerson.exhausted", "הכסף והמזון אזלו יחד. החזירו אחד מהם לפני שמונה ההפסד יגיע לגבולו.")]+ [TestCase("meyerson.debt_ceiling", "החוב הגיע לתקרה. אם גם מלאי המזון ריק בסוף התור, מונה ההפסד מתחיל או ממשיך לרוץ.")]+ [TestCase("meyerson.food_short", "בתור הזה המדינה נזקקה ליותר מזון ממה שהיה לה. מחסור במזון גם מוריד את הלכידות החברתית.")]+ [TestCase("dayan.defeat_war", "יחידה צבאית של האויב מחזיקה באחת מערי המדינה בסוף התור. המערכה הסתיימה בתבוסה.")]+ [TestCase("ben_gurion.defeat_economy", "שלושה תורים ברציפות הסתיימו כשהחוב שלנו בתקרה או מעליה ומלאי המזון ריק, וזה מסיים את המשחק.")]+ [TestCase("meyerson.budget_unsubmitted", "בתקציב יש שינויים שלא הוגשו. הם לא ייכנסו לתוקף בסיום התור עד שתגישו את התקציב.")]+ [TestCase("dayan.arms_out", "הנשק מצייד את האימון הצבאי ומתכלה בהתקפות. קניית נשק בכסף לפני שהמלאי אוזל שומרת את האפשרויות האלה פתוחות.")]+ public void AnApprovedHebrewLineIsTheTextTheOwnerRead(string id, string hebrew)+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ Assert.AreEqual(AdvisorCatalog.Approved, AdvisorCatalog.Parse(System.IO.File.ReadAllText(AdvisorCatalog.Path)).Find(id)!.HeReview);+ Assert.AreEqual(hebrew, he["advisor." + id + ".text"]);+ }++ [Test]+ public void TheEconomySignalsReadTheShownState()+ {+ var b = Bridge();+ foreach (var s in new[] { "exhausted", "in_debt", "food_short", "defeat_war", "defeat_economy" }) Assert.IsFalse(Holds(b, s), "a new game: " + s);+ b.State.ExhaustedTurns = 1; b.State.Debt = Ceiling(b) * 0.85; b.State.FoodUnmet = 3;+ Assert.IsTrue(Holds(b, "exhausted")); Assert.IsTrue(Holds(b, "in_debt")); Assert.IsTrue(Holds(b, "food_short"));+ Assert.AreEqual(0.85, AdvisorSignals.Measures["debt_ratio_at_least"](new AdvisorContext(b, null)), 1e-9);+ // meyerson.debt_ceiling's bound, read from the shipped row: the ceiling itself (R-END-001: Money is exhausted at or above it).+ var atCeiling = AdvisorCatalog.Parse(System.IO.File.ReadAllText(AdvisorCatalog.Path)).Find("meyerson.debt_ceiling")!.When;+ b.State.Debt = Ceiling(b) * 0.99; Assert.IsFalse(AdvisorSignals.When(new AdvisorContext(b, null), atCeiling), "below the ceiling");+ b.State.Debt = Ceiling(b); Assert.IsTrue(AdvisorSignals.When(new AdvisorContext(b, null), atCeiling), "at the ceiling");+ b.State.Debt = Ceiling(b) * 1.1; Assert.IsTrue(AdvisorSignals.When(new AdvisorContext(b, null), atCeiling), "above the ceiling");+ b.State.GameOver = GameOverCodes.DefeatWar;+ Assert.IsTrue(Holds(b, "defeat_war")); Assert.IsFalse(Holds(b, "defeat_economy"));+ }++ /// <summary>An enemy unit on one of our cities' hexes is a city at risk (Threats.CitiesAtRisk); taken away, the signal+ /// reads the helper again.</summary>+ [Test]+ public void TheCityAtRiskSignalIsTheSimsHelper()+ {+ var b = Bridge();+ bool before = Threats.CitiesAtRisk(C, b.State).Count > 0;+ Assert.AreEqual(before, Holds(b, "city_at_risk"));+ var city = C.SettlementHexes.First(h => b.State.Cities.ContainsKey(h.Id));+ int id = b.State.Units.Keys.Max() + 1;+ b.State.Units[id] = new Unit(id, "egyptian_army", city.Q, city.R, side: "egypt", strength: 10);+ CollectionAssert.Contains(Threats.CitiesAtRisk(C, b.State).ToList(), city.Id);+ Assert.IsTrue(Holds(b, "city_at_risk"), "an enemy unit stands on " + city.Id);+ b.State.Units.Remove(id);+ Assert.AreEqual(before, Holds(b, "city_at_risk"));+ }++ /// <summary>Spec 6: "Off" keeps every critical warning, and two in one turn both show, one after the other; a+ /// warnings-level message that holds at the same time (food_short) waits for "Warnings only" or chattier.</summary>+ [Test]+ public void OffStillShowsEveryCriticalWarning()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text);+ rig.Session.Settings.SetLevel("off");+ rig.Bridge.State.ExhaustedTurns = 1; rig.Bridge.State.Debt = Ceiling(rig.Bridge); rig.Bridge.State.FoodUnmet = 3;+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ var shown = Drain(rig);+ CollectionAssert.IsSubsetOf(new[] { "meyerson.exhausted", "meyerson.debt_ceiling" }, shown);+ CollectionAssert.DoesNotContain(shown, "meyerson.food_short", "Off");+ Assert.IsTrue(shown.All(id => rig.Session.Catalog.Find(id)!.Critical), "Off: nothing but critical");+ rig.Session.Settings.SetLevel("warnings");+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.Contains(Drain(rig), "meyerson.food_short", "Warnings only");+ }++ /// <summary>The owner approved the critical warnings' Hebrew (24 October 2026, "Hebrew approved"): a Hebrew player sees+ /// them at Off; food_short, approved too, waits for Warnings only.</summary>+ [Test]+ public void TheCriticalWarningsShowInHebrew()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: he);+ rig.Session.Settings.SetLevel("off");+ rig.Bridge.State.ExhaustedTurns = 1; rig.Bridge.State.Debt = Ceiling(rig.Bridge); rig.Bridge.State.FoodUnmet = 3;+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.IsSubsetOf(new[] { "meyerson.exhausted", "meyerson.debt_ceiling" }, Drain(rig));+ rig.Session.Settings.SetLevel("warnings");+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.Contains(Drain(rig), "meyerson.food_short", "approved Hebrew, at Warnings only");+ foreach (var id in new[] { "dayan.city_at_risk", "meyerson.exhausted", "meyerson.debt_ceiling" })+ Assert.IsTrue(rig.Session.Catalog.Find(id)!.ApprovedIn(hebrew: true), id);+ }++ /// <summary>Task 18: an unsubmitted budget change (BudgetPresenter.UnsubmittedChanged, wired by GameRoot) is a warning.</summary>+ [Test]+ public void AnUnsubmittedBudgetIsAWarning()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text);+ rig.Session.Settings.SetLevel("off");+ rig.Advisor.Notice(AdvisorSignals.BudgetUnsubmitted);+ CollectionAssert.DoesNotContain(Drain(rig), "meyerson.budget_unsubmitted", "Off");+ rig.Session.Settings.SetLevel("warnings");+ rig.Advisor.Notice(AdvisorSignals.BudgetUnsubmitted);+ CollectionAssert.Contains(Drain(rig), "meyerson.budget_unsubmitted", "Warnings only");+ }++ static System.Collections.Generic.List<string> Drain(AdvisorPopupTests.Rig rig)+ {+ var shown = new System.Collections.Generic.List<string>();+ while (rig.Advisor.Shown is AdvisorCatalog.Message m) { shown.Add(m.Id); rig.Ui.Press("advisor-got-it"); }+ return shown;+ }++ /// <summary>The owner's 24 October 2026 ruling ("Adopt clip words"): these messages say the recorded clips' words, by+ /// the clips' speakers (talking-v3/lines.csv), so a clip can attach to its message; a text edit needs a new recording.</summary>+ [TestCase("dayan.city_at_risk", "dayan", "An enemy attack is aimed at one of the country's cities. Review its defenders and the combat preview before the enemy phase resolves.")]+ [TestCase("meyerson.exhausted", "meyerson", "Money and Food are exhausted together. Restore either one before the defeat counter reaches its limit.")]+ [TestCase("meyerson.debt_ceiling", "meyerson", "Debt has reached the ceiling. If Food is also empty at turn end, the defeat counter begins or continues.")]+ [TestCase("dayan.defeat_war", "dayan", "An enemy military unit holds one of the country's cities at turn end. The campaign has ended in defeat.")]+ [TestCase("dayan.arms_out", "dayan", "Arms equip military training and are spent in attacks. Buying Arms with Money before the stock runs short keeps those choices available.")]+ public void AClipLineKeepsTheRecordedWordsAndSpeaker(string id, string advisor, string words)+ {+ var m = AdvisorCatalog.Parse(System.IO.File.ReadAllText(AdvisorCatalog.Path)).Find(id);+ Assert.IsNotNull(m, id);+ Assert.AreEqual(advisor, m!.Advisor);+ Assert.AreEqual(words, En["advisor." + id + ".text"]);+ }++ [Test]+ public void TheEndScreenNamesTheWarLoss()+ {+ foreach (var file in new[] { UiPaths.Strings, UiPaths.StringsHebrew })+ Assert.IsTrue(UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(file).text).Has("end.outcome.defeat_war"), file);+ Assert.AreEqual("The enemy holds a city.", En["end.outcome.defeat_war"], "Q-DEF-4 (b)'s line (PlayerText.cs:27)");+ }++ [Test]+ public void AnOrderRefusedForAttentionRaisesItsOwnEvent()+ {+ var b = Bridge();+ var ev = C.Events.First(e => e.Id == b.State.PendingEvents[0]);+ var order = new ChooseEventOption(ev.Id, ev.Options[0].Id);+ Assume.That(b.Price(order), Is.GreaterThan(0), "the opening card's answer costs Attention");+ b.State.Attention = 0;+ int raised = 0; b.RefusedForAttention += () => raised++;+ Assert.IsNotNull(b.Queue(order));+ Assert.AreEqual(1, raised);+ Assert.IsNotNull(b.Queue(new SetPolicy("no_such_policy", 1)), "a refusal for another reason");+ Assert.AreEqual(1, raised, "raises nothing");+ }++ /// <summary>Review (pre-#1602, must-fix 1): the advisor's hook never changes how an order is refused. A throwing+ /// RefusedForAttention subscriber is logged, and the order still gets its ordinary refusal, Refused included.</summary>+ [Test]+ public void AThrowingAttentionSubscriberLeavesTheRefusalAlone()+ {+ var b = Bridge();+ var ev = C.Events.First(e => e.Id == b.State.PendingEvents[0]);+ var order = new ChooseEventOption(ev.Id, ev.Options[0].Id);+ Assume.That(b.Price(order), Is.GreaterThan(0), "the opening card's answer costs Attention");+ b.State.Attention = 0;+ string? refused = null; b.Refused += r => refused = r;+ b.RefusedForAttention += () => throw new InvalidOperationException("advisor hook failed");+ LogAssert.Expect(LogType.Exception, new Regex("advisor hook failed"));+ var why = b.Queue(order);+ Assert.IsNotNull(why, "still refused");+ Assert.AreEqual(why, refused, "and Refused still raised");+ Assert.IsEmpty(b.Queued, "nothing queued");+ }++ /// <summary>Review (pre-#1602, should 2): the city warning is critical, shown at Off, in English and approved Hebrew.</summary>+ [TestCase(false)]+ [TestCase(true)]+ public void ACityAtRiskIsWarnedAtOff(bool hebrew)+ {+ var text = hebrew ? UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml")+ : UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text);+ rig.Session.Settings.SetLevel("off");+ var b = rig.Bridge;+ var city = C.SettlementHexes.First(h => b.State.Cities.ContainsKey(h.Id));+ int id = b.State.Units.Keys.Max() + 1;+ b.State.Units[id] = new Unit(id, "egyptian_army", city.Q, city.R, side: "egypt", strength: 10);+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.Contains(Drain(rig), "dayan.city_at_risk");+ }++ /// <summary>Review (pre-#1602, should 3), end to end on the shipped row: the owner's "Approve 3 / costliest action" means 4+ /// Arms say nothing and 3 Arms bring Dayan's warning, at Warnings only and not at Off.</summary>+ [Test]+ public void DayanWarnsAtThreeArmsAtWarningsOnly()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ using (var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text))+ {+ rig.Session.Settings.SetLevel("warnings");+ rig.Bridge.State.Arms = 4;+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.DoesNotContain(Drain(rig), "dayan.arms_out", "4 Arms");+ }+ using (var rig = new AdvisorPopupTests.Rig(catalog: System.IO.File.ReadAllText(AdvisorCatalog.Path), text: text))+ {+ rig.Session.Settings.SetLevel("off");+ rig.Bridge.State.Arms = 3;+ rig.Advisor.Notice(AdvisorSignals.TurnEnded);+ CollectionAssert.DoesNotContain(Drain(rig), "dayan.arms_out", "3 Arms at Off");+ rig.Session.Settings.SetLevel("warnings");+ CollectionAssert.Contains(Drain(rig), "dayan.arms_out", "3 Arms at Warnings only");+ }+ }++ [Test]+ public void AnObjectiveDoneHolds()+ {+ var b = Bridge();+ Assert.IsFalse(Holds(b, "objective_done"));+ b.State.Objectives[C.Objectives[0].Id] = b.State.Date;+ Assert.IsTrue(Holds(b, "objective_done"));+ }+ [Test]+ public void MeyersonsSignalsReadTheShownState()+ {+ var b = Bridge();+ var c = new AdvisorContext(b, null);+ Assert.AreEqual(b.State.UnlockedProjects.Count > 0, Holds(b, "project_unlocked"));+ Assert.AreEqual(b.State.Corridors.Count > 0, Holds(b, "corridor_started"));+ Assert.AreEqual(b.Vacancies.Count > 0, Holds(b, "cabinet_vacancy"));+ Assert.AreEqual(b.State.ActiveSituations.Count > 0, Holds(b, "situation_active"));+ var idle = b.State.Units.Values.Any(u => u.Side == "" && Projects.IsPioneer(u.Type) && !Projects.IsBusy(b.State, u.Id));+ Assert.AreEqual(idle, Holds(b, "idle_pioneer"));+ int id = b.State.Units.Keys.Max() + 1;+ b.State.Units[id] = new Unit(id, "halutz", 0, 0);+ Assert.IsTrue(Holds(b, "idle_pioneer"), "a halutz with no project");+ b.State.UnlockedProjects.Add("any"); b.State.ActiveSituations.Add("any");+ Assert.IsTrue(Holds(b, "project_unlocked")); Assert.IsTrue(Holds(b, "situation_active"));+ }+ [Test]+ public void DayansSignalsReadTheShownStateAndTheLastTurn()+ {+ var b = Bridge();+ bool ordered = b.State.Units.Values.Any(u => u.Side == Movement.PlayerSide && u.Order != "");+ Assert.AreEqual(ordered, Holds(b, "standing_order"));+ int id = b.State.Units.Keys.Max() + 1;+ b.State.Units[id] = new Unit(id, "recruit", 0, 0, side: Movement.PlayerSide, strength: 1, order: "hold");+ Assert.IsTrue(Holds(b, "standing_order"), "a unit on hold");+ b.State.Units.Remove(id);+ Assert.AreEqual(ordered, Holds(b, "standing_order"));+ Assert.IsFalse(Holds(b, "combat_seen"), "no turn yet");+ Assert.IsFalse(Holds(b, "enemy_moved"), "no turn yet");+ b.EndTurn();+ var why = b.Session.Last!.Why;+ Assert.AreEqual(why.Any(w => w.Key == WhyKeys.Engagement), Holds(b, "combat_seen"));+ Assert.AreEqual(why.Any(w => w.EnemyOrder != ""), Holds(b, "enemy_moved"));+ b.State.Arms = 0;+ Assert.AreEqual(C.IsGdd, Holds(b, "arms_low"), "an empty stock");+ Assert.AreEqual(b.State.Settlements.Values.Any(x => x.State == SettlementControl.AwaitingChoice), Holds(b, "capture_waiting"));+ }+ /// <summary>Owner, 24 October 2026: "Fire when low". Low (an owner-set DESIGN VALUE, "Approve 3 / costliest action") is at or below the Arms the+ /// costliest single Arms action takes under the current rules: a recruit group (mvp.arms_per_recruit_group, R-ARMS-003),+ /// an attack (mvp.arms_per_attack, R-COMBAT-004), or an Israeli type's training_arms or arms_per_fire (R-UNIT-008,+ /// R-COMBAT-007). Today an artillery group's 3. At or below it fires, above it does not, and an empty stock fires.</summary>+ [Test]+ public void ArmsAreLowAtOrBelowTheCostliestSingleAction()+ {+ var b = Bridge();+ var mvp = C.RulesAt(b.State.Date).Mvp!;+ var israeli = C.UnitTypes.Where(t => t.Side == Movement.PlayerSide).ToList();+ int reserve = new[] { mvp.ArmsPerRecruitGroup!.Value, mvp.ArmsPerAttack!.Value }+ .Concat(israeli.Select(t => t.TrainingArms ?? 0)).Concat(israeli.Select(t => t.ArmsPerFire ?? 0)).Max();+ Assert.AreEqual(3, reserve, "today's content: the artillery group's training_arms (unit_types.yaml)");+ Assert.AreEqual(reserve, AdvisorSignals.ArmsReserve(new AdvisorContext(b, null)));+ Assert.IsFalse(Holds(b, "arms_low"), "a new game's 12 Arms");+ b.State.Arms = reserve + 1; Assert.IsFalse(Holds(b, "arms_low"), "one above");+ b.State.Arms = reserve; Assert.IsTrue(Holds(b, "arms_low"), "at the reserve");+ b.State.Arms = reserve - 1; Assert.IsTrue(Holds(b, "arms_low"), "below");+ b.State.Arms = 0; Assert.IsTrue(Holds(b, "arms_low"), "empty");+ }++ [Test]+ public void RefugeesAreCountedFromTheShownCities()+ {+ var b = Bridge();+ double before = b.State.Cities.Values.Sum(x => x.Refugees);+ Assert.AreEqual(before, AdvisorSignals.Measures["refugees_at_least"](new AdvisorContext(b, null)));+ var city = b.State.Cities.Values.First();+ b.State.Cities[city.Id] = city.WithCounts(city.Civilians, city.Employed, city.Refugees + 7);+ Assert.AreEqual(before + 7, AdvisorSignals.Measures["refugees_at_least"](new AdvisorContext(b, null)));+ }++ [Test]+ public void TruceSignalUsesThePublicSimHelper()+ {+ var b = Bridge();+ Assert.IsFalse(Holds(b, "truce_active"), "15 May 1948: no truce accepted");+ b.State.ChosenOptions["first_truce"] = "accept"; // R-COMBAT-009: in force until 8 July 1948+ Assert.IsTrue(Holds(b, "truce_active"));+ }+}diff --git a/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs.meta b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs.metanew file mode 100644index 000000000..caf1494ea--- /dev/null+++ b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: e7507fe082124cdea5aa6f632c35e184diff --git a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs b/unity/Assets/Tests/EditMode/BudgetScreenTests.csindex 89304a481..470c2327f 100644--- a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs+++ b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs@@ -13,6 +13,21 @@ public class BudgetScreenTestsstatic readonly Content C = ContentLoader.Load(Paths.Content);static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ [Test]+ public void UnsubmittedChangedFiresOnlyWhenTheBadgeChanges()+ {+ using var ui = new UiTestKit();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ using var budget = new BudgetPresenter(ui.Root, bridge, Text);+ var changed = new List<bool>();+ budget.UnsubmittedChanged += on => changed.Add(on);+ ui.Press("budget-education_minister-up");+ budget.Render();+ CollectionAssert.AreEqual(new[] { true }, changed, "re-rendering the same badge emits nothing");+ ui.Press("budget-submit");+ CollectionAssert.AreEqual(new[] { true, false }, changed, "Submit clears the unsubmitted badge");+ }+[Test]public void AdjustKeepsTheTotalAtExactlyOne(){diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex 876c390cd..94ebd06d1 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -292,7 +292,7 @@ public class HebrewUiTests("settings-quality-high", "settings.quality.high"), ("settings-quality-low", "settings.quality.low"),("settings-sound-label", "settings.sound"), ("settings-sound-off", "settings.sound.off"),("settings-sound-low", "settings.sound.low"), ("settings-sound-high", "settings.sound.high"),- ("settings-language-label", "settings.language"),+ ("settings-advisors-label", "settings.advisors"), ("settings-language-label", "settings.language"),("settings-uiscale-label", "settings.uiscale"),("settings-community-label", "settings.community"), ("settings-star", "community.star"), ("start-star", "community.star"),("settings-report", "feedback.open"), ("start-report", "feedback.open"), ("feedback-title", "feedback.open"), // #1169diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex ffeb9bebe..37c20f3b7 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -422,6 +422,16 @@<ui:Button name="settings-sound-high" text="High" class="settings-switch" /></ui:VisualElement></ui:VisualElement>+ <!-- How much the advisors say (spec 6, AdvisorSettings): four levels, the one set carries .settings-choice-selected. -->+ <ui:VisualElement class="row settings-row">+ <ui:Label name="settings-advisors-label" text="Advisors" class="settings-name" />+ <ui:VisualElement class="row settings-choices settings-advisors">+ <ui:Button name="settings-advisors-new" class="settings-switch" />+ <ui:Button name="settings-advisors-experienced" class="settings-switch" />+ <ui:Button name="settings-advisors-warnings" class="settings-switch" />+ <ui:Button name="settings-advisors-off" class="settings-switch" />+ </ui:VisualElement>+ </ui:VisualElement><!-- The UI's language (#1036): SettingsPresenter names each language in itself; the one in use carries .settings-choice-selected. --><ui:VisualElement class="row settings-row"><ui:Label name="settings-language-label" text="Language" class="settings-name" />@@ -469,6 +479,8 @@<ui:VisualElement name="advisor-media" class="advisor-media" /><ui:ScrollView name="advisor-body" class="advisor-body"><ui:Label name="advisor-text" class="advisor-text" />+ <ui:Label name="advisor-quote" class="advisor-quote" />+ <ui:Label name="advisor-quote-source" class="muted advisor-quote-source" /></ui:ScrollView><!-- The disclosure and credit: under the live caption, never over the picture (spec 12, OQ-16). --><ui:Label name="advisor-media-label" class="muted advisor-media-label" />diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 124a38ea3..04b456620 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -1027,6 +1027,14 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas.advisor-ring-open #attention { margin-bottom: 5px; }.advisor-ring-open.hud-narrow #attention { margin-bottom: 8px; }+/* The help-level choices can wrap within narrow Settings screens (spec6). */+.settings-advisors { flex-wrap: wrap; flex-shrink: 1; }++/* Only spec3.3 verified quotes, separated from the advisor's game dialogue, with their source. */+.advisor-quote { white-space: normal; font-size: 20px; -unity-font-style: italic; margin: 2px 12px 0 12px; border-left-width: 2px; border-color: var(--gold-dim); padding-left: 8px; }+.lang-he .advisor-quote { border-left-width: 0; border-right-width: 2px; padding-left: 0; padding-right: 8px; }+.advisor-quote-source { white-space: normal; font-size: 15px; margin: 2px 12px 6px 12px; }+/* User-started advisor media: live caption replaces the prose; no shipped media row means no Watch badge. */.advisor-watch { display: none; position: absolute; bottom: 0; left: 0; right: 0; min-width: 0; font-size: 15px; padding: 1px 2px; }.advisor-media, .advisor-media-label { display: none; }diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 886c5f4ed..578c5dc8d 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -641,6 +641,33 @@ advisor.done: "Done"# {0} the step, {1} the steps in the chain now.advisor.step: "Step {0} of {1}"+# Advisor help levels (spec6). English and Hebrew approved by the owner, 24 October 2026 ("approved both").+settings.advisors: "Advisors"+settings.advisors.new: "New to strategy games"+settings.advisors.experienced: "Experienced"+settings.advisors.warnings: "Warnings only"+settings.advisors.off: "Off"++# S4 Task16 warnings (spec6). Their Hebrew is approved by the owner (24 October 2026); see advisor-messages.yaml. "three": rules.yaml defeat_turns (R-END-002, a+# design value). Change that line if the rule changes. The clip lines (city_at_risk, exhausted, debt_ceiling, defeat_war,+# arms_out) are the recorded words, word for word (advisor-messages.yaml); change them only with a new recording. The other+# three (food_short, defeat_economy, budget_unsubmitted) and end.outcome.defeat_war are approved by the owner, 24 October+# 2026 ("approved both").+advisor.dayan.city_at_risk.text: "An enemy attack is aimed at one of the country's cities. Review its defenders and the combat preview before the enemy phase resolves."+advisor.meyerson.exhausted.text: "Money and Food are exhausted together. Restore either one before the defeat counter reaches its limit."+advisor.meyerson.debt_ceiling.text: "Debt has reached the ceiling. If Food is also empty at turn end, the defeat counter begins or continues."+advisor.meyerson.food_short.text: "This turn the country needed more Food than it had. A Food shortage also lowers Social cohesion."+advisor.dayan.defeat_war.text: "An enemy military unit holds one of the country's cities at turn end. The campaign has ended in defeat."+advisor.ben_gurion.defeat_economy.text: "Three turns in a row ended with our debt at or above the ceiling and the Food stock empty, and that ends the game."+end.outcome.defeat_war: "The enemy holds a city."+advisor.meyerson.budget_unsubmitted.text: "The budget has changes that are not submitted. They will not apply when the turn ends until you submit the budget."+advisor.dayan.arms_out.text: "Arms equip military training and are spent in attacks. Buying Arms with Money before the stock runs short keeps those choices available."++# Spec3.3 verified Q1, attributed to the Declaration, never a person. The Hebrew source label is approved by the owner,+# 24 October 2026 ("approved both").+advisor.quote.q1.text: "“THE STATE OF ISRAEL will be open for Jewish immigration and for the Ingathering of the Exiles;”"+advisor.quote.q1.source: "Declaration of the Establishment of the State of Israel, 14 May 1948"+# Advisor media control (spec12). Hebrew UI draft for the native reviewer (#564).advisor.watch: "Watch"# The media row's disclosure (owner, 24 Oct 2026, OQ-16 option 2; spec 11.3, 12): exactly this text, shown small.diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 1b8264f99..f768df1ca 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -682,6 +682,30 @@ advisor.next: "הבא"advisor.done: "סיום"advisor.step: "שלב {0} מתוך {1}"+# Advisor help levels (spec6). English and Hebrew approved by the owner, 24 October 2026 ("approved both").+settings.advisors: "יועצים"+settings.advisors.new: "חדשים במשחקי אסטרטגיה"+settings.advisors.experienced: "מנוסים"+settings.advisors.warnings: "אזהרות בלבד"+settings.advisors.off: "כבוי"++# S4 Task16 warnings (spec6). Approved by the owner, a native speaker (24 October 2026; advisor-messages.yaml records the+# rulings); any change needs a new approval. end.outcome.defeat_war is approved too (24 October 2026, "approved both").+advisor.dayan.city_at_risk.text: "התקפת אויב מכוונת לאחת מערי המדינה. בדקו את מגיני העיר ואת תחזית הקרב לפני ששלב האויב מוכרע."+advisor.meyerson.exhausted.text: "הכסף והמזון אזלו יחד. החזירו אחד מהם לפני שמונה ההפסד יגיע לגבולו."+advisor.meyerson.debt_ceiling.text: "החוב הגיע לתקרה. אם גם מלאי המזון ריק בסוף התור, מונה ההפסד מתחיל או ממשיך לרוץ."+advisor.meyerson.food_short.text: "בתור הזה המדינה נזקקה ליותר מזון ממה שהיה לה. מחסור במזון גם מוריד את הלכידות החברתית."+advisor.dayan.defeat_war.text: "יחידה צבאית של האויב מחזיקה באחת מערי המדינה בסוף התור. המערכה הסתיימה בתבוסה."+advisor.ben_gurion.defeat_economy.text: "שלושה תורים ברציפות הסתיימו כשהחוב שלנו בתקרה או מעליה ומלאי המזון ריק, וזה מסיים את המשחק."+end.outcome.defeat_war: "האויב מחזיק בעיר."+advisor.meyerson.budget_unsubmitted.text: "בתקציב יש שינויים שלא הוגשו. הם לא ייכנסו לתוקף בסיום התור עד שתגישו את התקציב."+advisor.dayan.arms_out.text: "הנשק מצייד את האימון הצבאי ומתכלה בהתקפות. קניית נשק בכסף לפני שהמלאי אוזל שומרת את האפשרויות האלה פתוחות."++# Spec3.3 verified Q1, attributed to the Declaration, never a person. The Hebrew source label is approved by the owner,+# 24 October 2026 ("approved both").+advisor.quote.q1.text: "«מדינת ישראל תהא פתוחה לעליה יהודית ולקיבוץ גלויות;»"+advisor.quote.q1.source: "ההכרזה על הקמת מדינת ישראל, 14 במאי 1948"+# Advisor media control (spec12). Hebrew UI draft for the native reviewer (#564).advisor.watch: "צפייה"# The media row's disclosure (OQ-16). Hebrew draft for the native reviewer (#564).