A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
ui: an unreadable autosave shows only a short localised reason (refs #631) (#636)
Eyal Golane6f989625de6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8425f9220..4dd7d4256 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -514,6 +514,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBIt decodes to the same bytes, so the terrain is unchanged (#44).### Fixed+- An autosave that cannot be continued (refs #631, #622) no longer shows the sim's English reason or a replay's exception+ message to the player: the note always gives the short reason "the file could not be read or replayed", in English and+ Hebrew, and the full exception goes to the log. A replay that throws keeps that exception, with its stack, as the+ SaveException's inner exception. No save format change.- UI text from Jeremy Hoover's review (refs #622): a refused order no longer shows a content id or an exception'smessage after "Not done:" ("Unknown policy", "The turn could not run", in English and Hebrew); both stay in the log.The six Title Case labels are in sentence case ("Public support", "International standing", "Foreign currency", "Enddiff --git a/README.md b/README.mdindex 43c169825..5634ac7dc 100644--- a/README.md+++ b/README.md@@ -41,7 +41,7 @@ The game design of record is now [docs/GDD.md](docs/GDD.md) (12 October 2026): m## What it looks like today<p align="center">- <img src="docs/images/build-gameplay.webp" alt="Real gameplay, 22 to 29 May 1948: a pan across Tel Aviv, Jaffa and the coastal plain, a click on a hex that opens its panel, the One Army decision, and End Turn moving the date to 29 May" width="820">+ <img src="docs/images/build-gameplay.webp" alt="Real gameplay, 22 to 29 May 1948: a pan across Tel Aviv, Jaffa and the coastal plain, a click on a hex that opens its panel, the One Army decision, and End turn moving the date to 29 May" width="820"><br><em>Real gameplay, build 0.1.0, 2026-10-13, commit f93fd5e.</em></p><p align="center">@@ -171,7 +171,7 @@ You need Unity **6000.3.25f1 (6.3 LTS)** with Web Build Support; the exact versiThis project is built with heavy AI assistance, disclosed here using itch.io's categories:- **Code:** written with AI coding agents and reviewed through tests and review gates.-- **Graphics:** the concept and promo images in `promo/` are AI-generated, as is the start screen's painting, and the web page's tab icon was drawn with AI help. The game's terrain comes from real elevation data. The portraits are public-domain, CC0 or CC BY 4.0 photographs (credited in NOTICE), and the event cards use archival photographs; on some cards an Illustration switch plays a short, silent AI-generated loop, and a few historical orders show a short AI-generated clip at End Turn, both labelled as such.+- **Graphics:** the concept and promo images in `promo/` are AI-generated, as is the start screen's painting, and the web page's tab icon was drawn with AI help. The game's terrain comes from real elevation data. The portraits are public-domain, CC0 or CC BY 4.0 photographs (credited in NOTICE), and the event cards use archival photographs; on some cards an Illustration switch plays a short, silent AI-generated loop, and a few historical orders show a short AI-generated clip at End turn, both labelled as such.- **Text:** event and content text was drafted with AI, and every fact is checked against the cited source.- **Sound:** no AI sound. The start screen can play the original 1948 recording of Ben-Gurion reading the Declaration (Israel State Archives).diff --git a/docs/event-videos.md b/docs/event-videos.mdindex 58237d017..83f7cc228 100644--- a/docs/event-videos.md+++ b/docs/event-videos.md@@ -22,7 +22,7 @@ moments.md`, the "Full plan"; plan: `docs/superpowers/plans/2026-10-13-decision-`docs/ai-disclosure.md` lists them.- **Silent.** The clips have no audio stream (`tools/encode_event_videos.py` refuses one).- **Opt-in.** A card's loop plays only after the player presses the switch, so it needs no separate pause button and no- reduced-motion setting. Pressing the switch again stops it. (The outcome clips below play at End Turn without a+ reduced-motion setting. Pressing the switch again stops it. (The outcome clips below play at End turn without aswitch, once, for 3.5 s: a click, Enter or Space skips one, and Esc skips them all.)- The choice holds for the session: later cards open on their clip until the player switches back.- It is not saved, and every launch starts on the photograph.@@ -36,7 +36,7 @@ moments.md`, the "Full plan"; plan: `docs/superpowers/plans/2026-10-13-decision-- **Rights:** owner ruling D-V (`docs/oss/DECISIONS.md`, merged in #449), "no need to check, just use them". Every clip has an`ASSETS.yaml` row with `ai_generated: true`, the generator and the date, and those rows feed `docs/ai-disclosure.md`.-## Outcome clips at End Turn (phase 3)+## Outcome clips at End turn (phase 3)When a turn runs, every event the player answered with its **historical** option, if the turn applied the order and theevent has an outcome clip, plays that clip once, in the middle of the screen, before the game goes on (`OutcomePresenter`).@@ -47,7 +47,7 @@ event has an outcome clip, plays that clip once, in the middle of the screen, be- **3.5 s, silent.** The caption is worded as the order, "Your order: …", because the clip illustrates the order anddoes not show its outcome.- A click, Enter or Space (or a gamepad's Submit) skips the clip. Esc (or Cancel) skips all of the turn's clips.- - A screen open at End Turn (Cabinet, Budget, Defence, Why) closes when the clip starts. The clip is drawn over+ - A screen open at End turn (Cabinet, Budget, Defence, Why) closes when the clip starts. The clip is drawn overeverything but the toast, and while it plays the decision card, the top bar and the panels wait, so no order can begiven under it.- It has its own player, separate from the card's loop.@@ -74,7 +74,7 @@ event has an outcome clip, plays that clip once, in the middle of the screen, be| The clips (960x540 H.264, about 0.4 to 1.5 MB each) | `unity/Assets/StreamingAssets/video/<event>.mp4`, and `<event>-outcome.mp4` for the outcome clips || The encode, pinned (no burned-in caption) | `tools/encode_event_videos.py` || The player: a lazy VideoPlayer playing a URL into a 960x540 RenderTexture; one for the card's loop and one for the outcome clips | `CardVideo` |-| The outcome clips at End Turn | `OutcomePresenter` |+| The outcome clips at End turn | `OutcomePresenter` || The switch | `EventCardPresenter.ApplyIllustration` |The mapping is **not game content**: the sim never reads it, and the goldens and the content hash cannot move for itdiff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.csindex 8da46f85c..1239a6854 100644--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs@@ -263,7 +263,7 @@ public class SaveGameTests}/// <summary>The replay runs under content whose step throws (a MapAction with no attention cost line): the exception- /// must surface as a SaveException that names the turn.</summary>+ /// must surface as a SaveException that names the turn and keeps the original exception for the log (#631).</summary>[Fact]public void AReplayThatThrowsIsASaveExceptionNamingTheTurn(){@@ -272,6 +272,9 @@ public class SaveGameTestsbroken.Rules.AttentionCost.Remove("map_action");var ex = Assert.Throws<SaveException>(() => GameSession.Load(broken, text, out _));Assert.StartsWith("turn 4: ", ex.Message);+ var inner = Assert.IsType<KeyNotFoundException>(ex.InnerException);+ Assert.Equal("turn 4: " + inner.Message, ex.Message);+ Assert.Equal(0, ex.Line);}[Theory]diff --git a/sim/Statecraft.Sim/GameSession.cs b/sim/Statecraft.Sim/GameSession.csindex d6d86bc49..076a2f945 100644--- a/sim/Statecraft.Sim/GameSession.cs+++ b/sim/Statecraft.Sim/GameSession.cs@@ -56,7 +56,7 @@ namespace Statecraft.Simint turnNo = 0;try { foreach (var turn in saved.Turns) { session.Step(turn); turnNo++; } }catch (SaveException) { throw; }- catch (Exception e) { throw new SaveException(0, $"turn {turnNo + 1}: {e.Message}"); }+ catch (Exception e) { throw new SaveException(FormattableString.Invariant($"turn {turnNo + 1}: {e.Message}"), e); }if (session.State.Hash() != saved.FinalHash){if (sameContent) throw new SaveException(0, "The replay does not match the saved game: the save is damaged or was edited, or the game has a bug.");diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.csindex c45fa32fe..df2527c05 100644--- a/sim/Statecraft.Sim/SaveGame.cs+++ b/sim/Statecraft.Sim/SaveGame.cs@@ -11,6 +11,8 @@ namespace Statecraft.Sim/// <summary>1-based line of the save text the error is on (0 when it concerns the whole save).</summary>public int Line { get; }public SaveException(int line, string message) : base(line > 0 ? FormattableString.Invariant($"line {line}: {message}") : message) { Line = line; }+ /// <summary>A save whose replay threw <paramref name="inner"/>: kept, with its stack, for the log (#631).</summary>+ public SaveException(string message, Exception inner) : base(message, inner) { }}/// <summary>diff --git a/unity/Assets/Scripts/UI/GameStart.cs b/unity/Assets/Scripts/UI/GameStart.csindex 4d6927919..38f29fa66 100644--- a/unity/Assets/Scripts/UI/GameStart.cs+++ b/unity/Assets/Scripts/UI/GameStart.cs@@ -38,11 +38,11 @@ namespace Statecraft.Game.UIcatch (Exception e) // any failure (a bad save, a replay that throws): never block the start{try { store.SetAsideAutosave(); } catch (Exception) { /* even this must not stop the start */ }- // A SaveException's message is about the save's own text (line numbers); anything else can carry file paths, so- // the player gets a short reason and the full exception goes to the log.- if (!(e is SaveException)) UnityEngine.Debug.LogWarning("Autosave could not be loaded: " + e);- else UnityEngine.Debug.LogWarning("Autosave rejected: " + e.Message);- notes.Add(text.Format("save.unreadable", e is SaveException ? e.Message : text["save.reason_other"]));+ // The sim's reasons are English and technical (line numbers, a replay's own exception), and anything else+ // can carry file paths: the player gets one short reason in their language, and the full exception (with+ // a replay's inner exception) goes to the log only (#631).+ UnityEngine.Debug.LogWarning((e is SaveException ? "Autosave rejected: " : "Autosave could not be loaded: ") + e);+ notes.Add(text.Format("save.unreadable", text["save.reason_other"]));}}return GameSession.New(c, newSeed(), Mode.Historical);diff --git a/unity/Assets/Tests/EditMode/SaveUiTests.cs b/unity/Assets/Tests/EditMode/SaveUiTests.csindex 355e86a06..7c96fbf99 100644--- a/unity/Assets/Tests/EditMode/SaveUiTests.cs+++ b/unity/Assets/Tests/EditMode/SaveUiTests.cs@@ -64,7 +64,7 @@ public class SaveUiTestsvar notes = new List<string>();var session = GameStart.Begin(C, store, () => 5UL, notes, Text);Assert.AreEqual(0, session.State.Turn);- StringAssert.StartsWith("Your saved game could not be loaded (line 1: save schema version 9 is newer", notes[0]);+ Assert.AreEqual(new[] { Unreadable(Text) }, notes.ToArray()); // the sim's English reason goes to the log only (#631)Assert.IsFalse(File.Exists(store.AutosavePath));Assert.IsTrue(File.Exists(Path.Combine(store.Directory, "autosave.bad.txt")));}@@ -78,7 +78,64 @@ public class SaveUiTestsvar notes = new List<string>();var session = GameStart.Begin(C, store, () => 6UL, notes, Text);Assert.AreEqual(0, session.State.Turn);- StringAssert.StartsWith("Your saved game could not be loaded (line 4: mode Open is not supported)", notes[0]);+ Assert.AreEqual(new[] { Unreadable(Text) }, notes.ToArray());+ Assert.IsTrue(File.Exists(Path.Combine(store.Directory, "autosave.bad.txt")));+ }++ /// <summary>The note the player reads for any autosave that cannot be continued: a short reason in their language.</summary>+ static string Unreadable(UiText text) => text.Format("save.unreadable", text["save.reason_other"]);++ /// <summary>#631: every way a save is refused (a damaged line, another ruleset, a replay that ends elsewhere, a replay that+ /// throws) shows the player the same short reason in English and in Hebrew, never the sim's English message; the full+ /// exception, with the replay's own exception inside it, goes to the log.</summary>+ [TestCase("strings.en.yaml", "damaged line")]+ [TestCase("strings.he.yaml", "damaged line")]+ [TestCase("strings.en.yaml", "other ruleset")]+ [TestCase("strings.he.yaml", "other ruleset")]+ [TestCase("strings.en.yaml", "replay differs")]+ [TestCase("strings.he.yaml", "replay differs")]+ [TestCase("strings.en.yaml", "replay throws")]+ [TestCase("strings.he.yaml", "replay throws")]+ public void AnUnreadableSaveShowsOnlyALocalisedReason(string file, string kind)+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Folder + "/" + file).text, file);+ var content = C;+ var played = GameSession.New(C, 9, Mode.Historical);+ played.Step(new Command[] { new SetMobilization(1.0) });+ var save = played.Save.Write();+ string logged;+ switch (kind)+ {+ case "damaged line":+ save = save.Replace("seed 9", "seed nine");+ logged = "line 3: bad seed";+ break;+ case "other ruleset":+ var other = C.Ruleset == SaveGame.LegacyRuleset ? SaveGame.GddRuleset : SaveGame.LegacyRuleset;+ save = save.Replace("ruleset " + C.Ruleset, "ruleset " + other);+ logged = "version of the game's rules";+ break;+ case "replay differs":+ save = save.Replace("seed 9", "seed 10"); // the same content, so a replay that ends elsewhere is refused+ logged = "The replay does not match the saved game";+ break;+ default:+ content = ContentLoader.Load(Paths.Content); // its own copy: removing a price must not touch C+ content.Rules.AttentionCost.Remove("set_mobilization");+ foreach (var r in content.EraRules.Values) r.AttentionCost.Remove("set_mobilization");+ logged = "turn 1: (.|\\n)*KeyNotFoundException";+ break;+ }+ var store = TempStore();+ store.WriteAutosave(save);+ var notes = new List<string>();+ LogAssert.Expect(LogType.Warning, new System.Text.RegularExpressions.Regex("Autosave rejected: (.|\\n)*" + logged));+ var session = GameStart.Begin(content, store, () => 6UL, notes, text, out var resumed);+ Assert.IsFalse(resumed);+ Assert.AreEqual(0, session.State.Turn);+ Assert.AreEqual(new[] { Unreadable(text) }, notes.ToArray());+ StringAssert.DoesNotContain("line", notes[0]);+ StringAssert.DoesNotContain("turn", notes[0]);Assert.IsTrue(File.Exists(Path.Combine(store.Directory, "autosave.bad.txt")));}@@ -107,7 +164,7 @@ public class SaveUiTestsAssert.DoesNotThrow(() => session = GameStart.Begin(C, store, () => 6UL, notes, Text));Assert.AreEqual(0, session!.State.Turn);Assert.AreEqual(1, notes.Count);- StringAssert.StartsWith("Your saved game could not be loaded (Not a Statecraft save", notes[0]);+ Assert.AreEqual(Unreadable(Text), notes[0]);Assert.IsTrue(store.SetAsideCalled);}