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.

web_check: fail a start screen run without Israeli and enemy unit tokens on turns 1-2 (#2056) (#2130)

Eyal Golana4042450bff2
diff --git a/changelog.d/2056-web-check-units.md b/changelog.d/2056-web-check-units.md
new file mode 100644
index 000000000..08811c76f
--- /dev/null
+++ b/changelog.d/2056-web-check-units.md
@@ -0,0 +1,3 @@
+- Under `?navlog` the map logs the unit tokens it draws for each side, and `tools/web_check.py`'s start screen
+ passes fail when Israeli or enemy tokens are missing on turn 1 or turn 2, as in the 31 October nightly with no enemy
+ units (#2056).
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index 0f6fc16d5..ce0a6a06e 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -48,7 +48,10 @@ macOS IL2CPP parity check is not an MVP release gate.
The four `--startscreen` passes (owner decision on #967, 17 October 2026) open the start screen every player sees
first, which the golden and smoke run skips: New game, and Play the recording then New game, in English and in
- Hebrew. Each must print `PASS`. A console exception, `RECORDING failed` or `BOOT FAIL` fails it (#908).
+ Hebrew. Each must print `PASS`. A console exception, `RECORDING failed` or `BOOT FAIL` fails it (#908). So does a map
+ without Israeli and enemy unit tokens on turn 1 (the new game) or turn 2 (after End turn): `UNITS FAIL`, read from the
+ `units drawn` line the unit layer logs under `?navlog`; a build that logs no such line fails too (owner ruling on #2056,
+ 1 November 2026).
The English-only `--persistence` pass waits for each save's matching IndexedDB commit and checks that both reloads
restore its date, turn and state hash.
diff --git a/tools/tests/test_web_check.py b/tools/tests/test_web_check.py
index 8a4d7d23c..4005a905d 100644
--- a/tools/tests/test_web_check.py
+++ b/tools/tests/test_web_check.py
@@ -231,6 +231,12 @@ LAID_OUT = ("NAV f=88 t=9625 start buttons start-continue=0.3750,0.9278 start-ne
AT = {"start-continue": (720, 1002), "start-new-game": (860, 1002), "start-star": (1060, 1002), "start-listen": (812, 940)}
+# The map's tokens as UnitLayer logs them under ?navlog (#2056): the turn, the Israeli and the enemy totals, then each enemy
+# side's count.
+def units_line(turn, israel, enemy):
+ return f"NAV f=412 t=20311 units drawn turn={turn} israel={israel} enemy={enemy}" + (f" egypt={enemy}" if enemy else "")
+
+
def _buttons(text=LAID_OUT, wait=0.0):
buttons = wc.StartButtons((1920, 1080), wait=wait, sleep=lambda s: None)
buttons.feed(text)
@@ -288,12 +294,22 @@ class FakeGame:
"""Answers a driver's clicks as ?navlog's game does, through a real ConsoleTail: End turn (either layout's) selects a
unit while `units` still need orders, else ends the turn: a TURN line in the console EndTurn reads (a driver's own
TURN lines are fed by the test). The unit card is EN_CARD, its rows mirrored in Hebrew: a probe names the element under
- it (a "map" one is taken by the map), and a click on Skip skips a unit."""
+ it (a "map" one is taken by the map), and a click on Skip skips a unit. The map's tokens (#2056) are `drawn`, fed as
+ UnitLayer logs them: `tokens[turn]` (Israeli, enemy) for the new game's turn 0 at once, and for each later turn just
+ before its TURN line (SimBridge raises Changed before TurnEnded); a turn missing from `tokens` logs no line."""
- def __init__(self, units=0, card=None, hebrew=False, answers=True, opening=None):
+ def __init__(self, units=0, card=None, hebrew=False, answers=True, opening=None, tokens=None):
self.tail, self.units, self.answers = wc.ConsoleTail(), units, answers
self.card, self.hebrew, self.actions, self.turn = card or EN_CARD, hebrew, [], 1
self.opening = opening # #530: the opening's layout while it covers the window (top bar included), until Skip
+ self.tokens = {0: (10, 2), 1: (10, 3)} if tokens is None else tokens
+ self.drawn = wc.UnitsOnMap(wait=0.05)
+ self.draw(0)
+
+ def draw(self, turn):
+ if turn in self.tokens:
+ israel, enemy = self.tokens[turn]
+ self.drawn.feed(units_line(turn, israel, enemy))
def nav(self, what):
self.tail.feed(f"NAV f=1 t=1 {what}")
@@ -322,6 +338,7 @@ class FakeGame:
elif kind == "click" and (x, y) in (wc.END_TURN, wc.END_TURN_HE):
self.nav("ui click count=1 target=end-turn")
if self.units == 0:
+ self.draw(self.turn)
self.tail.feed(f"TURN {self.turn} 1948-06-15 hash bb")
self.turn += self.units == 0
elif kind == "probe":
@@ -361,9 +378,9 @@ def _quiet():
def _quiet_start():
- """An English New game StartScreenCheck's game, recording, hebrew, buttons and console."""
+ """An English New game StartScreenCheck's game, recording, hebrew, buttons, console and tokens."""
game = FakeGame()
- return game, False, False, _buttons(), game.tail
+ return game, False, False, _buttons(), game.tail, game.drawn
def _end_turn(game, **kw):
@@ -445,7 +462,8 @@ def test_end_turn_fails_when_the_opening_is_still_there_after_skip():
def test_start_screen_check_skips_the_opening_after_new_game():
game = FakeGame(opening=EN_OPENING)
- check = wc.StartScreenCheck(game, recording=False, hebrew=False, buttons=_buttons(), tail=game.tail, settle=lambda s: None)
+ check = wc.StartScreenCheck(game, recording=False, hebrew=False, buttons=_buttons(), tail=game.tail, units=game.drawn,
+ settle=lambda s: None)
check.feed("GAME OK 1948-05-15 turn 0 hash aa")
clicks = [a for a in game.actions if a.startswith("click:")]
assert clicks[:2] == _clicks(AT["start-new-game"], wc.END_TURN) and clicks[-1] == _clicks(wc.END_TURN)[0]
@@ -574,7 +592,8 @@ def _clicks(*points):
def test_start_screen_check_presses_new_game_then_end_turn_and_needs_turn_1(capsys):
game = FakeGame()
actions = game.actions
- check = wc.StartScreenCheck(game, recording=False, hebrew=False, buttons=_buttons(), tail=game.tail, settle=lambda s: None)
+ check = wc.StartScreenCheck(game, recording=False, hebrew=False, buttons=_buttons(), tail=game.tail, units=game.drawn,
+ settle=lambda s: None)
check.feed("GAME OK 1948-05-15 turn 0 hash aa")
assert actions == _clicks(AT["start-new-game"], wc.END_TURN)
assert not check.done
@@ -585,7 +604,8 @@ def test_start_screen_check_presses_new_game_then_end_turn_and_needs_turn_1(caps
def test_start_screen_check_fails_at_once_when_the_game_never_says_where_new_game_is():
- check = wc.StartScreenCheck(lambda a: None, False, False, buttons=_buttons(""), tail=wc.ConsoleTail(), settle=lambda s: None)
+ check = wc.StartScreenCheck(lambda a: None, False, False, buttons=_buttons(""), tail=wc.ConsoleTail(),
+ units=wc.UnitsOnMap(), settle=lambda s: None)
with pytest.raises(ValueError, match="START SCREEN FAIL no centre for start-new-game"):
check.feed("GAME OK 1948-05-15 turn 0 hash aa")
@@ -593,7 +613,8 @@ def test_start_screen_check_fails_at_once_when_the_game_never_says_where_new_gam
def test_start_screen_check_plays_the_recording_first_and_waits_for_it_hebrew_layout():
game = FakeGame()
actions, buttons = game.actions, _buttons()
- check = wc.StartScreenCheck(game, recording=True, hebrew=True, buttons=buttons, tail=game.tail, settle=lambda s: None)
+ check = wc.StartScreenCheck(game, recording=True, hebrew=True, buttons=buttons, tail=game.tail, units=game.drawn,
+ settle=lambda s: None)
check.feed("GAME OK 1948-05-15 turn 0 hash aa")
assert actions == _clicks(AT["start-listen"])
check.feed("TURN 1 1948-06-15 hash bb") # no New game before the recording plays
@@ -615,6 +636,89 @@ def test_start_screen_check_fails_on_a_saved_game_or_a_wrong_turn():
assert not check.done
+def _start(game):
+ return wc.StartScreenCheck(game, recording=False, hebrew=False, buttons=_buttons(), tail=game.tail, units=game.drawn,
+ settle=lambda s: None)
+
+
+def test_start_screen_check_needs_israeli_and_enemy_tokens_on_turns_1_and_2(capsys):
+ """#2056 (owner, 1 November 2026): the player's turn 1 is the new game (sim turn 0, GDD: "the units of turn 1 of a new
+ historical game"), turn 2 the state after the first End turn (TURN 1)."""
+ check = _start(FakeGame())
+ check.feed("GAME OK 1948-05-15 turn 0 hash aa")
+ check.feed("TURN 1 1948-06-15 hash bb")
+ assert check.done
+ out = capsys.readouterr().out
+ assert "UNITS OK turn 1 (New game): israel=10 enemy=2" in out and "UNITS OK turn 2 (after End turn): israel=10 enemy=3" in out
+
+
+def test_the_31_october_build_with_no_enemy_tokens_fails_before_end_turn():
+ """v0.3.1-nightly.20261028: the enemy tokens waited for a side figure that was never requested, so UnitLayer drew
+ Israel's tokens alone."""
+ game = FakeGame(tokens={0: (10, 0), 1: (10, 0)})
+ with pytest.raises(ValueError, match=r"UNITS FAIL turn 1 \(New game\): no enemy unit tokens drawn within .*enemy=0"):
+ _start(game).feed("GAME OK 1948-05-15 turn 0 hash aa")
+ assert game.actions == _clicks(AT["start-new-game"]), "End turn is not pressed"
+
+
+def test_enemy_tokens_gone_on_turn_2_fail():
+ game = FakeGame(tokens={0: (10, 2), 1: (10, 0)})
+ check = _start(game)
+ check.feed("GAME OK 1948-05-15 turn 0 hash aa")
+ with pytest.raises(ValueError, match=r"UNITS FAIL turn 2 \(after End turn\): no enemy unit tokens"):
+ check.feed("TURN 1 1948-06-15 hash bb")
+ assert not check.done
+
+
+def test_no_israeli_tokens_fail():
+ with pytest.raises(ValueError, match="UNITS FAIL turn 1 .*no Israeli unit tokens"):
+ _start(FakeGame(tokens={0: (0, 2)})).feed("GAME OK 1948-05-15 turn 0 hash aa")
+
+
+def test_no_units_line_at_all_fails_and_never_passes():
+ """Fail closed: a build that logs no units line (one from before #2056, or a page without ?navlog) fails."""
+ game = FakeGame(tokens={})
+ with pytest.raises(ValueError, match="UNITS FAIL turn 1 .*no 'units drawn' line .*navlog"):
+ _start(game).feed("GAME OK 1948-05-15 turn 0 hash aa")
+
+
+def test_turn_2_needs_a_line_for_turn_1_not_the_new_games():
+ """The new game's line says nothing of turn 2: a game that logs no line once the turn ends fails."""
+ check = _start(FakeGame(tokens={0: (10, 2)}))
+ check.feed("GAME OK 1948-05-15 turn 0 hash aa")
+ with pytest.raises(ValueError, match="UNITS FAIL turn 2 .*no 'units drawn' line for turn 1 .*the last was .*turn=0"):
+ check.feed("TURN 1 1948-06-15 hash bb")
+
+
+def test_units_on_map_waits_for_a_token_that_arrives_later_and_keeps_the_latest_line():
+ """An enemy token is drawn once its figure streams in (#665): the check waits for it, and reads the latest line."""
+ drawn = wc.UnitsOnMap(wait=5)
+ drawn.feed(units_line(0, 10, 0))
+ threading.Timer(0.05, drawn.feed, [units_line(0, 10, 2)]).start()
+ assert drawn.require(0, "turn 1") == (10, 2)
+ drawn.feed(units_line(0, 10, 0))
+ drawn.wait = 0
+ with pytest.raises(ValueError, match="no enemy unit tokens"):
+ drawn.require(0, "turn 1")
+
+
[email protected]("text", ["NAV f=1 t=1 units drawn turn=0 israel=10", "units drawn turn=0 israel=10 enemy=2",
+ "NAV f=1 t=1 units drawn turn=x israel=10 enemy=2", "NAV f=1 t=1 ui click count=1 target=units"])
+def test_a_line_not_in_the_units_format_is_no_signal(text):
+ drawn = wc.UnitsOnMap(wait=0)
+ drawn.feed(text)
+ with pytest.raises(ValueError, match="no 'units drawn' line"):
+ drawn.require(0, "turn 1")
+
+
[email protected]("mode", ["new", "recording"])
+def test_every_start_screen_run_checks_the_tokens(mode):
+ """run_plan gives the nightly's four start screen passes (both modes, both languages) the units check."""
+ lines = BOOTED_AND_TURNED[:1] + ["RECORDING playing audio/declaration.wav (9.29 s, at 0.20 s)"] * (mode == "recording")
+ with pytest.raises(ValueError, match=r"UNITS FAIL turn 1 \(New game\): no enemy unit tokens"):
+ _run(("--startscreen", mode), lines, game=FakeGame(tokens={0: (10, 0)}))
+
+
def test_query_value():
assert wc.query_value("lang=he&smoke", "lang") == "he"
assert wc.query_value("smoke", "lang") is None
@@ -624,7 +728,8 @@ def test_query_value():
def test_start_screen_check_english_recording_uses_the_english_layout():
game = FakeGame()
actions = game.actions
- check = wc.StartScreenCheck(game, recording=True, hebrew=False, buttons=_buttons(), tail=game.tail, settle=lambda s: None)
+ check = wc.StartScreenCheck(game, recording=True, hebrew=False, buttons=_buttons(), tail=game.tail, units=game.drawn,
+ settle=lambda s: None)
check.feed("GAME OK 1948-05-15 turn 0 hash aa")
check.feed("RECORDING playing audio/declaration.wav (9.29 s, at 0.20 s)")
assert actions == _clicks(AT["start-listen"], AT["start-new-game"], wc.END_TURN)
@@ -634,9 +739,9 @@ def _args(*argv):
return wc.parser().parse_args(["build", *argv])
-def _plan(*argv):
- game = FakeGame()
- driver, fail, plan = wc.run_plan(_args(*argv), game, _buttons(), game.tail)
+def _plan(*argv, game=None):
+ game = game or FakeGame()
+ driver, fail, plan = wc.run_plan(_args(*argv), game, _buttons(), game.tail, game.drawn)
if driver is not None:
driver.settle = driver.end_turn.settle = lambda seconds: None
return driver, fail, plan
@@ -668,9 +773,9 @@ def test_persistence_and_start_screen_are_separate_runs():
_plan("--persistence", "--startscreen", "new")
-def _run(plan_args, lines, late=()):
+def _run(plan_args, lines, late=(), game=None):
"""Feeds `lines` to watch through run_plan's driver; `late` arrive at the first sleep, after them."""
- driver, fail, plan = _plan(*plan_args)
+ driver, fail, plan = _plan(*plan_args, game=game)
inbox = queue.Queue()
for text in lines:
inbox.put(line(text))
diff --git a/tools/web_check.py b/tools/web_check.py
index d246a7d48..89b221fda 100644
--- a/tools/web_check.py
+++ b/tools/web_check.py
@@ -20,8 +20,9 @@ turn and reload as soon as its matching commit arrives; both reloads must report
profile, the real start screen every player sees first: "new" presses New game, "recording" first presses Play the
recording and waits for RECORDING playing; then End turn must log TURN 1, first pressing "Skip the opening" when the
opening (#530) takes End turn's click, then "Skip this turn" on each unit End
-turn selects while units still need orders (EndTurn; --persistence ends its turns so too); any console Exception, RECORDING failed or
-BOOT FAIL fails the run; add --query lang=he for the Hebrew layout). Both runs add ?navlog and click the start screen's
+turn selects while units still need orders (EndTurn; --persistence ends its turns so too); the map must draw Israeli and
+enemy unit tokens on turn 1 (the new game) and turn 2 (after End turn), else UNITS FAIL (#2056, UnitsOnMap); any console
+Exception, RECORDING failed or BOOT FAIL fails the run; add --query lang=he for the Hebrew layout). Both runs add ?navlog and click the start screen's
buttons where its "start buttons" line says they are (StartButtons).
--url URL opens that page (the itch.io game frame) instead of serving a build; --profile DIR keeps that Chrome profile
between runs; --first-save drives --persistence only to its first durable autosave and prints PERSISTENCE saved <date> turn <n> hash <h>.
@@ -485,6 +486,56 @@ class ConsoleTail:
self.cond.wait(left)
+# The tokens the map draws, as Statecraft.Game.Map.Units.UnitLayer logs them under ?navlog (#2056) whenever the drawn
+# tokens change and on each new turn: the state's turn, the Israeli and the enemy (every other side) totals, then each enemy
+# side's count:
+# NAV f=412 t=20311 units drawn turn=0 israel=10 enemy=2 egypt=1 jordan=1
+UNITS_DRAWN = re.compile(r"^NAV f=\d+ t=\d+ units drawn turn=(\d+) israel=(\d+) enemy=(\d+)(?: .*)?$")
+# Seconds the check waits for both sides' tokens: an enemy token is drawn only once its side's figure has streamed in (#665).
+UNITS_WAIT = 60.0
+
+
+class UnitsOnMap:
+ """Owner ruling on #2056 (1 November 2026): a run fails unless the map draws Israeli and enemy unit tokens on turns 1
+ and 2 (the 31 October nightly drew no enemy token: its enemy tokens waited for a figure never requested). Keeps the latest
+ UNITS_DRAWN line, fed from the stderr reader thread (like StartButtons). `require` waits up to `wait` seconds for the
+ latest line to be for the given sim turn with both totals above zero. No such line (a build from before #2056, a page
+ without ?navlog, a line in another format) fails: the check never passes without its signal."""
+
+ def __init__(self, wait: float = UNITS_WAIT):
+ self.wait, self.cond = wait, threading.Condition()
+ self.latest: tuple[int, int, int, str] | None = None # (turn, israel, enemy, the line)
+
+ def feed(self, text: str) -> None:
+ m = UNITS_DRAWN.match(text)
+ if m:
+ with self.cond:
+ self.latest = (int(m.group(1)), int(m.group(2)), int(m.group(3)), text)
+ self.cond.notify_all()
+
+ def require(self, turn: int, what: str) -> tuple[int, int]:
+ """(Israeli, enemy) tokens drawn on sim turn `turn` (the player's `what`); a ValueError naming what is missing."""
+ deadline = time.monotonic() + self.wait
+ with self.cond:
+ while True:
+ latest = self.latest
+ if latest is not None and latest[0] == turn and latest[1] > 0 and latest[2] > 0:
+ print(f"UNITS OK {what}: israel={latest[1]} enemy={latest[2]}")
+ return latest[1], latest[2]
+ left = deadline - time.monotonic()
+ if left <= 0:
+ break
+ self.cond.wait(left)
+ within = f"within {self.wait:g} s"
+ if latest is None:
+ raise ValueError(f"UNITS FAIL {what}: no 'units drawn' line {within} (the page needs ?{NAVLOG}, and a build "
+ f"whose UnitLayer logs it, #2056)")
+ if latest[0] != turn:
+ raise ValueError(f"UNITS FAIL {what}: no 'units drawn' line for turn {turn} {within}; the last was {latest[3]}")
+ missing = " and ".join(name for name, n in (("Israeli", latest[1]), ("enemy", latest[2])) if n == 0)
+ raise ValueError(f"UNITS FAIL {what}: no {missing} unit tokens drawn {within}: {latest[3]}")
+
+
# What ?navlog's NavEventLog says of a press and a click: the deepest UI element under the pointer, by name.
NAV_DOWN = re.compile(r"^NAV f=\d+ t=\d+ ui pointerdown id=\d+ at \([^)]*\) target=(\S+)(?: .*)?$") # NavEventLog adds path= and modals= after target
NAV_CLICK = re.compile(r"^NAV f=\d+ t=\d+ ui click count=\d+ target=(\S+)$")
@@ -766,10 +817,12 @@ def query_value(query: str, key: str) -> str | None:
class StartScreenCheck:
"""Issue #908: the start screen of a fresh profile, as a player meets it (no automation flag skips it). New game
(after Play the recording when `recording`) and End turn (EndTurn: Skip each unit it selects) must reach the map's
- first turn. `action` is Page.command; `buttons` says where the start screen's buttons are; `tail` is the console."""
+ first turn, with Israeli and enemy tokens drawn on the new game (the player's turn 1) and after End turn (turn 2):
+ `units` (#2056). `action` is Page.command; `buttons` says where the start screen's buttons are; `tail` is the console."""
- def __init__(self, action, recording: bool, hebrew: bool, buttons: StartButtons, tail: ConsoleTail, settle=time.sleep):
- self.action, self.recording, self.buttons, self.settle = action, recording, buttons, settle
+ def __init__(self, action, recording: bool, hebrew: bool, buttons: StartButtons, tail: ConsoleTail, units: UnitsOnMap,
+ settle=time.sleep):
+ self.action, self.recording, self.buttons, self.settle, self.units = action, recording, buttons, settle, units
self.end_turn = EndTurn(action, tail, hebrew, settle=settle)
self.stage, self.done = "boot", False
@@ -791,12 +844,14 @@ class StartScreenCheck:
elif self.stage == "turn" and turn:
if int(turn.group(1)) != 1:
raise ValueError(f"START SCREEN FAIL End turn after New game logged turn {turn.group(1)}, not turn 1")
+ self.units.require(1, "turn 2 (after End turn)")
print(f"START SCREEN OK New game reached the map: TURN 1 {turn.group(2)} hash {turn.group(3)}")
self.done = True
def new_game(self) -> None:
self.click(NEW_GAME)
self.settle(2)
+ self.units.require(0, "turn 1 (New game)")
self.stage = "turn"
self.end_turn()
@@ -880,13 +935,14 @@ def page_query(a) -> str:
return f"{a.query}&{NAVLOG}" if a.query else NAVLOG
-def run_plan(a, command, buttons: StartButtons, tail: ConsoleTail):
+def run_plan(a, command, buttons: StartButtons, tail: ConsoleTail, units: UnitsOnMap):
"""What a run drives and fails on: (driver or None, the failure regex, watch's keyword arguments). `command` is
- Page.command; `buttons` and `tail` are fed the console by the caller."""
+ Page.command; `buttons`, `tail` and `units` are fed the console by the caller."""
if (a.persistence or a.first_save) and a.startscreen:
raise ValueError("--persistence and --startscreen are separate runs")
if a.startscreen:
- driver = StartScreenCheck(command, a.startscreen == "recording", query_value(a.query, "lang") == "he", buttons, tail)
+ driver = StartScreenCheck(command, a.startscreen == "recording", query_value(a.query, "lang") == "he", buttons, tail,
+ units)
fail, what = f"(?:{a.fail})|{START_SCREEN_FAILS}", f"the end of the --startscreen {a.startscreen} run"
elif a.persistence or a.first_save:
driver = PersistenceCheck(command, buttons, tail, first_save_only=a.first_save)
@@ -956,7 +1012,7 @@ def main() -> int:
profile, own_profile = pick_profile(a)
res = expected_res(w, h, a.dpr)
shots = ShotCollector(a.shots, size=(round(w * a.dpr), round(h * a.dpr)))
- buttons, tail = StartButtons((w, h)), ConsoleTail()
+ buttons, tail, units = StartButtons((w, h)), ConsoleTail(), UnitsOnMap()
def on_text(text: str) -> bool:
err = res_error(text, res)
@@ -983,6 +1039,7 @@ def main() -> int:
if console:
buttons.feed(console.group(1)) # here, not in watch: a driver waiting in settle() sees it
tail.feed(console.group(1)) # and one waiting for the game's answer to its click
+ units.feed(console.group(1)) # and one waiting for the map's tokens
inbox.put(line)
for line in rejoin.flush():
inbox.put(line)
@@ -992,7 +1049,7 @@ def main() -> int:
page = Page(profile, url, w, h, a.dpr, a.mobile)
page.open()
print(f"viewport {w}x{h} at DPR {a.dpr:g}{' mobile' if a.mobile else ''} (expect res={res})")
- driver, fail, plan = run_plan(a, page.command, buttons, tail)
+ driver, fail, plan = run_plan(a, page.command, buttons, tail, units)
def handle_text(text: str) -> bool:
consumed = on_text(text)
diff --git a/unity/Assets/Scripts/Map/Units/UnitLayer.cs b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
index e57b1373b..a3abae661 100644
--- a/unity/Assets/Scripts/Map/Units/UnitLayer.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
@@ -351,7 +351,12 @@ namespace Statecraft.Game.Map.Units
// An Arab force's token waits while its figure loads, and is drawn with the plain built-in figure if it failed.
now = now.Where(t => t.Unit.Side == UnitData.Israel || UnitFigures.Arrived(UnitFigures.SideFigure(t.Unit.Side)!)
|| UnitFigures.Failed(UnitFigures.SideFigure(t.Unit.Side)!)).ToList();
- if (roster != null && roster.SequenceEqual(now)) { seenAvailability = UnitFigures.AvailabilityVersion; return false; }
+ if (roster != null && roster.SequenceEqual(now))
+ {
+ seenAvailability = UnitFigures.AvailabilityVersion;
+ LogDrawn(state.Turn, rebuilt: false);
+ return false;
+ }
roster = now;
PlaceMoved(now);
placed = UnitPlacer.Place(now, drawSpots ?? DisplaySpots);
@@ -359,9 +364,29 @@ namespace Statecraft.Game.Map.Units
ScheduleSatisfiedPrefetchRetirement();
if (Selected != null && !placed.Any(p => p.Token.Unit.Id == Selected)) Select(null); else Select(Selected);
seenAvailability = UnitFigures.AvailabilityVersion;
+ LogDrawn(state.Turn, rebuilt: true);
return true;
}
+ /// <summary>The turn of the last "units drawn" line (null before the first).</summary>
+ int? loggedTurn;
+
+ /// <summary>Under ?navlog (DiagLog.Nav), the tokens drawn now, whenever they change and on each new turn: the state's
+ /// turn, the Israeli and the enemy (every other side) totals, then each enemy side's count, e.g.
+ /// "NAV f=412 t=20311 units drawn turn=0 israel=10 enemy=2 egypt=1 jordan=1". tools/web_check.py's start screen runs
+ /// fail without Israeli and enemy tokens on turns 1 and 2 (owner ruling on #2056, 1 November 2026).</summary>
+ void LogDrawn(int turn, bool rebuilt)
+ {
+ if (!Boot.DiagLog.Nav || (!rebuilt && loggedTurn == turn)) return;
+ loggedTurn = turn;
+ int israel = placed.Count(p => p.Token.Unit.Side == UnitData.Israel);
+ var sides = placed.Where(p => p.Token.Unit.Side != UnitData.Israel).GroupBy(p => p.Token.Unit.Side)
+ .OrderBy(g => g.Key, StringComparer.Ordinal)
+ .Select(g => FormattableString.Invariant($" {g.Key}={g.Count()}"));
+ Boot.DiagLog.NavLine(FormattableString.Invariant(
+ $"units drawn turn={turn} israel={israel} enemy={placed.Count - israel}{string.Concat(sides)}"));
+ }
+
float DisplayReach(AnchorSpot spot) => Mathf.Max(ground.RingRadius(spot.Compact),
UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3),
UnitShowcase.DrawSpread * ground.HexSizeM * Scale(spot))) * UnitPlinth.RimOuter);
diff --git a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs b/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
index f603bf113..9a1806718 100644
--- a/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitFiguresTests.cs
@@ -593,6 +593,61 @@ public class UnitFiguresTests
finally { UnityEngine.Object.DestroyImmediate(map.gameObject); }
}
+ /// <summary>#2056 (owner, 1 November 2026): tools/web_check.py fails a run without Israeli and enemy tokens on turns 1
+ /// and 2. Under ?navlog the layer logs the tokens it draws, per side, whenever they change and on each new turn; the
+ /// 31 October build (enemy tokens waiting for a figure never requested) logs enemy=0 until a figure arrives.</summary>
+ [Test]
+ public void UnderNavlogItLogsTheDrawnTokensOfEachSideWhenTheyChangeAndOnEachTurn()
+ {
+ var map = BuildMap(); var asked = new Dictionary<string, Action<GameObject>>();
+ UnitFigures.Source = (id, detail, done) => asked[id] = done;
+ var wasNav = Statecraft.Game.Boot.DiagLog.Nav;
+ var logged = new List<string>();
+ void Capture(string message, string trace, LogType type) { if (message.Contains(" units drawn ")) logged.Add(message); }
+ Application.logMessageReceived += Capture;
+ try
+ {
+ var content = ContentLoader.Load(Paths.Content); Assert.IsTrue(content.IsGdd);
+ var state = Simulation.NewGame(content, GoldenRun.Seed, Mode.Historical);
+ Statecraft.Game.Boot.DiagLog.Nav = true;
+ var layer = UnitLayer.Create(map, Units, content.Hexes, still: true); layer.Show(content, state);
+ string Expected(int turn)
+ {
+ int israel = layer.Tokens.Count(t => t.Token.Unit.Side == UnitData.Israel);
+ var sides = layer.Tokens.Where(t => t.Token.Unit.Side != UnitData.Israel).GroupBy(t => t.Token.Unit.Side)
+ .OrderBy(g => g.Key, StringComparer.Ordinal).Select(g => $" {g.Key}={g.Count()}");
+ return $"units drawn turn={turn} israel={israel} enemy={layer.Tokens.Count - israel}{string.Concat(sides)}";
+ }
+ // The first Show can be re-entered from inside its Rebuild (seen: two identical turn=0 lines 1 ms apart); the
+ // latest line is what web_check reads.
+ Assert.IsNotEmpty(logged);
+ StringAssert.IsMatch(@"^NAV f=\d+ t=\d+ units drawn turn=0 israel=[1-9]\d* enemy=0$", logged[^1], "no figure has arrived");
+ int first = logged.Count;
+ layer.Show(content, state);
+ Assert.AreEqual(first, logged.Count, "the same tokens on the same turn log nothing");
+ var sideFigures = UnitData.Sides.Where(side => side != UnitData.Israel).Select(UnitFigures.SideFigure)
+ .Where(id => id != null && asked.ContainsKey(id)).Distinct().ToList();
+ Assert.IsNotEmpty(sideFigures, "the new game's enemy forces ask for their figures");
+ foreach (var id in sideFigures) asked[id!](Prefab(id!));
+ Assert.Greater(layer.Tokens.Count(t => t.Token.Unit.Side != UnitData.Israel), 0, "precondition: enemy tokens drawn");
+ Assert.Greater(logged.Count, 1, "the arrival rebuilt the tokens and logged them");
+ StringAssert.EndsWith(Expected(0), logged[^1]);
+ var next = state.Clone(); next.Turn = 1;
+ layer.Show(content, next);
+ StringAssert.EndsWith(Expected(1), logged[^1], "a new turn logs the tokens again, changed or not");
+ int count = logged.Count;
+ Statecraft.Game.Boot.DiagLog.Nav = false;
+ var later = next.Clone(); later.Turn = 2;
+ layer.Show(content, later);
+ Assert.AreEqual(count, logged.Count, "without ?navlog nothing is logged");
+ }
+ finally
+ {
+ Application.logMessageReceived -= Capture; Statecraft.Game.Boot.DiagLog.Nav = wasNav;
+ UnityEngine.Object.DestroyImmediate(map.gameObject);
+ }
+ }
+
/// <summary>A model that arrives after its token was rebuilt or destroyed is dropped quietly, and the showcase trio is
/// dressed by headgear too (C04, C06, C07).</summary>
[Test]