A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Tools: headed.py derives the start screen's New game click per language (Refs #3003) (#3051)
Eyal Golan86afdb66bc48
diff --git a/tools/headed.py b/tools/headed.pyindex 83536e1ae..601855c75 100644--- a/tools/headed.py+++ b/tools/headed.py@@ -60,9 +60,43 @@ def left_column_button(index: int, window: tuple[int, int] = WINDOW) -> tuple[inWHY = left_column_button(3) # Why? moved from the top bar to the left icon column (#602)+# The start screen's bottom stack and action row in panel units, from Statecraft.uss: the body's 28 px bottom padding, the+# panel's 1 px border and 20 px bottom padding, the community row (40 px high, 8 px above it); a .start-button is 300 px+# wide (min-width) and 50 px high with 10 px and 4 px margins.+START_PANEL_BOTTOM, START_BUTTON = 28 + 1 + 20 + 40 + 8, (300 + 2 * 10, 50 + 2 * 4)+# The action row a fresh profile shows: no save, so no Continue; the reviewed opening's replay; Star on GitHub (#1168).+START_ROW = ("start-new-game", "start-opening-replay", "start-star")+++def start_new_game_button(lang: str = "en", window: tuple[int, int] = WINDOW) -> tuple[int, int]:+ """The centre of the start screen's New game in CSS pixels, from Statecraft.uss (refs #3003): the panel sits at the+ bottom of the window (a wide window, so no .start-band), its action row centred and START_ROW's buttons all+ START_BUTTON wide; in Hebrew (?lang=he) the row runs right to left (.lang-he .start-actions: row-reverse), so New game+ is mirrored about the centre. Scaled as left_column_button. A headed capture on 10 Nov 2026 at 0be35a517 (main+ 59fdd6924 plus #3003) measured (541, 657) and (1026, 657); this gives (543, 657) and (1025, 657) (Star on GitHub's label+ and signs make it a few px wider than 300 in English)."""+ if lang not in ("en", "he"):+ raise ValueError(f"no start screen layout for lang={lang!r}")+ w, h = window+ scale = ((w / 1920) * (h / 1080)) ** 0.5+ bw, bh = START_BUTTON+ offset = (START_ROW.index("start-new-game") + 0.5 - len(START_ROW) / 2) * bw # from the row's centre+ if lang == "he":+ offset = -offset+ return round(w / 2 + offset * scale), round(h - (START_PANEL_BOTTOM + bh / 2) * scale)+++def query_lang(query: str) -> str:+ """The UI language a page query asks for (UiLanguage: ?lang=he), English without one."""+ return "he" if "lang=he" in query.split("&") else "en"++# For `wheel`, in a fixed 1568x752 CSS viewport (Playwright's, from the #43 browser runs): START_NEW, the start screen's-# New Game button; MAP, open map clear of the HUD; PANEL, the End Turn button in the top bar.-WHEEL_VIEWPORT, START_NEW, MAP, PANEL = (1568, 752), (784, 693), (300, 400), (1500, 44)+# New Game button (START_NEW_BY_LANG for a ?lang=he page); MAP, open map clear of the HUD; PANEL, the End Turn button in+# the top bar.+WHEEL_VIEWPORT, MAP, PANEL = (1568, 752), (300, 400), (1500, 44)+START_NEW_BY_LANG = {lang: start_new_game_button(lang, WHEEL_VIEWPORT) for lang in ("en", "he")}+START_NEW = START_NEW_BY_LANG["en"]def pad_swipe() -> list[float]:@@ -430,10 +464,11 @@ async def wheel(args):results = {}for label, steps in WHEEL_CASES:async with Browser(args.build, viewport=WHEEL_VIEWPORT) as b:- sid = await b.open("camlog", init_script=WHEEL_SEEN_SCRIPT)+ query = "camlog"+ sid = await b.open(query, init_script=WHEEL_SEEN_SCRIPT)await b.wait_for(sid, r"^GAME OK")await asyncio.sleep(3)- await b.click(sid, *START_NEW)+ await b.click(sid, *START_NEW_BY_LANG[query_lang(query)])await b.wait_for(sid, r"^CAMERA ")await asyncio.sleep(2)out = []diff --git a/tools/tests/test_headed.py b/tools/tests/test_headed.pyindex cffeb422b..343789fa1 100644--- a/tools/tests/test_headed.py+++ b/tools/tests/test_headed.py@@ -233,3 +233,40 @@ def test_profile_exits_1_on_a_partial_profile_and_0_on_a_whole_one(monkeypatch,FakeBrowser.waits, FakeBrowser.console = ["PROFILE visual done"], list(lines)assert headed.main(["profile", "--build", str(tmp_path)]) == codeassert ("FAIL" in capsys.readouterr().out) == (code == 1)+++def test_new_game_is_clicked_where_the_start_screen_puts_it_in_each_language():+ """The start screen's New game in the 1568x752 playtest window, derived from Statecraft.uss (refs #3003). A headed+ capture on 10 Nov 2026 at 0be35a517 (main 59fdd6924 plus #3003) found it at (541, 657) in English and (1026, 657) in+ Hebrew (?lang=he, the action row mirrored); the old (784, 693) missed it. The derivation agrees within 2 px."""+ for lang, measured in (("en", (541, 657)), ("he", (1026, 657))):+ x, y = headed.start_new_game_button(lang)+ assert abs(x - measured[0]) <= 3 and abs(y - measured[1]) <= 3, (lang, (x, y))+ assert headed.start_new_game_button("en") == (543, 657)+ assert headed.start_new_game_button("he") == (1025, 657)+ assert headed.START_NEW == headed.start_new_game_button("en")+ assert headed.query_lang("camlog") == "en" and headed.query_lang("camlog&lang=he") == "he"+ with pytest.raises(ValueError):+ headed.start_new_game_button("ro")+++def test_the_new_game_derivation_reads_the_uss_numbers():+ """Fails when Statecraft.uss moves the start panel's bottom stack or resizes its buttons and headed.py does not follow."""+ import re+ uss = (Path(headed.REPO) / "unity/Assets/UI/Statecraft.uss").read_text()++ def rule(selector):+ m = re.search(r"(?m)^" + re.escape(selector) + r"\s*\{([^}]*)\}", uss)+ assert m, selector+ return m.group(1)++ assert re.search(r"padding:\s*0 16px 28px 16px", rule(".start-body"))+ assert re.search(r"padding:\s*18px 40px 20px 40px", rule(".start-panel"))+ assert re.search(r"border-width:\s*1px", rule(".panel"))+ community = rule(".start-community")+ assert re.search(r"height:\s*40px", community) and re.search(r"margin-top:\s*8px", community)+ button = rule(".start-button")+ assert re.search(r"min-width:\s*300px", button) and re.search(r"height:\s*50px", button)+ assert re.search(r"margin:\s*4px 10px", button)+ assert re.search(r"\.start-actions, \.lang-he \.start-community \{ flex-direction: row-reverse", uss)+ assert headed.START_PANEL_BOTTOM == 28 + 1 + 20 + 40 + 8 and headed.START_BUTTON == (300 + 2 * 10, 50 + 2 * 4)