A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Unity: the smoke-orders golden, one Move given through the unit card (GDD Phase 5 PR 15 slice 4, refs #754) (#1289)
Berie1becad9a4f6
diff --git a/changelog.d/unity-gdd-smoke-orders-754.md b/changelog.d/unity-gdd-smoke-orders-754.mdnew file mode 100644index 000000000..4bfd3fe1b--- /dev/null+++ b/changelog.d/unity-gdd-smoke-orders-754.md@@ -0,0 +1,4 @@+- GDD Phase 5 PR 15, slice 4: the `smoke-orders` golden (refs #754). The WebGL player's `?smoke-orders` run (desktop+ `-smoke-orders`) plays the first turn as a player gives one unit order: it hides the event card, clicks Golani, presses+ the card's Move button, clicks the first lit hex and presses End turn, then logs `SMOKE ORDERS OK 1948-06-15 <hash>`.+ The sim's `GoldenRun.PlaySmokeOrders` pins the same state in the golden manifest; no other golden moves.diff --git a/docs/determinism.md b/docs/determinism.mdindex aa163c3c4..894bef66a 100644--- a/docs/determinism.md+++ b/docs/determinism.md@@ -66,6 +66,20 @@ uv run tools/web_check.py unity/Builds/Web-<compression> --query "golden&smoke=5--expect "SMOKE OK 5 turns 1948-10-15 7559f30cc7649555cb369b729442d203fa0b42968679f870ac88f0e519a8b755"```+`smoke-orders` (GDD Phase 5 PR 15, #754) is the same kind of browser run for the unit orders (`?smoke-orders`, desktop+`-smoke-orders`: the golden seed, one turn). It hides the turn's event card (the events go to their ministers), clicks the+hex of the unit `GoldenRun.SmokeMove` names (the lowest-id unit `Movement.Reachable` has a hex for: unit 0, Golani, on+10,9), presses the unit card's Move button, clicks the first lit hex in `Reachable`'s (q, r) order (7,11) and presses End+Turn: `SMOKE ORDERS OK 1948-06-15 98422be8eca2981e191fde3a7aaf28fdef269203cee2f6dfe7a7cddb770f7133`.+`GoldenRun.PlaySmokeOrders` plays the same turn with that one `Move`, so the value is in the manifest (`SliceSmokeTests.TheSmokeOrdersRunMovesOneUnitAndEndsOnTheGolden`) and the player's golden check+prints it as `GOLDEN OK smoke-orders`. Re-record it when the sim or the order path on the card changes; the fortify, hold and+attack slices can add their orders to it. Check a WebGL build with:++```+uv run tools/web_check.py unity/Builds/Web-<compression> --query "smoke-orders" \+ --expect "SMOKE ORDERS OK 1948-06-15 98422be8eca2981e191fde3a7aaf28fdef269203cee2f6dfe7a7cddb770f7133"+```+**When a golden moves.** The test fails with the lines that changed, grouped by section (`[ind]`, `[pol]`, `[bud]`,`[sit]` and so on), against a committed snapshot of the run's final state: `sim/Statecraft.Sim.Tests/golden/hash1950.txt`and `hash1952.txt`, written by `GameState.Describe()`, which uses the same writer as `Hash()` (so the two cannot list@@ -141,7 +155,7 @@ goldens (playtest 2 changed every line's casing with no hash change). They are s`FinalWaveTests.AReloadedSaveReproducesTheLastTurnsCauses` checks a reloaded save gives the same last-turn Causes, and`TheGoldenRunsCausesAreTheSameInEveryCulture` runs the 1952 golden under de-DE and ar-SA against the invariant culture.-Each golden hash is pinned in `sim/Statecraft.Sim.Tests/golden/manifest.txt` (`hash1950`, `hash1952`, `mvp-end`, `smoke5`, and the scenario lines above). The .NET tests+Each golden hash is pinned in `sim/Statecraft.Sim.Tests/golden/manifest.txt` (`hash1950`, `hash1952`, `mvp-end`, `smoke5`, `smoke-orders`, and the scenario lines above). The .NET testscompare against it. These places must agree with it, and `GoldenManifestTests` fails naming the one that does not:- `sim/Statecraft.Sim/GoldenRun.cs`, which Unity code and players compare against (the update command rewrites it);- this file, `docs/RELEASING.md` and `tools/web_check.py`'s usage example (by hand).@@ -371,3 +385,4 @@ The hash reads the state keys, so it never sees a record outside its window. An| #1241: Etzioni starts, the 7th Brigade arrives (R-UNIT-009), on the enemy AI (#1263) | scenario-cautious | `e45c5429` | same as reckless (was `230791a1`) || #1241: Etzioni starts, the 7th Brigade arrives (R-UNIT-009), on the enemy AI (#1263) | scenario-mvp-absorb-first | `64bdd93b` | same as reckless (was `de176931`) || #1241: Etzioni starts, the 7th Brigade arrives (R-UNIT-009), on the enemy AI (#1263) | scenario-mvp-defeat | `54ec7d6b` | same as reckless; the defeat is unchanged (was `7404295a`) |+| GDD Phase 5 PR 15 slice 4 (#754) | smoke-orders | `98422be8` | new: one turn from the golden seed whose only order is unit 0 (Golani) moving from 10,9 to 7,11, given through the unit card in the browser run; no other golden moves |diff --git a/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs b/sim/Statecraft.Sim.Tests/GoldenManifestTests.csindex d47c68f56..d1260caef 100644--- a/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs+++ b/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs@@ -15,7 +15,7 @@ public class GoldenManifestTests{var m = GoldenManifest.Read();var scenarios = System.IO.Directory.GetFiles(ScenarioTests.Dir(), "*.yaml").Select(f => "scenario-" + System.IO.Path.GetFileNameWithoutExtension(f));- var known = new[] { "hash1950", "hash1952", "smoke5", "mvp-end" }.Concat(scenarios).OrderBy(k => k, StringComparer.Ordinal).ToArray(); // one line per scenario file (#296)+ var known = new[] { "hash1950", "hash1952", "smoke5", "smoke-orders", "mvp-end" }.Concat(scenarios).OrderBy(k => k, StringComparer.Ordinal).ToArray(); // one line per scenario file (#296)Assert.Equal(known, m.Keys.OrderBy(k => k, StringComparer.Ordinal).ToArray());Assert.All(m.Values, h => Assert.Matches("^[0-9a-f]{64}$", h));}@@ -44,11 +44,13 @@ public class GoldenManifestTests[InlineData("hash1950")][InlineData("hash1952")][InlineData("smoke5")]+ [InlineData("smoke-orders")]public void TheDocsAndTheWebCheckShowTheManifestHash(string name){var hash = GoldenManifest.Expected(name);Assert.True(Text("docs", "determinism.md").Contains(hash), $"docs/determinism.md does not show the current {name} hash {hash}");- Assert.True(Text("docs", "RELEASING.md").Contains(hash), $"docs/RELEASING.md does not show the current {name} hash {hash}");+ if (name != "smoke-orders") // the release runs pin smoke5's UI path only; smoke-orders' sim value is in their manifest loop+ Assert.True(Text("docs", "RELEASING.md").Contains(hash), $"docs/RELEASING.md does not show the current {name} hash {hash}");if (name != "smoke5")Assert.True(Text("tools", "web_check.py").Contains(hash), $"tools/web_check.py does not show the current {name} hash {hash}");}diff --git a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs b/sim/Statecraft.Sim.Tests/SliceSmokeTests.csindex b48a0ba2e..98778c534 100644--- a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs+++ b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs@@ -237,6 +237,22 @@ public class SliceSmokeTestsAssert.True(clock.Elapsed < TimeSpan.FromMinutes(1), $"took {clock.Elapsed}");}+ /// <summary>The smoke-orders golden (GDD Phase 5 PR 15, #754): one turn whose only order is one Move, the one the WebGL+ /// ?smoke-orders run gives through the unit card's buttons (GameRoot.SmokeOrders); events go to their ministers.</summary>+ [Fact]+ public void TheSmokeOrdersRunMovesOneUnitAndEndsOnTheGolden()+ {+ var start = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);+ var move = GoldenRun.SmokeMove(Real, start);+ Assert.Equal(Movement.Reachable(Real, start, move.Unit).Keys.First(), (move.Q, move.R)); // a hex the card lights+ var end = GoldenRun.PlaySmokeOrders(Real);+ var expected = GoldenManifest.Expected("smoke-orders"); // read before an update rewrites the manifest+ if (GoldenManifest.UpdateRequested) GoldenManifest.Update("smoke-orders", end.Hash());+ Assert.Equal((move.Q, move.R), (end.Units[move.Unit].Q, end.Units[move.Unit].R)); // the order took effect+ Assert.NotEqual(Simulation.Step(Real, start, new List<Command>()).State.Hash(), end.Hash()); // and shows in the hash+ Assert.Equal(expected, end.Hash());+ }+[Fact]public void TheHistoricalRunPlaysTheWholeSliceCleanlyAndEndsOnTheGolden(){diff --git a/sim/Statecraft.Sim.Tests/golden/manifest.txt b/sim/Statecraft.Sim.Tests/golden/manifest.txtindex bece00341..ddc4f62f4 100644--- a/sim/Statecraft.Sim.Tests/golden/manifest.txt+++ b/sim/Statecraft.Sim.Tests/golden/manifest.txt@@ -5,6 +5,7 @@hash1950 d14a4899a1e068bf238f84f4e8fe06270b5164b2c6ba62f2fef399fd7eaada8ehash1952 3bacd2b10340aa95ec130d84aedfb560828dae6b0ed35323f64410f9ac8eee85smoke5 7559f30cc7649555cb369b729442d203fa0b42968679f870ac88f0e519a8b755+smoke-orders 98422be8eca2981e191fde3a7aaf28fdef269203cee2f6dfe7a7cddb770f7133scenario-reckless 030817e35956616c848df451c02fbb1b4e981d0971100f49121cb83c01220586scenario-cautious e45c542996b94c73242f276acc0f1d6301e3f1cc1a55a919bdc7cc3788894d33scenario-mvp-absorb-first 64bdd93b3003158e9504d4d1e4581d214ffd52a992ccf9035d81b56c312eb6aediff --git a/sim/Statecraft.Sim/GoldenRun.cs b/sim/Statecraft.Sim/GoldenRun.csindex 0b2913bc4..60b7cf875 100644--- a/sim/Statecraft.Sim/GoldenRun.cs+++ b/sim/Statecraft.Sim/GoldenRun.cs@@ -93,5 +93,28 @@ namespace Statecraft.Sims = Simulation.Step(c, s, SmokeOrders(c, s)).State;return s;}++ /// <summary>The smoke-orders golden's one order (GDD Phase 5 PR 15, #754), what the WebGL ?smoke-orders run's+ /// GameRoot.SmokeOrders gives through the unit card: Move for the lowest-id unit Movement.Reachable has a hex for,+ /// to the first of those hexes in Reachable's (q, r) order. Here, so Unity's run and the tests pick the same order.</summary>+ public static Move SmokeMove(Content c, GameState s)+ {+ if (c == null) throw new ArgumentNullException(nameof(c));+ foreach (var id in s.Units.Keys) // a SortedList: in id order+ {+ var reach = Movement.Reachable(c, s, id);+ if (reach.Count > 0) { var (q, r) = reach.Keys.First(); return new Move(id, q, r); }+ }+ throw new InvalidOperationException("the smoke-orders run needs a unit that can move");+ }++ /// <summary>The smoke-orders golden: the golden seed, Historical mode, one turn whose only order is <see cref="SmokeMove"/>+ /// (the turn's events go to their ministers).</summary>+ public static GameState PlaySmokeOrders(Content c)+ {+ if (c == null) throw new ArgumentNullException(nameof(c));+ var s = Simulation.NewGame(c, Seed, Mode.Historical);+ return Simulation.Step(c, s, new Command[] { SmokeMove(c, s) }).State;+ }}}diff --git a/tools/web_check.py b/tools/web_check.pyindex d20415204..aae880509 100644--- a/tools/web_check.py+++ b/tools/web_check.py@@ -9,6 +9,8 @@ fail on a failure line or a timeout. Uses Chrome for Testing from the PlaywrightUsage (from the repo root):uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK hash1950 d14a4899a1e068bf238f84f4e8fe06270b5164b2c6ba62f2fef399fd7eaada8e" --expect "GOLDEN OK hash1952 3bacd2b10340aa95ec130d84aedfb560828dae6b0ed35323f64410f9ac8eee85"+ uv run tools/web_check.py unity/Builds/Web-disabled --query "smoke-orders" --expect "SMOKE ORDERS OK 1948-06-15 98422be8eca2981e191fde3a7aaf28fdef269203cee2f6dfe7a7cddb770f7133"+ (the smoke-orders golden: one Move given through the unit card, docs/determinism.md)Options: --query Q (page URL query, without '?'), --expect TEXT (repeatable), --fail REGEX (default: GOLDEN FAIL|SMOKE FAIL|BOOT FAIL),--timeout SECONDS (default 300), --stall SECONDS (fail when no console message arrives for that long; 0 = off),--swiftshader (software WebGL when there is no GPU), --dpr N (default 1), --shots DIR (reassemble the player'sdiff --git a/unity/Assets/Scripts/Boot/GoldenCheck.cs b/unity/Assets/Scripts/Boot/GoldenCheck.csindex eba4dbb3f..5efc34b77 100644--- a/unity/Assets/Scripts/Boot/GoldenCheck.cs+++ b/unity/Assets/Scripts/Boot/GoldenCheck.cs@@ -43,13 +43,14 @@ namespace Statecraft.Game.Boot}/// <summary>The run a manifest name pins (docs/determinism.md): hash1950 and hash1952 (GoldenRun.Play), mvp-end- /// (GoldenRun.PlayToEnd), smoke<N> (GoldenRun.PlaySmoke), scenario-<name> (that scenario file) and the+ /// (GoldenRun.PlayToEnd), smoke<N> (GoldenRun.PlaySmoke), smoke-orders (GoldenRun.PlaySmokeOrders), scenario-<name> (that scenario file) and the/// era goldens hash_<era>_<year> (GoldenRun.PlayEra to 1 January of that year, as EraGolden names them).</summary>internal static GameState Play(string name, Content c, GoldenData data){if (name == "hash1950") return GoldenRun.Play(c, GoldenRun.Until1950);if (name == "hash1952") return GoldenRun.Play(c, GoldenRun.Until1952);if (name == "mvp-end") return GoldenRun.PlayToEnd(c);+ if (name == "smoke-orders") return GoldenRun.PlaySmokeOrders(c);if (name.StartsWith("smoke", StringComparison.Ordinal)&& int.TryParse(name.Substring("smoke".Length), NumberStyles.None, CultureInfo.InvariantCulture, out var turns) && turns > 0)return GoldenRun.PlaySmoke(c, turns);diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex 48eeb60ad..87a72d759 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -187,15 +187,25 @@ namespace Statecraft.Game.UIpublic static int SmokeTurns() =>SmokeTurns(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer);+ /// <summary>"?smoke-orders" (WebGL) or "-smoke-orders" (desktop): the smoke-orders golden's one-turn run (SmokeOrders, #754)+ /// instead of the smoke turns. A whole query parameter, so the "smoke" flag never matches it, nor it "?smoke-orders-x".</summary>+ internal static bool SmokeOrdersRequested(string? url, string[] args, bool webgl) =>+ webgl ? UrlFlags.Has(url, "smoke-orders") : Array.IndexOf(args, "-smoke-orders") >= 0;+/// <summary>GameBoot.Ready: starts the game, smoke-testing when the URL or command line asks, with the start screen/// unless an automated run skips it.</summary>- public void Begin(GameInputs inputs) => Begin(inputs, SmokeTurns(), Application.isPlaying && !StartScreenPresenter.Skipped());+ public void Begin(GameInputs inputs)+ {+ bool orders = SmokeOrdersRequested(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer);+ Begin(inputs, orders ? 1 : SmokeTurns(), Application.isPlaying && !StartScreenPresenter.Skipped(), smokeOrders: orders);+ }- /// <summary>Starts (or restarts) the game over the built map. <paramref name="smoke"/> > 0 plays that many turns;+ /// <summary>Starts (or restarts) the game over the built map. <paramref name="smoke"/> > 0 plays that many turns+ /// (with <paramref name="smokeOrders"/>, the smoke-orders run's one turn instead);/// <paramref name="startScreen"/> shows the start screen first (never in a smoke run, which has no New Game)./// <paramref name="keep"/> (Settings' language switch) goes on with that bridge's game and its queued orders instead/// of loading the autosave.</summary>- internal void Begin(GameInputs inputs, int smoke, bool startScreen = false, SimBridge? keep = null)+ internal void Begin(GameInputs inputs, int smoke, bool startScreen = false, SimBridge? keep = null, bool smokeOrders = false){if (inputs == null) throw new ArgumentNullException(nameof(inputs));foreach (var (value, field) in new (UnityEngine.Object?, string)[] { (document, nameof(document)), (strings, nameof(strings)), (stringsHe, nameof(stringsHe)),@@ -495,7 +505,7 @@ namespace Statecraft.Game.UIStartCoroutine(FirstCardCheck(root, card!, Debug.Log));if (smoke > 0){- if (Application.isPlaying) StartCoroutine(Smoke(root, bridge, card!, smoke, Debug.Log));+ if (Application.isPlaying) StartCoroutine(smokeOrders ? SmokeOrders(root, bridge, unitLayer, onHex, Debug.Log) : Smoke(root, bridge, card!, smoke, Debug.Log));else Debug.LogWarning("SMOKE FAIL the smoke run needs play mode or a player");}if (Application.isPlaying && PixelErrorProfile.Requested()) StartCoroutine(PixelErrorProfile.Run(map.Terrain));@@ -791,6 +801,46 @@ namespace Statecraft.Game.UIlog(FormattableString.Invariant($"SMOKE OK {turns} turns {bridge.State.Date:yyyy-MM-dd} {bridge.State.Hash()}"));}+ /// <summary>The smoke-orders golden (#754, docs/determinism.md): turn 1 with one unit order given as a player gives it.+ /// An open event card takes the panels under it out of reach, so it first presses the card's Hide (the turn's events+ /// go to their ministers). It clicks the hex of the unit GoldenRun.SmokeMove names (<paramref name="clickHex"/>: what+ /// a map click raises), presses the unit card's Move button, clicks the order's lit hex, then presses End Turn and+ /// closes the turn report. Logs "SMOKE ORDERS move unit <id> to <q>,<r>", then+ /// "SMOKE ORDERS OK <date> <hash>", or "SMOKE FAIL <reason>" when a click or press does not take effect.+ /// Static, so an edit-mode test can drive it.</summary>+ public static IEnumerator SmokeOrders(VisualElement root, SimBridge bridge, Statecraft.Game.Map.Units.UnitLayer units,+ Action<int, int> clickHex, Action<string> log)+ {+ yield return null;+ var hud = root.Q("root") ?? root;+ if (hud.ClassListContains(EventCardPresenter.OpenClass))+ {+ if (!Press(root.Q<Button>("event-hide"), log)) yield break;+ if (hud.ClassListContains(EventCardPresenter.OpenClass)) { log("SMOKE FAIL the event card did not hide"); yield break; }+ }+ var move = GoldenRun.SmokeMove(bridge.Content, bridge.State);+ var token = units.Tokens.Where(p => UnitCard.SimUnit(bridge.Content, bridge.State, p.Token.Unit) == move.Unit)+ .Select(p => (Statecraft.Game.Map.Units.PlacedToken?)p).FirstOrDefault();+ if (!(token is { } t)) { log(FormattableString.Invariant($"SMOKE FAIL unit {move.Unit} has no token on the map")); yield break; }+ log(FormattableString.Invariant($"SMOKE ORDERS move unit {move.Unit} to {move.Q},{move.R}"));+ clickHex(t.Q, t.R);+ if (units.Selected != t.Token.Unit.Id) { log(FormattableString.Invariant($"SMOKE FAIL the click on {t.Q},{t.R} did not select unit {move.Unit}")); yield break; }+ if (!Press(root.Q<Button>("info-move"), log)) yield break;+ clickHex(move.Q, move.R);+ if (!bridge.Queued.OfType<Move>().Any(m => m.Unit == move.Unit && m.Q == move.Q && m.R == move.R))+ { log(FormattableString.Invariant($"SMOKE FAIL the click on {move.Q},{move.R} queued no Move for unit {move.Unit}")); yield break; }+ yield return null;+ var turn = bridge.State.Turn;+ if (!Press(root.Q<Button>("end-turn"), log)) yield break;+ if (bridge.State.Turn != turn + 1) { log(FormattableString.Invariant($"SMOKE FAIL End Turn did not end turn {turn}")); yield break; }+ if (hud.ClassListContains(TurnReportPresenter.OpenClass))+ {+ if (!Press(root.Q<Button>("turn-report-close"), log)) yield break;+ if (hud.ClassListContains(TurnReportPresenter.OpenClass)) { log(FormattableString.Invariant($"SMOKE FAIL the turn report after turn {turn} did not close")); yield break; }+ }+ log(FormattableString.Invariant($"SMOKE ORDERS OK {bridge.State.Date:yyyy-MM-dd} {bridge.State.Hash()}"));+ }+static bool Press(Button? b, Action<string> log){if (b == null) { log("SMOKE FAIL button missing"); return false; }diff --git a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs b/unity/Assets/Tests/EditMode/UnitOrdersTests.csindex 4c9e13be1..46b194f1a 100644--- a/unity/Assets/Tests/EditMode/UnitOrdersTests.cs+++ b/unity/Assets/Tests/EditMode/UnitOrdersTests.cs@@ -255,4 +255,75 @@ public class UnitOrdersTests}finally { Object.DestroyImmediate(map.gameObject); }}++ /// <summary>The smoke-orders golden (slice 4): GameRoot.SmokeOrders hides turn 1's event card, gives GoldenRun.SmokeMove+ /// through the unit card (a click on the unit, Move, a click on the lit hex), ends the turn with End Turn, and ends on the state the sim's+ /// PlaySmokeOrders pins in the golden manifest.</summary>+ [Test]+ public void TheSmokeOrdersRunGivesItsMoveThroughTheCardAndEndsOnTheGolden()+ {+ var map = BuildMap();+ using var ui = new UiTestKit();+ try+ {+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ using var toast = new ToastPresenter(ui.Root, bridge, Text);+ using var hud = new HudPresenter(ui.Root, bridge, Text); // wires End Turn+ using var card = new EventCardPresenter(ui.Root, bridge, Text, null);+ Assert.IsTrue(ui.Root.Q("root").ClassListContains(EventCardPresenter.OpenClass), "precondition: turn 1's card is open, as in the player");+ var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);+ layer.Show(bridge.Content, bridge.State);+ using var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(),+ selectedUnit: () => layer.Selected is string sel ? layer.Tokens.First(p => p.Token.Unit.Id == sel) : (PlacedToken?)null,+ showReachable: map.ShowReachable);+ var log = new List<string>();+ var run = GameRoot.SmokeOrders(ui.Root, bridge, layer, (q, r) => GameRoot.OnHexClicked(map, layer, info, q, r), log.Add);+ while (run.MoveNext()) { }+ var golden = GoldenRun.PlaySmokeOrders(C);+ Assert.AreEqual(System.FormattableString.Invariant($"SMOKE ORDERS OK {golden.Date:yyyy-MM-dd} {golden.Hash()}"), log.Last(), string.Join("\n", log));+ var move = (Move)bridge.LastBatch.Single();+ var expected = GoldenRun.SmokeMove(C, GameSession.New(C, GoldenRun.Seed, Mode.Historical).State);+ Assert.AreEqual((expected.Unit, expected.Q, expected.R), (move.Unit, move.Q, move.R), "the one order End Turn sent");+ }+ finally { Object.DestroyImmediate(map.gameObject); }+ }++ /// <summary>A click that misses the lit hex queues no Move: the smoke-orders run fails and ends no turn.</summary>+ [Test]+ public void ASmokeOrdersRunWhoseMoveIsNotQueuedFails()+ {+ var map = BuildMap();+ using var ui = new UiTestKit();+ try+ {+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ using var hud = new HudPresenter(ui.Root, bridge, Text);+ var layer = UnitLayer.Create(map, Units, C.Hexes, still: true);+ layer.Show(bridge.Content, bridge.State);+ using var info = new InfoPanelPresenter(ui.Root, bridge, Text, new Dictionary<string, string>(),+ selectedUnit: () => layer.Selected is string sel ? layer.Tokens.First(p => p.Token.Unit.Id == sel) : (PlacedToken?)null);+ int clicks = 0, turn = bridge.State.Turn;+ var log = new List<string>();+ var run = GameRoot.SmokeOrders(ui.Root, bridge, layer, (q, r) => { if (clicks++ == 0) GameRoot.OnHexClicked(map, layer, info, q, r); }, log.Add);+ while (run.MoveNext()) { }+ StringAssert.StartsWith("SMOKE FAIL", log.Last(), string.Join("\n", log));+ Assert.IsFalse(log.Any(l => l.StartsWith("SMOKE ORDERS OK")));+ Assert.AreEqual(turn, bridge.State.Turn, "no turn ended");+ }+ finally { Object.DestroyImmediate(map.gameObject); }+ }++ /// <summary>"smoke-orders" is its own whole flag: it starts the one-turn run and is not the "smoke" flag.</summary>+ [Test]+ public void SmokeOrdersIsItsOwnFlag()+ {+ var none = new string[0];+ Assert.IsTrue(GameRoot.SmokeOrdersRequested("http://localhost/?smoke-orders", none, true));+ Assert.IsTrue(GameRoot.SmokeOrdersRequested("http://localhost/?golden&smoke-orders", none, true));+ Assert.IsFalse(GameRoot.SmokeOrdersRequested("http://localhost/?smoke-orders-x", none, true));+ Assert.IsFalse(GameRoot.SmokeOrdersRequested("http://localhost/?smoke=5", none, true));+ Assert.AreEqual(0, GameRoot.SmokeTurns("http://localhost/?smoke-orders", none, true), "not the smoke flag");+ Assert.IsTrue(GameRoot.SmokeOrdersRequested(null, new[] { "Statecraft", "-smoke-orders" }, false));+ Assert.IsFalse(GameRoot.SmokeOrdersRequested("http://localhost/?smoke-orders", new[] { "Statecraft" }, false), "desktop reads only the command line");+ }}