A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
feat(unity): a ?firstcard browser check runs the first event card's normal media path (Fixes #909) (#921)
Eyal Goland553eeded7b0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3c6a461f5..a5b026972 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,6 +39,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB(#881). The new Hebrew strings are flagged for native-speaker review (#564).- The 7th Brigade's card dates follow the IDF sources (owner, 17 October 2026): formed 14 May 1948, the day of thefounding order (was 16 May), and Operation Bin Nun ends on 31 May 1948 (was 1 June) (refs #902).+- A WebGL `?firstcard` check now follows the normal first-card path: it closes the start screen through New Game,+ leaves decision video enabled, records the event-photo load, and requires an interactive photo or portrait-fallback+ card within a proposed 10-second budget (refs #909; budget needs maintainer sign-off).- The content loader now checks `name_he_review` on people rows the way it does for parties, governments,legislatures, offices and settlements: the flag is `agent-checked` or left out, and only beside a `name_he`(CONTENT_POLICY section 2, rule 6; #862). No people row carries the flag yet, so no row changes.diff --git a/docs/dev-setup.md b/docs/dev-setup.mdindex 8f5252437..5477c3538 100644--- a/docs/dev-setup.md+++ b/docs/dev-setup.md@@ -59,6 +59,11 @@ Not possible without Unity and not in CI: the Unity EditMode tests, player build(every UI pointer and submit event, screen toggle and map click, with its frame), `?vprofile` (the visual frame-timeprofile per feature), `?shot` (screenshots at the promo poses as `SHOT` console lines) and `?kitscale=N`, `?housescale=N`, `?treescale=N` (the settlement kits' symbolic scale for city blocks, houses and trees, clamped to 5–200; defaults 60, 100, 100). In the editor, `MapCapture.Kits` takes `-kitScale`, `-houseScale` and `-treeScale`. Desktop players take `-golden`,`-smoke N`, `-profile`, `-camlog`, `-bootlog`, `-navlog`, `-vprofile` and `-shot`. The console also shows `GAME OK <date> turn <n> hash <h>` at start and `TURN <n> <date> hash <h>` per turn.+- First card in normal mode (#909): `?firstcard` keeps the start screen and decision video on, presses New Game at once+ and logs `FIRST CARD OK event=<id> media=<photo|portrait fallback> wait=<ms> ms budget=<ms> ms`, or `FIRST CARD FAIL`+ after the budget (10 s, proposed). Run it with `uv run tools/machine_lock.py --shared -- uv run tools/web_check.py <build>+ --query firstcard --expect "BOOT event photos ready" --expect "FIRST CARD OK" --fail "FIRST CARD FAIL|BOOT FAIL|Exception"`,+ and again with `--query "firstcard&lang=he"`.- Visual checks (docs/visual-v1.md): measure only under the machine lock, which also waits for any open Unity editor:`uv run tools/machine_lock.py --exclusive --wait-unity -- uv run tools/web_check.py <build> --query vprofile --expect "PROFILE visual done" --timeout 1800 --stall 120`(headless), `... -- uv run tools/headed.py profile --build <build> --dpr 1` (headed; `--dpr 2` is thediff --git a/unity/Assets/Scripts/UI/EventImageCatalog.cs b/unity/Assets/Scripts/UI/EventImageCatalog.csindex 40fcf5d83..33b286857 100644--- a/unity/Assets/Scripts/UI/EventImageCatalog.cs+++ b/unity/Assets/Scripts/UI/EventImageCatalog.cs@@ -126,7 +126,8 @@ namespace Statecraft.Game.UIif (pending == null) { Loads++; catalog = LoadNow(); }else catalog = pending();pending = null; Loaded = true;- if (Statecraft.Game.Boot.DiagLog.Boot)+ // The normal-media browser check always records this line; other runs keep it behind ?bootlog.+ if (Statecraft.Game.Boot.DiagLog.Boot || GameRoot.FirstCardCheckRequested())Debug.Log(FormattableString.Invariant($"BOOT event photos ready ({how}) wait={watch.Elapsed.TotalMilliseconds:0} ms"));return catalog;}diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex c5e6cbff5..60e73eb8a 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -28,6 +28,9 @@ namespace Statecraft.Game.UI{/// <summary>Turns a bare smoke flag ("?smoke", "-smoke") plays.</summary>internal const int DefaultSmokeTurns = 5;+ /// <summary>Maximum time after closing the start screen for the normal-media browser check's first card to become usable.+ /// This proposed budget needs maintainer sign-off (#909).</summary>+ internal const double FirstCardBudgetSeconds = 10;[SerializeField] GameBoot boot = null!;[SerializeField] UIDocument document = null!;@@ -364,6 +367,11 @@ namespace Statecraft.Game.UIif (notes.Count > 0) toast.Show(notes);Debug.Log(FormattableString.Invariant($"GAME OK {bridge.State.Date:yyyy-MM-dd} turn {bridge.State.Turn} hash {bridge.State.Hash()}"));+ // Unlike the other browser instruments, ?firstcard keeps the normal start screen, clip mapping and video players.+ // It closes the screen through its real button immediately, then gives tools/web_check.py a bounded result to+ // wait for. Console exceptions are collected by that browser-side check (#910).+ if (Application.isPlaying && FirstCardCheckRequested())+ StartCoroutine(FirstCardCheck(root, card!, Debug.Log));if (smoke > 0){if (Application.isPlaying) StartCoroutine(Smoke(root, bridge, card!, smoke, Debug.Log));@@ -458,6 +466,46 @@ namespace Statecraft.Game.UIinternal static string CameraLine(float distance, float yaw) => FormattableString.Invariant($"CAMERA distance={distance:0} yaw={yaw:0.0}");+ /// <summary>"firstcard" asks a player build to exercise the first card through the normal media path. It deliberately+ /// is not one of StartScreenPresenter.Skipped or CardVideo.ForcedOff's automation flags.</summary>+ internal static bool FirstCardCheckRequested(string? url, string[] args, bool webgl) =>+ webgl ? UrlFlags.Has(url, "firstcard") : Array.IndexOf(args, "-firstcard") >= 0;++ internal static bool FirstCardCheckRequested() =>+ FirstCardCheckRequested(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer);++ /// <summary>Closes a fresh game's start screen at once through New Game and waits at most+ /// <see cref="FirstCardBudgetSeconds"/> seconds for an enabled option plus the archival photograph or documented+ /// minister-portrait fallback. The browser check treats FIRST CARD FAIL and console exceptions as failures.</summary>+ internal static IEnumerator FirstCardCheck(VisualElement root, EventCardPresenter card, Action<string> log,+ Func<double>? now = null)+ {+ now ??= () => Time.realtimeSinceStartupAsDouble;+ var began = now();+ var hud = root.Q("root") ?? root;+ if (!hud.ClassListContains(StartScreenPresenter.OpenClass))+ {+ log("FIRST CARD FAIL start screen is not open");+ yield break;+ }+ if (!Press(root.Q<Button>("start-new-game"), s => log(s.Replace("SMOKE FAIL", "FIRST CARD FAIL")))) yield break;+ while (now() - began <= FirstCardBudgetSeconds)+ {+ var option = root.Q<VisualElement>("event-options")?.Q<Button>();+ bool photo = root.Q<VisualElement>("event-photo")?.style.display.value == DisplayStyle.Flex;+ bool portrait = root.Q<VisualElement>("event-image")?.style.display.value == DisplayStyle.Flex;+ if (!hud.ClassListContains(StartScreenPresenter.OpenClass) && card.Shown != null && !card.Collapsed &&+ !card.PhotoWaits && option != null && option.enabledInHierarchy && (photo || portrait))+ {+ var wait = (now() - began) * 1000;+ log(FormattableString.Invariant($"FIRST CARD OK event={card.Shown.Id} media={(photo ? "photo" : "portrait fallback")} wait={wait:0} ms budget={FirstCardBudgetSeconds * 1000:0} ms"));+ yield break;+ }+ yield return null;+ }+ log(FormattableString.Invariant($"FIRST CARD FAIL not interactive after {FirstCardBudgetSeconds * 1000:0} ms"));+ }+/// <summary>After every Update (CameraController moves the camera in its Update), so the pills never trail the camera.</summary>void LateUpdate(){diff --git a/unity/Assets/Tests/EditMode/EventPhotosLoadTests.cs b/unity/Assets/Tests/EditMode/EventPhotosLoadTests.csindex 2d3461792..e7af6f76e 100644--- a/unity/Assets/Tests/EditMode/EventPhotosLoadTests.cs+++ b/unity/Assets/Tests/EditMode/EventPhotosLoadTests.cs@@ -1,5 +1,7 @@#nullable enableusing System.IO;+using System.Collections;+using System.Collections.Generic;using System.Linq;using NUnit.Framework;using Statecraft.Game;@@ -367,6 +369,42 @@ public class EventPhotosLoadTestsfinally { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }}+ /// <summary>#909: the browser's ?firstcard run is normal play (the start screen and video stay on). It presses New Game+ /// immediately and reports only once the first option and its photo or documented portrait fallback are usable. The+ /// proposed first-card budget is 10 seconds and needs maintainer sign-off.</summary>+ [Test]+ public void TheNormalMediaBrowserCheckClosesTheStartScreenAndFindsAnInteractiveFirstCard()+ {+ const string url = "http://localhost:8000/index.html?firstcard";+ Assert.IsTrue(GameRoot.FirstCardCheckRequested(url, System.Array.Empty<string>(), webgl: true));+ Assert.IsFalse(StartScreenPresenter.Skipped(url, System.Array.Empty<string>(), webgl: true), "normal start screen");+ Assert.IsFalse(CardVideo.ForcedOff(url, System.Array.Empty<string>(), webgl: true), "normal clip mapping and players");+ Assert.AreEqual(10, GameRoot.FirstCardBudgetSeconds, "the stated browser budget, in seconds");++ var inputs = GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);+ try+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ Object.FindFirstObjectByType<MapScene>().Build(inputs.Map);+ var game = Object.FindFirstObjectByType<GameRoot>();+ game.Store = new SaveStore(saveDir);+ game.Begin(inputs, 0, startScreen: true);+ var ui = Object.FindFirstObjectByType<UIDocument>().rootVisualElement;+ var lines = new List<string>();+ double clock = 0;+ IEnumerator check = GameRoot.FirstCardCheck(ui, game.Card!, lines.Add, () => clock++);+ while (check.MoveNext()) { }++ Assert.IsFalse(ui.Q("root").ClassListContains(StartScreenPresenter.OpenClass), "New Game closed the screen at once");+ Assert.AreEqual(1, lines.Count, string.Join("\n", lines));+ StringAssert.StartsWith("FIRST CARD OK event=idf_founding media=photo ", lines[0]);+ StringAssert.EndsWith("budget=10000 ms", lines[0]);+ Assert.IsTrue(EventPhotos.Loaded, "the card ran the real photo path");+ Assert.IsTrue(ui.Q<VisualElement>("event-options").Q<Button>().enabledInHierarchy, "the first option is interactive");+ }+ finally { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); VisualToggles.Clear(); }+ }+[Test]public void GameRootBeginLoadsNoPhotoCatalog([Values(false, true)] bool startScreen){