Skip to content

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

Advisors: drop a waiting warning once its cause has passed (#2024) (#2110)

Beri1a6dbde1e3e2
diff --git a/changelog.d/2024.md b/changelog.d/2024.md
new file mode 100644
index 000000000..1da546002
--- /dev/null
+++ b/changelog.d/2024.md
@@ -0,0 +1,5 @@
+### Fixed
+- An advisor warning that waited for the next turn, or that you put off with Not now, no longer shows once its cause has
+ passed (#2024): each turn it is checked again and, if it no longer applies, it goes to the Counsel history as
+ missed. Critical warnings are never dropped this way, a warning already on screen stays until you close it, and the
+ unsubmitted-budget warning stays while the budget edit is still unsubmitted.
diff --git a/unity/Assets/Scripts/UI/AdvisorPresenter.cs b/unity/Assets/Scripts/UI/AdvisorPresenter.cs
index b2c2bf0bf..3d5942c91 100644
--- a/unity/Assets/Scripts/UI/AdvisorPresenter.cs
+++ b/unity/Assets/Scripts/UI/AdvisorPresenter.cs
@@ -91,6 +91,8 @@ namespace Statecraft.Game.UI
int escapedAt = -1;
/// <summary>The message a layer covered, to show again or drop when the layer closes (spec 4.2).</summary>
AdvisorCatalog.Message? covered;
+ /// <summary>The Budget screen's last word on its edit (BudgetUnsubmitted): true while an edit is not submitted.</summary>
+ bool budgetUnsubmitted;
public AdvisorPresenter(VisualElement root, SimBridge bridge, UiText text, AdvisorSession session,
PortraitCatalog? portraits = null, AdvisorHooks? hooks = null)
@@ -219,6 +221,7 @@ namespace Statecraft.Game.UI
/// fires budget_unsubmitted; Submit takes it back.</summary>
public void BudgetUnsubmitted(bool on)
{
+ budgetUnsubmitted = on;
if (on) { Notice(AdvisorSignals.BudgetUnsubmitted); return; }
if (disposed) return;
session.Fired.Remove(AdvisorSignals.BudgetUnsubmitted);
@@ -243,7 +246,12 @@ namespace Statecraft.Game.UI
if (session.AutoShow)
{
var ctx = Context();
- session.Queue.Offer(AdvisorSignals.Holding(ctx, session), w => AdvisorSignals.When(ctx, w), Turn);
+ var holding = AdvisorSignals.Holding(ctx, session);
+ session.Queue.Offer(holding, w => AdvisorSignals.When(ctx, w), Turn);
+ // Owner, 1 Nov: budget_unsubmitted fires only when the edit changes, so for pruning its cause is read from
+ // the Budget screen's state; a put-off budget warning lasts while the edit is unsubmitted (Submit withdraws it).
+ if (budgetUnsubmitted) holding.Add(AdvisorSignals.BudgetUnsubmitted);
+ session.Queue.Prune(holding, w => AdvisorSignals.When(ctx, w), Turn, bridge.State.Date, Shown);
}
Render();
}
@@ -355,7 +363,9 @@ namespace Statecraft.Game.UI
{
covered = null;
var ctx = Context();
- if (!(AdvisorSignals.Holding(ctx, session).Contains(m.Signal) && AdvisorSignals.When(ctx, m.When)))
+ var holding = AdvisorSignals.Holding(ctx, session);
+ if (budgetUnsubmitted) holding.Add(AdvisorSignals.BudgetUnsubmitted); // as in Evaluate's Prune
+ if (!(holding.Contains(m.Signal) && AdvisorSignals.When(ctx, m.When)))
session.Queue.Drop(m, Turn, bridge.State.Date);
}
Render();
diff --git a/unity/Assets/Scripts/UI/AdvisorQueue.cs b/unity/Assets/Scripts/UI/AdvisorQueue.cs
index 65b0bfe77..d16831c96 100644
--- a/unity/Assets/Scripts/UI/AdvisorQueue.cs
+++ b/unity/Assets/Scripts/UI/AdvisorQueue.cs
@@ -49,6 +49,18 @@ namespace Statecraft.Game.UI
}
}
+ /// <summary>Each turn, a waiting or put-off warning whose signal or condition no longer holds goes to the history as
+ /// missed, not seen, so its signal can bring it back (owner, #2024). Critical messages are never pruned, and teaching
+ /// ones are not warnings. The one on screen (<paramref name="shown"/>) stays until the player closes it (owner, 1 Nov).</summary>
+ public void Prune(IReadOnlyCollection<string> holding, Func<IReadOnlyDictionary<string, double>, bool> when, int turn, DateTime date, AdvisorCatalog.Message? shown = null)
+ {
+ foreach (var w in waiting.Where(w => w.M != shown && !w.M.Critical && !w.M.Teaching && !(holding.Contains(w.M.Signal) && when(w.M.When))).ToList())
+ {
+ waiting.Remove(w);
+ history.Add(new Entry(w.M.Id, turn, date, Outcome.Missed));
+ }
+ }
+
bool Eligible(AdvisorCatalog.Message m, int turn) =>
Array.IndexOf(AdvisorCatalog.Levels, m.Level) >= settings.LevelRank
&& (m.Repeat == AdvisorCatalog.Once ? !settings.Seen(m.Id) : !(lastShown.TryGetValue(m.Id, out var t) && turn < t + m.CooldownTurns))
@@ -101,7 +113,7 @@ namespace Statecraft.Game.UI
/// not shown again now, and not marked seen, so its signal can bring it back later.</summary>
public void Drop(AdvisorCatalog.Message m, int turn, DateTime date)
{
- waiting.RemoveAll(w => w.M == m);
+ if (waiting.RemoveAll(w => w.M == m) == 0) return; // Withdraw (or Prune) already sent it to the history
history.Add(new Entry(m.Id, turn, date, Outcome.Missed));
}
diff --git a/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs b/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs
index 3217c9ed3..fb61d3246 100644
--- a/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs
+++ b/unity/Assets/Tests/EditMode/AdvisorPopupTests.cs
@@ -128,6 +128,24 @@ public class AdvisorPopupTests
rig.Session.Queue.History.Select(h => h.Outcome).ToArray());
}
+ /// <summary>Owner, 1 Nov 2026 (#2110): a warning on screen whose cause passes mid-turn stays until the player closes it;
+ /// only waiting or put-off warnings are pruned.</summary>
+ [Test]
+ public void AShownWarningWhoseCausePassesStaysUntilClosed()
+ {
+ using var rig = new Rig(catalog: Fixture.Replace("signal: turn_ended, level: warnings", "signal: in_debt, level: warnings"));
+ rig.Bridge.State.Debt = 1;
+ rig.Advisor.Resume(); // Evaluate, as bridge.Changed runs it
+ Assert.AreEqual("t.warn", rig.Advisor.Shown?.Id);
+ rig.Bridge.State.Debt = 0;
+ rig.Advisor.Resume();
+ Assert.AreEqual("t.warn", rig.Advisor.Shown?.Id, "the debt is paid, but the player is reading it");
+ Assert.IsTrue(rig.Advisor.IsOpen);
+ rig.Ui.Press("advisor-got-it");
+ Assert.IsNull(rig.Advisor.Shown);
+ Assert.AreEqual(("t.warn", AdvisorQueue.Outcome.Shown), (rig.Session.Queue.History.Last().Id, rig.Session.Queue.History.Last().Outcome));
+ }
+
static readonly string[] Layers =
{
StartScreenPresenter.OpenClass, EventCardPresenter.OpenClass, CaptureDialogPresenter.OpenClass,
diff --git a/unity/Assets/Tests/EditMode/AdvisorQueueTests.cs b/unity/Assets/Tests/EditMode/AdvisorQueueTests.cs
index 36981be1a..a10437a26 100644
--- a/unity/Assets/Tests/EditMode/AdvisorQueueTests.cs
+++ b/unity/Assets/Tests/EditMode/AdvisorQueueTests.cs
@@ -118,6 +118,52 @@ public class AdvisorQueueTests
Assert.AreEqual("p", q.Head(1, hebrew: false)!.Id, "the same queue in English: p fired first");
}
+ [Test]
+ public void ACappedWarningGoesToTheHistoryOnceItsSignalStopsHolding()
+ {
+ var q = new AdvisorQueue(Catalog(Row("w1", "warnings"), "{ id: w2, advisor: dayan, signal: d, level: warnings, priority: 1 }"), new AdvisorSettings(null));
+ q.Offer(new[] { "s", "d" }, Always, 1);
+ q.Done(q.Head(1, false)!, 1, Day);
+ Assert.IsNull(q.Head(1, false), "w2 waits: the warning slot is used");
+ q.Offer(Fired, Always, 2);
+ q.Prune(Fired, Always, 2, Day);
+ Assert.IsNull(q.Head(2, false), "d no longer holds, so w2 does not show");
+ Assert.AreEqual(("w2", AdvisorQueue.Outcome.Missed), (q.History.Last().Id, q.History.Last().Outcome));
+ }
+
+ [Test]
+ public void APutOffWarningGoesToTheHistoryOnceItsWhenStopsHolding()
+ {
+ var q = new AdvisorQueue(Catalog(Row("w", "warnings", 1, ", when: { debt_ratio_at_least: 0.8 }")), new AdvisorSettings(null));
+ q.Offer(Fired, Always, 1);
+ q.PutOff(q.Head(1, false)!, 1, Day);
+ q.Prune(Fired, _ => false, 2, Day);
+ Assert.IsNull(q.Head(2, false), "the debt fell under 0.8, so Not now does not bring it back");
+ Assert.IsEmpty(q.PutOffIds);
+ Assert.AreEqual(("w", AdvisorQueue.Outcome.Missed), (q.History.Last().Id, q.History.Last().Outcome));
+ }
+
+ [Test]
+ public void ACriticalMessageSurvivesADeadSignal()
+ {
+ var q = new AdvisorQueue(Catalog(Row("c", "critical")), new AdvisorSettings(null));
+ q.Offer(Fired, Always, 1);
+ q.Prune(Array.Empty<string>(), _ => false, 2, Day);
+ Assert.AreEqual("c", q.Head(2, false)!.Id, "a critical message is never pruned (owner, 31 Oct)");
+ Assert.IsEmpty(q.History);
+ }
+
+ [Test]
+ public void ACoveredWarningPrunedBeforeTheLayerClosesIsMissedOnce()
+ {
+ var q = new AdvisorQueue(Catalog(Row("w", "warnings")), new AdvisorSettings(null));
+ q.Offer(Fired, Always, 1);
+ var m = q.Head(1, false)!;
+ q.Prune(Array.Empty<string>(), Always, 1, Day);
+ q.Drop(m, 1, Day);
+ Assert.AreEqual(1, q.History.Count, "Counsel lists it once");
+ }
+
[Test]
public void ResetForgetsTheGameButNotTheSeenMarks()
{
diff --git a/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs
index f0a2d19fa..4a3cdb426 100644
--- a/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs
+++ b/unity/Assets/Tests/EditMode/AdvisorSignalsTests.cs
@@ -88,6 +88,49 @@ public class AdvisorSignalsTests
CollectionAssert.DoesNotContain(Drain(rig), "meyerson.budget_unsubmitted", "nor waiting");
}
+ /// <summary>Owner, 1 Nov 2026 (#2110): the budget warning's cause is the unsubmitted edit, not the turn its signal fired.
+ /// Put off with Not now, it survives the next turn while the edit is unsubmitted, and goes once it is submitted.</summary>
+ [Test]
+ public void APutOffBudgetWarningLastsWhileTheEditIsUnsubmitted()
+ {
+ const string id = "meyerson.budget_unsubmitted";
+ 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(id, rig.Advisor.Shown?.Id);
+ rig.Ui.Press("advisor-not-now");
+ rig.EndTurn();
+ Assert.IsTrue(rig.Bridge.BudgetUnsubmitted(budget.Draft), "the edit survives End turn");
+ CollectionAssert.Contains(rig.Session.Queue.PutOffIds, id, "still unsubmitted: Not now brings it back");
+ rig.Ui.Press("budget-submit");
+ CollectionAssert.DoesNotContain(rig.Session.Queue.PutOffIds, id, "submitted: gone");
+ Assert.AreEqual(AdvisorQueue.Outcome.Missed, rig.Session.Queue.History.Last(h => h.Id == id).Outcome);
+ }
+
+ /// <summary>Owner, 1 Nov 2026 (#2110): the cover path checks the same cause. Covered by a layer, the budget warning
+ /// survives End turn while the edit is unsubmitted, and comes back when the layer closes.</summary>
+ [Test]
+ public void ACoveredBudgetWarningLastsWhileTheEditIsUnsubmitted()
+ {
+ const string id = "meyerson.budget_unsubmitted";
+ 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(id, rig.Advisor.Shown?.Id);
+ rig.HudRoot.AddToClassList(TurnReportPresenter.OpenClass); ScreenNav.DisableCovered(rig.Ui.Root);
+ Assert.IsFalse(rig.Advisor.IsOpen, "covered");
+ rig.EndTurn();
+ Assert.IsTrue(rig.Bridge.BudgetUnsubmitted(budget.Draft), "the edit survives End turn");
+ rig.HudRoot.RemoveFromClassList(TurnReportPresenter.OpenClass); ScreenNav.DisableCovered(rig.Ui.Root);
+ Assert.AreEqual(id, rig.Advisor.Shown?.Id, "still unsubmitted: it comes back");
+ Assert.IsTrue(rig.Advisor.IsOpen);
+ Assert.IsFalse(rig.Session.Queue.History.Any(h => h.Id == id), "not sent to the history");
+ }
+
/// <summary>Review (should 4): a new help level applies to the popup at once, both ways.</summary>
[Test]
public void ANewHelpLevelAppliesAtOnce()