A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Toast: a save failure stays until a save succeeds; move and other sim refusals in Hebrew (Refs #2707) (#2909)
Berie7604867f4db
diff --git a/changelog.d/2707.md b/changelog.d/2707.mdnew file mode 100644index 000000000..ad1f0536d--- /dev/null+++ b/changelog.d/2707.md@@ -0,0 +1,8 @@+### Fixed++- "Your game could not be saved." now stays in the message under the top bar until a save works again. Before, the+ next order or message cleared it while saves could still be failing.+- In Hebrew, the move and go-to refusals ("That unit cannot move", "That hex is out of reach this turn" and the rest),+ the stack limit, the Attention shortfall on an instant order, "Buy at least 1 Arms", the reserve call-up's range,+ Send home with no armistice signed, and a housing repair off its city's hex now read in Hebrew. Before, they showed in+ English.diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.csindex 808f998a8..6be0d3baf 100644--- a/sim/Statecraft.Sim/AttentionSystem.cs+++ b/sim/Statecraft.Sim/AttentionSystem.cs@@ -46,13 +46,17 @@ namespace Statecraft.Simpublic static double Left(Content c, GameState s, IEnumerable<Command> pending){ RequireAttention(c); return s.Attention - pending.Sum(x => Price(c, s, x)); }+ /// <summary>The refusal for an order that costs more Attention than is left: the cost, then what is left (#2707: a+ /// constant, for the UI's string).</summary>+ public const string RefusedAttention = "Not enough attention (need {0:0.0}, have {1:0.0})";+/// <summary>Returns null and deducts on success, or the reason it could not be afforded./// <paramref name="rung"/> prices the command at that security level (the turn's starting rung).</summary>public static string? TrySpend(Content c, GameState s, string kind, int? rung = null){var cost = Cost(c, s, kind, rung);if (cost > s.Attention + 1e-9)- return string.Format(CultureInfo.InvariantCulture, "Not enough attention (need {0:0.0}, have {1:0.0})", cost, s.Attention);+ return string.Format(CultureInfo.InvariantCulture, RefusedAttention, cost, s.Attention);s.Attention -= cost;return null;}diff --git a/sim/Statecraft.Sim/Demobilization.cs b/sim/Statecraft.Sim/Demobilization.csindex 7ceac3f70..28a646789 100644--- a/sim/Statecraft.Sim/Demobilization.cs+++ b/sim/Statecraft.Sim/Demobilization.cs@@ -38,6 +38,9 @@ namespace Statecraft.Simreturn candidates.OrderBy(e => e.Distance).ThenBy(e => e.Unit).First().Front;}+ /// <summary>Send home's refusal while no armistice is signed (#2707: a constant, for the UI's string).</summary>+ public const string RefusedNoArmistice = "No armistice is signed";+/// <summary>R-UNIT-005's refusals: null when <see cref="Give"/> takes the order, else the reason shown to the player./// Changes nothing: the unit card asks it before it offers Send home. Refused for an unknown unit, a unit with no/// side (a halutz) or an enemy unit, as the standing orders are; then while the armistice on the unit's front is@@ -51,7 +54,7 @@ namespace Statecraft.Simvar front = Front(s, u, attacked);if (front != null)return Signed(s, front) ? null : $"The armistice with {PlayerText.Capitalised(front)} is not signed";- return Prisoners.Fronts.Any(f => Signed(s, f)) ? null : "No armistice is signed";+ return Prisoners.Fronts.Any(f => Signed(s, f)) ? null : RefusedNoArmistice;}/// <summary>R-UNIT-005: sends the unit home at once, like CancelTraining returns a cohort (R-TRAIN-002): the unitdiff --git a/sim/Statecraft.Sim/Movement.cs b/sim/Statecraft.Sim/Movement.csindex 4a2f1dea1..96a17943c 100644--- a/sim/Statecraft.Sim/Movement.cs+++ b/sim/Statecraft.Sim/Movement.cs@@ -19,6 +19,15 @@ namespace Statecraft.Sim/// is the player's.</summary>public const string PlayerSide = "israel";+ /// <summary>The go-to's and the move's refusals (R-MOVE-005/006/008), as constants so the UI can say them in its+ /// language (#2707). RefusedFull takes the count the hex already holds.</summary>+ public const string RefusedNoHex = "A route names a hex", RefusedCannotMove = "That unit cannot move",+ RefusedAlreadyThere = "That unit is already there", RefusedOffLand = "Units cannot enter water or leave the map",+ RefusedEnemyHex = "An enemy unit holds that hex",+ RefusedClosed = "Units may not enter an enemy-held locality before its capture is possible",+ RefusedNoRoute = "No route reaches that hex", RefusedOutOfReach = "That hex is out of reach this turn",+ RefusedFull = "That hex already holds {0} units of that side, the most one hex can hold";+static readonly IReadOnlyDictionary<int, int> NothingSpent = new Dictionary<int, int>();/// <summary>The six axial directions in tools/hexgrid.py's NEIGHBOURS order, the fixed order of hexes.json's layout@@ -155,15 +164,15 @@ namespace Statecraft.Sim/// ends on that day (<see cref="ContinueRoutes"/>). The player's own go-to replaces a card's.</summary>internal static string? GiveGoTo(Content c, GameState s, int unitId, int? q, int? r, Dictionary<int, int> spent, List<Cause> why, DateTime? cardUntil = null){- if (q == null || r == null) return "A route names a hex";+ if (q == null || r == null) return RefusedNoHex;if (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";if (IsEnemy(u)) return "That unit is not yours";- if (Points(c, u) == 0) return "That unit cannot move";- if (u.Q == q && u.R == r) return "That unit is already there";- if (!(c.HexAt(q.Value, r.Value) is MapHex hex) || !hex.Land) return "Units cannot enter water or leave the map";- if (s.Units.Values.Any(x => x.Q == q && x.R == r && IsEnemy(x))) return "An enemy unit holds that hex";- if (Closed(c, s, false).Contains((q.Value, r.Value))) return "Units may not enter an enemy-held locality before its capture is possible";- if (Route(c, s, unitId, q.Value, r.Value, spent, cardUntil != null).Count == 0) return "No route reaches that hex";+ if (Points(c, u) == 0) return RefusedCannotMove;+ if (u.Q == q && u.R == r) return RefusedAlreadyThere;+ if (!(c.HexAt(q.Value, r.Value) is MapHex hex) || !hex.Land) return RefusedOffLand;+ if (s.Units.Values.Any(x => x.Q == q && x.R == r && IsEnemy(x))) return RefusedEnemyHex;+ if (Closed(c, s, false).Contains((q.Value, r.Value))) return RefusedClosed;+ if (Route(c, s, unitId, q.Value, r.Value, spent, cardUntil != null).Count == 0) return RefusedNoRoute;var target = HexText(q.Value, r.Value);var given = new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, GoTo, target, u.HomeCity, u.Full, u.CombatXp);s.Units[unitId] = given;@@ -253,15 +262,15 @@ namespace Statecraft.Simif (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";if (IsEnemy(u) != enemy) return "That unit is not yours";var points = Points(c, u);- if (points == 0) return "That unit cannot move";- if (u.Q == q && u.R == r) return "That unit is already there";- if (!(c.HexAt(q, r) is MapHex hex) || !hex.Land) return "Units cannot enter water or leave the map";- if (s.Units.Values.Any(x => x.Q == q && x.R == r && IsEnemy(x) != enemy)) return "An enemy unit holds that hex";- if (Closed(c, s, enemy).Contains((q, r))) return "Units may not enter an enemy-held locality before its capture is possible";+ if (points == 0) return RefusedCannotMove;+ if (u.Q == q && u.R == r) return RefusedAlreadyThere;+ if (!(c.HexAt(q, r) is MapHex hex) || !hex.Land) return RefusedOffLand;+ if (s.Units.Values.Any(x => x.Q == q && x.R == r && IsEnemy(x) != enemy)) return RefusedEnemyHex;+ if (Closed(c, s, enemy).Contains((q, r))) return RefusedClosed;if (Full(c, s, u, q, r) is string full) return full;spent.TryGetValue(unitId, out var used);var (dist, _) = Search(c, s, u, points - used, fresh: used == 0, card: card);- if (!dist.TryGetValue((q, r), out var cost)) return "That hex is out of reach this turn";+ if (!dist.TryGetValue((q, r), out var cost)) return RefusedOutOfReach;// Moving clears fortify at once (Q-HOLD-1, "lost on move"; the standing orders' "fortify", or "fortifying" the turn it// is given, with the hex it names), so a unit that goes out and comes back the same turn is not fortified; hold moves with// the unit. The order step at the end of the turn only sees the final hex.@@ -286,7 +295,7 @@ namespace Statecraft.Sim{var limit = StackLimit(c, s); // the loader requires it in the GDD loopvar held = s.Units.Values.Count(x => x.Id != u.Id && x.Side == u.Side && x.Q == q && x.R == r);- return held >= limit ? FormattableString.Invariant($"That hex already holds {held} units of that side, the most one hex can hold") : null;+ return held >= limit ? string.Format(CultureInfo.InvariantCulture, RefusedFull, held) : null;}/// <summary>R-MOVE-005: the hexes of mvp.enemy_held_localities. For the enemy (R-ENEMY-001, the rule's mirror) everydiff --git a/sim/Statecraft.Sim/Pools.cs b/sim/Statecraft.Sim/Pools.csindex 186431c21..76f3547b1 100644--- a/sim/Statecraft.Sim/Pools.cs+++ b/sim/Statecraft.Sim/Pools.cs@@ -39,6 +39,9 @@ namespace Statecraft.Sim/// <summary>R-ARMS-002's refusal at the debt ceiling (#2198); SimBridge.ReasonKeys gives it the UI's words.</summary>public const string RefusedDebtCeiling = "Buying that many Arms would take the debt past its ceiling";+ /// <summary>R-ARMS-002's refusal for fewer than one Arms (#2707: a constant, for the UI's string).</summary>+ public const string RefusedCount = "Buy at least 1 Arms";+/// <summary>R-ARMS-002's refusal when a purchase would overflow the Arms stock.</summary>public const string RefusedStockCapacity = "That is more Arms than the stock can hold";@@ -51,7 +54,7 @@ namespace Statecraft.Simpublic static string? BuyArms(Content c, GameState s, int count, List<Cause> why){PopulationLedger.RefuseAggregate(s);- if (count < 1) return "Buy at least 1 Arms";+ if (count < 1) return RefusedCount;if ((long)s.Arms + count > int.MaxValue) return RefusedStockCapacity;if (BorrowsPastDebtCeiling(c, s, count)) return RefusedDebtCeiling;var cost = count * c.RulesAt(s.Date).Mvp!.ArmsPrice!.Value;diff --git a/sim/Statecraft.Sim/SecuritySystem.cs b/sim/Statecraft.Sim/SecuritySystem.csindex 2e2d9ce4a..1f832e35d 100644--- a/sim/Statecraft.Sim/SecuritySystem.cs+++ b/sim/Statecraft.Sim/SecuritySystem.cs@@ -52,10 +52,13 @@ namespace Statecraft.Simif (c.IsGdd) SendHomeToFloor(c, s, why);}+ /// <summary>SetMobilization's refusal for a level outside 0..1 (#2707: a constant, for the UI's string).</summary>+ public const string RefusedMobilization = "Mobilization must be between 0 and 1";+/// <summary>Returns null on success, or the reason the order was rejected.</summary>public static string? SetMobilization(Content c, GameState s, double level, List<Cause> why){- if (!(level >= 0 && level <= 1)) return "Mobilization must be between 0 and 1";+ if (!(level >= 0 && level <= 1)) return RefusedMobilization;s.Mobilization = level;why.Add(new Cause("security", "mobilization", level, $"reserve call-up set to {PlayerText.Percent(level)}", key: CauseKeys.CallUpSet));RaiseToFloor(c, s, why);diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex c8f9219b5..2f80a7414 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -332,9 +332,10 @@ namespace Statecraft.Game.UI{if (result.StartsWith("fail save ", StringComparison.Ordinal)){- toast.Append(text["save.write_failed"]);+ toast.SaveFailed(text["save.write_failed"]);Debug.Log("SAVE FAILURE SHOWN save.write_failed");}+ else if (result.StartsWith("ok save ", StringComparison.Ordinal)) toast.SaveSucceeded(); // #2707: the failure stays until then};unseenSkipped = () => toast.Show(text["toast.unit_unseen_skipped"]);var hudPresenter = Own(new HudPresenter(root, bridge, text, selectUnit: _ => FocusNextUnit()));@@ -519,7 +520,7 @@ namespace Statecraft.Game.UI{newGame = Own(new NewGamePresenter(root, bridge, store, toast, text, GameStart.NewSeed, gameObject.name));this.newGame = newGame;- Own(GameStart.Autosave(bridge, store, text, toast.Append, gameObject.name)); // appends: the turn's refusals stay visible+ Own(GameStart.Autosave(bridge, store, text, toast.SaveFailed, gameObject.name, toast.SaveSucceeded)); // under the turn's refusals, until a save succeeds (#2707)}// Once the game is over, the sim's end report (#812); after the autosave, so the last turn is saved first. New Game// is its two presses; a smoke run has none.diff --git a/unity/Assets/Scripts/UI/GameStart.cs b/unity/Assets/Scripts/UI/GameStart.csindex e3be15e39..a4b95b120 100644--- a/unity/Assets/Scripts/UI/GameStart.cs+++ b/unity/Assets/Scripts/UI/GameStart.cs@@ -79,9 +79,9 @@ namespace Statecraft.Game.UI/// <summary>Writes <paramref name="session"/> through the complete autosave path. A failure never stops play: the/// reason goes to <paramref name="onError"/> and false is returned. On WebGL <paramref name="persistenceTarget"/>- /// receives the asynchronous IndexedDB result.</summary>+ /// receives the asynchronous IndexedDB result; elsewhere the write is the save, and <paramref name="onSaved"/> is told.</summary>internal static bool WriteAutosave(GameSession session, SaveStore store, UiText text, Action<string>? onError = null,- string? persistenceTarget = null)+ string? persistenceTarget = null, Action? onSaved = null){try{@@ -95,6 +95,7 @@ namespace Statecraft.Game.UIStatecraftPersistAutosave("save " + receipt, persistenceTarget ?? "");#elseUnityEngine.Debug.Log("AUTOSAVE OK " + receipt);+ onSaved?.Invoke();#endifreturn true;}@@ -108,9 +109,9 @@ namespace Statecraft.Game.UI/// <summary>Writes the save after every committed order and every turn. Dispose the result to stop autosaving.</summary>public static IDisposable Autosave(SimBridge bridge, SaveStore store, UiText text, Action<string>? onError = null,- string? persistenceTarget = null)+ string? persistenceTarget = null, Action? onSaved = null){- void Save(IReadOnlyList<Rejection> _) => WriteAutosave(bridge.Session, store, text, onError, persistenceTarget);+ void Save(IReadOnlyList<Rejection> _) => WriteAutosave(bridge.Session, store, text, onError, persistenceTarget, onSaved);Action<IReadOnlyList<Cause>> onCommit = _ => Save(Array.Empty<Rejection>());bridge.Committed += onCommit;bridge.TurnEnded += Save;diff --git a/unity/Assets/Scripts/UI/NewGamePresenter.cs b/unity/Assets/Scripts/UI/NewGamePresenter.csindex 4109fb885..3a445b208 100644--- a/unity/Assets/Scripts/UI/NewGamePresenter.cs+++ b/unity/Assets/Scripts/UI/NewGamePresenter.cs@@ -53,7 +53,7 @@ namespace Statecraft.Game.UIArmed = false;var fresh = GameSession.New(bridge.Content, seed(), Mode.Historical);bridge.Replace(fresh);- if (GameStart.WriteAutosave(fresh, store, text, toast.Show, persistenceTarget)) toast.Clear();+ if (GameStart.WriteAutosave(fresh, store, text, toast.SaveFailed, persistenceTarget, toast.SaveSucceeded)) toast.Clear();Started?.Invoke();}}diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex 7fbd66e72..3f0875b63 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -276,6 +276,18 @@ namespace Statecraft.Game.UI[Pools.RefusedStockCapacity] = "arms.refused_stock_capacity",[Orders.RefusedCardOrder] = "unit.order_refused.card_order", // R-ENEMY-005: an operation card's refused go-to[Orders.RefusedLastGarrison] = "unit.order_refused.last_garrison", // R-CTRL-013: a card's go-to held back+ // #2707: the move's and the go-to's refusals, Arms bought below one, the call-up's range and Send home's.+ [Movement.RefusedNoHex] = "unit.move_refused.no_hex",+ [Movement.RefusedCannotMove] = "unit.move_refused.cannot_move",+ [Movement.RefusedAlreadyThere] = "unit.move_refused.already_there",+ [Movement.RefusedOffLand] = "unit.move_refused.off_land",+ [Movement.RefusedEnemyHex] = "unit.move_refused.enemy_hex",+ [Movement.RefusedClosed] = "unit.move_refused.closed",+ [Movement.RefusedNoRoute] = "unit.move_refused.no_route",+ [Movement.RefusedOutOfReach] = "unit.move_refused.out_of_reach",+ [Pools.RefusedCount] = "arms.refused_count",+ [SecuritySystem.RefusedMobilization] = "defence.refused_mobilization",+ [Demobilization.RefusedNoArmistice] = "unit.send_home_refused.no_armistice",};/// <summary>The sim's refusals that carry values (#2072: Combat.Check's Arms, Training.Reinforce's unit, settlement,@@ -304,7 +316,11 @@ namespace Statecraft.Game.UI(Projects.RefusedBeingBuilt, "builder.refused_being_built"),// R-PROJ-001 under gdd-0.3 (#1700 slice B): a second city project start in one city in one turn.(Projects.RefusedCityCap, "city.project_reason.city_cap"),- }.Select(x => (new Regex("^" + string.Join("(.+?)", Regex.Split(x.format, @"\{\d+\}").Select(Regex.Escape)) + "$"), x.key)).ToArray();+ // #2707: a hex at the stack limit, an instant order short of Attention (the queue's own line), a housing repair off its city.+ (Movement.RefusedFull, "unit.move_refused.full"),+ (AttentionSystem.RefusedAttention, "order.no_attention"),+ (Projects.RefusedRepairCityHex, "city.project_reason.repair_city_hex"),+ }.Select(x => (new Regex("^" + string.Join("(.+?)", Regex.Split(x.format, @"\{\d+(?::[^}]*)?\}").Select(Regex.Escape)) + "$"), x.key)).ToArray();/// <summary>A sim refusal in the UI's language where it has a string (<see cref="ReasonKeys"/>, <see cref="ReasonFormats"/>),/// else the sim's English as given. The queue's refusals, the unit card's (InfoPanelPresenter) and the end of turn'sdiff --git a/unity/Assets/Scripts/UI/ToastPresenter.cs b/unity/Assets/Scripts/UI/ToastPresenter.csindex 312a35c3d..dbe27f994 100644--- a/unity/Assets/Scripts/UI/ToastPresenter.cs+++ b/unity/Assets/Scripts/UI/ToastPresenter.cs@@ -9,13 +9,16 @@ using UnityEngine.UIElements;namespace Statecraft.Game.UI{/// <summary>A short message under the top bar: why orders were refused (spec section 7: the UI shows the stated- /// reason), or a note such as a save warning. Hidden when there is nothing to say; cleared by the next order.</summary>+ /// reason), or a note such as a save warning. Hidden when there is nothing to say; cleared by the next order, except a+ /// failed save, which stays under the other lines until a save succeeds (#2707).</summary>public sealed class ToastPresenter : System.IDisposable{readonly Label label; readonly UiText text; readonly SimBridge bridge;readonly Action<IReadOnlyList<Rejection>> onTurnEnded, onRouteStep;readonly Action<IReadOnlyList<Cause>> onCommitted;IReadOnlyList<UnitEntry> units = Array.Empty<UnitEntry>();+ string shown = ""; // the lines Show and Append set; Clear and the next order replace them+ string? saveFailure; // SaveFailed's line, kept until SaveSucceeded/// <summary>The units_1948.yaml rows that name starting forces in the committed orders' Why lines (GameRoot sets/// them once the map has read them, as for WhyPresenter); without them a starting force is named by its type.</summary>@@ -46,20 +49,32 @@ namespace Statecraft.Game.UIpublic void Dispose() { bridge.TurnEnded -= onTurnEnded; bridge.TurnEnded -= onRouteStep; bridge.Refused -= Refuse; bridge.Changed -= Clear; bridge.Committed -= onCommitted; }- /// <summary>Shows the lines as they are (none = hide).</summary>+ /// <summary>Shows the lines as they are, a failed save's line under them (none of either = hide).</summary>public void Show(IEnumerable<string> lines){- var list = lines.ToList();- label.text = string.Join("\n", list);- label.style.display = list.Count > 0 ? DisplayStyle.Flex : DisplayStyle.None;+ shown = string.Join("\n", lines);+ var all = new[] { shown, saveFailure ?? "" }.Where(x => x.Length > 0).ToList();+ label.text = string.Join("\n", all);+ label.style.display = all.Count > 0 ? DisplayStyle.Flex : DisplayStyle.None;}public void Show(string line) => Show(new[] { line });- /// <summary>Adds a line under what is shown (alone when nothing is), e.g. a failed autosave after the turn's+ /// <summary>Adds a line under what is shown (alone when nothing is), e.g. a unit's route step after the turn's/// refusals.</summary>- public void Append(string line) =>- Show(label.style.display.value == DisplayStyle.Flex && label.text.Length > 0 ? label.text + "\n" + line : line);+ public void Append(string line) => Show(shown.Length > 0 ? shown + "\n" + line : line);++ /// <summary>A save failed: its line stays under whatever else is shown, through the next order, until+ /// <see cref="SaveSucceeded"/> (autosave and New Game, and on WebGL the IndexedDB result).</summary>+ public void SaveFailed(string line) { saveFailure = line; Show(shown); }++ /// <summary>A save succeeded: a failed save's line goes; the other lines stay.</summary>+ public void SaveSucceeded()+ {+ if (saveFailure == null) return;+ saveFailure = null;+ Show(shown);+ }/// <summary>Shows why an order was refused ("Not done: ...").</summary>public void Refuse(string reason) => Show(text.Format("toast.refused", reason));diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex 069daca59..9b151d155 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -740,6 +740,40 @@ public class GameSceneTestsAssert.AreEqual(DisplayStyle.Flex, Ui.Q("toast").style.display.value);}+ // #2707 item 1: a failed autosave stays in the toast through the next order (a deferred order raises Changed, which+ // clears routine lines) and goes with the next save that succeeds.+ [Test]+ public void ASaveFailureStaysThroughTheNextOrderUntilASaveSucceeds()+ {+ File.WriteAllText(saveDir, "a file where the save folder should be");+ var root = Boot(new SaveStore(saveDir));+ var toast = Ui.Q<Label>("toast");+ LogAssert.Expect(LogType.Warning, new System.Text.RegularExpressions.Regex("^Autosave could not be written"));+ root.Bridge!.EndTurn();+ Assert.AreEqual(Text["save.write_failed"], toast.text);+ Assert.IsNull(root.Bridge.Queue(new SecurityOrder(-1)), "a deferred order");+ Assert.AreEqual(Text["save.write_failed"], toast.text, "the next order leaves the save failure");+ Assert.AreEqual(DisplayStyle.Flex, toast.style.display.value);+ File.Delete(saveDir); // the save folder can be written again+ root.Bridge.EndTurn();+ Assert.IsTrue(File.Exists(Path.Combine(saveDir, SaveStore.AutosaveName)), "the turn was autosaved");+ StringAssert.DoesNotContain(Text["save.write_failed"], toast.text, "a successful save takes the failure away");+ }++ // #2707 item 1 on WebGL: the IndexedDB result decides; a failure stays through the next order, an "ok" takes it away.+ [Test]+ public void AWebSaveFailureStaysUntilAWebSaveSucceeds()+ {+ var root = Boot();+ var toast = Ui.Q<Label>("toast");+ root.OnSavePersistenceResult("fail save 1 1948-06-15 turn 1 hash aa");+ Assert.IsNull(root.Bridge!.Queue(new SecurityOrder(-1)), "a deferred order");+ Assert.AreEqual(Text["save.write_failed"], toast.text, "the next order leaves the save failure");+ root.OnSavePersistenceResult("ok save 2 1948-06-15 turn 1 hash aa");+ Assert.AreEqual("", toast.text);+ Assert.AreEqual(DisplayStyle.None, toast.style.display.value);+ }+[TestCase(false)][TestCase(true)]public void WebSavePersistenceFailuresUseTheCurrentLanguagesExistingToast(bool hebrew)diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex f9818a685..788448cd7 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -200,6 +200,31 @@ public class HebrewUiTests}}+ // #2707 catch-all: every Refused* constant anywhere in the sim reaches the toast (ReasonText) in Hebrew under Hebrew, and+ // as the sim's own English under English. A format is filled with distinct numbers, so its pattern must take any value;+ // the values themselves are the per-check tests' (above, CityProjectPanelTests). A refusal still a bare literal in the+ // sim is not seen here: naming it a Refused* constant is how it joins this check.+ [Test]+ public void EveryNamedSimRefusalHasAHebrewString()+ {+ var c = Statecraft.Sim.ContentLoader.Load(Paths.Content);+ var refusals = typeof(Statecraft.Sim.Orders).Assembly.GetTypes()+ .SelectMany(t => t.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static))+ .Where(f => f.IsLiteral && f.FieldType == typeof(string) && f.Name.StartsWith("Refused"))+ .Select(f => (name: f.DeclaringType!.Name + "." + f.Name, format: (string)f.GetRawConstantValue())).ToList();+ Assert.That(refusals.Count, Is.GreaterThan(40));+ var missing = new List<string>();+ foreach (var (name, format) in refusals)+ {+ var slots = Regex.Matches(format, @"\{(\d+)").Cast<Match>().Select(m => int.Parse(m.Groups[1].Value) + 1).DefaultIfEmpty(0).Max();+ var reason = string.Format(System.Globalization.CultureInfo.InvariantCulture, format,+ Enumerable.Range(0, slots).Select(i => (object)(i + 2)).ToArray());+ Assert.AreEqual(reason, SimBridge.ReasonText(En, reason), name + ": the English string is the sim's own");+ if (!Regex.IsMatch(SimBridge.ReasonText(He, reason, c), "[א-ת]")) missing.Add(name + " \"" + reason + "\"");+ }+ Assert.IsEmpty(missing, "no Hebrew string for:\n" + string.Join("\n", missing));+ }+[Test]public void TheGameIsEnglishUnlessHebrewIsAskedFor(){diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex e3a724871..0dc4373c2 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -1073,6 +1073,8 @@ arms.no_attention: "Not enough Attention for this purchase. Withdraw another ord# end-of-turn toast.arms.refused_debt_ceiling: "Buying that many Arms would take the debt past its ceiling"arms.refused_stock_capacity: "That is more Arms than the stock can hold"+# #2707: Pools.BuyArms's refusal below one Arms, word for word.+arms.refused_count: "Buy at least 1 Arms"# #731 stock summaries in the report and Why.report.stock_line: "{0}: {1}"@@ -1091,6 +1093,21 @@ unit.order_refused.card_order: "The unit could not take the operation's order"# 2 November 2026, #2087: "Keep a garrison in Nazareth (Recommended)").unit.order_refused.last_garrison: "The unit stays: it is the last Israeli unit holding an occupied place"+# #2707: the move's and the go-to's refusals (Movement), Send home's with no armistice (Demobilization) and the reserve+# call-up's range (SecuritySystem), shown in the toast. Each English line is the sim's own text; {0} is the number of+# units the hex already holds.+unit.move_refused.no_hex: "A route names a hex"+unit.move_refused.cannot_move: "That unit cannot move"+unit.move_refused.already_there: "That unit is already there"+unit.move_refused.off_land: "Units cannot enter water or leave the map"+unit.move_refused.enemy_hex: "An enemy unit holds that hex"+unit.move_refused.closed: "Units may not enter an enemy-held locality before its capture is possible"+unit.move_refused.no_route: "No route reaches that hex"+unit.move_refused.out_of_reach: "That hex is out of reach this turn"+unit.move_refused.full: "That hex already holds {0} units of that side, the most one hex can hold"+unit.send_home_refused.no_armistice: "No armistice is signed"+defence.refused_mobilization: "Mobilization must be between 0 and 1"+# #2072 Attack and Reinforce refusals (Combat.Check, Training.Reinforce), shown on the unit card and in the toast. Each# English line is the sim's own text; {0}, {1}... are the values it fills in.unit.attack_refused.no_hex: "An attack names a hex"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex c335a5cb3..a8f1e7462 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -1302,6 +1302,8 @@ arms.no_attention: "אין די תשומת לב לרכישה. יש לבטל הוarms.refused_debt_ceiling: "רכישת כמות כזאת של נשק תעלה את החוב מעל התקרה"# Agent-drafted Hebrew; for the native read in #564.arms.refused_stock_capacity: "כמות זו של נשק גדולה מכפי שהמלאי יכול להכיל"+# #2707. Agent-drafted Hebrew; for the native read in #564.+arms.refused_count: "יש לרכוש לפחות יחידת נשק אחת"# #731 stock summaries in the report and Why. Native review: owner, 3 Nov 2026 (HE batch 1: "All fine as they are").report.stock_line: "{0} במלאי: {1}"@@ -1326,6 +1328,20 @@ unit.order_refused.card_order: "לא ניתן היה לבצע את פקודת ה# Agent-drafted Hebrew; native review pending (#564).unit.order_refused.last_garrison: "היחידה נשארת במקום: היא היחידה הישראלית האחרונה המחזיקה בו"+# #2707: the move's and the go-to's refusals (Movement), Send home's with no armistice (Demobilization) and the reserve+# call-up's range (SecuritySystem), shown in the toast. {0} is a number. Agent-drafted Hebrew; for the native read in #564.+unit.move_refused.no_hex: "יש לבחור משבצת יעד"+unit.move_refused.cannot_move: "היחידה אינה יכולה לנוע"+unit.move_refused.already_there: "היחידה כבר נמצאת שם"+unit.move_refused.off_land: "יחידות אינן יכולות להיכנס למים או לצאת מהמפה"+unit.move_refused.enemy_hex: "יחידת אויב מחזיקה במשבצת הזאת"+unit.move_refused.closed: "אי אפשר להיכנס ליישוב שבידי האויב לפני שאפשר לכבוש אותו"+unit.move_refused.no_route: "אין דרך שמגיעה למשבצת הזאת"+unit.move_refused.out_of_reach: "היחידה לא תגיע למשבצת הזאת בתור הזה"+unit.move_refused.full: "במשבצת כבר יש {0} יחידות של הצד הזה, המספר המרבי במשבצת אחת"+unit.send_home_refused.no_armistice: "עדיין לא נחתם הסכם שביתת נשק"+defence.refused_mobilization: "שיעור גיוס המילואים חייב להיות בין 0 ל־1"+# #2072 Attack and Reinforce refusals (Combat.Check, Training.Reinforce), shown on the unit card and in the toast. A# settlement in {0}/{1} opens the line as its label or follows a prefix, so no verb agrees with its gender (HE-15).# Approved by Beri, a native speaker, on #2072 (31 Oct 2026), all 20 lines as written. For the native reviewer (#564).