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.

tools: web_check presses the raid card after the raid flight (Refs #3003) (#3099)

Eyal Golana562443301af
diff --git a/tools/tests/test_web_check.py b/tools/tests/test_web_check.py
index 58aa6023d..c336b7201 100644
--- a/tools/tests/test_web_check.py
+++ b/tools/tests/test_web_check.py
@@ -299,10 +299,13 @@ class FakeGame:
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, tokens=None):
+ def __init__(self, units=0, card=None, hebrew=False, answers=True, opening=None, tokens=None, raid=None, flight=True):
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
+ # #3003: the raid card's layout once the opening is gone, until its OK; with `flight`, the raid flight's clear layer
+ # (#3000) covers the window first, and any press on it ends the flight and shows the card (RaidFlightPresenter).
+ self.raid, self.flight = raid, flight and raid is not None
self.tokens = {0: (10, 2), 1: (10, 3)} if tokens is None else tokens
self.drawn = wc.UnitsOnMap(wait=0.05)
self.draw(0)
@@ -319,6 +322,10 @@ class FakeGame:
if self.opening is not None:
return next((name for (x0, x1, y0, y1), name in self.opening if x0 <= x <= x1 and y0 <= y <= y1),
"opening-card" if 440 <= x <= 1480 else "opening-layer")
+ if self.flight:
+ return "raid-flight-layer"
+ if self.raid is not None:
+ return next((name for (x0, x1, y0, y1), name in self.raid if x0 <= x <= x1 and y0 <= y <= y1), "raid-layer")
if self.hebrew:
x = wc.INFO_PANEL_LEFT + wc.INFO_PANEL_RIGHT - x
inside = wc.INFO_PANEL_LEFT <= x <= wc.INFO_PANEL_RIGHT and y >= 1080 - wc.INFO_PANEL_BOTTOM - wc.INFO_PANEL_MAX_HEIGHT
@@ -336,6 +343,18 @@ class FakeGame:
self.nav(f"ui click count=1 target={target}")
if target == "opening-skip":
self.opening = None
+ elif self.flight and self.opening is None: # a press ends the flight and shows the card, which takes the release
+ self.flight = False
+ self.nav(f"ui pointerdown id=0 at ({x}, {y}) target=raid-flight-layer path=raid-flight-layer.raid-flight-layer "
+ f"< root.event-open.raid-flight-open.root modals=-")
+ if kind == "click": # the 0.4.1 nightly's trace: the click goes to their common ancestor
+ self.nav(f"ui pointerup id=0 at ({x}, {y}) target=raid-layer")
+ self.nav("ui click count=1 target=root")
+ elif kind == "click" and self.raid is not None: # the card takes every click while it shows
+ target = self.at(x, y)
+ self.nav(f"ui click count=1 target={target}")
+ if target == "raid-ok":
+ self.raid = None
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:
@@ -369,6 +388,11 @@ HE_OPENING = [((800, 948, 582, 628), "opening-skip"), ((966, 1028, 582, 628), "o
((1040, 1102, 582, 628), "opening-back"), ((794, 1108, 578, 632), "VisualElement")]
FAR_OPENING = [((900, 1000, 560, 600), "opening-next"), ((1100, 1200, 560, 600), "opening-skip")]
NO_SKIP_OPENING = [((900, 1000, 560, 600), "opening-next")]
+# The raid card (#3003) at 1920x1080: the opening's card frame centred over a dim backdrop (Statecraft.uss .raid-layer), its
+# title, clip and scrolling text over one centred row with only OK (Game.uxml .raid-actions, min-width 160 px).
+EN_RAID = [((880, 1040, 900, 944), "raid-ok"), ((700, 1220, 560, 890), "raid-text"), ((700, 1220, 150, 550), "raid-media"),
+ ((690, 1230, 120, 960), "raid-card")]
+NO_OK_RAID = [((700, 1220, 560, 890), "raid-text"), ((690, 1230, 120, 960), "raid-card")]
NO_SKIP_CARD = [((84, 536, 1010, 1064), "info-reason"), ((96, 180, 976, 1002), "info-move"), ((84, 536, 960, 1009), "VisualElement")]
@@ -473,6 +497,98 @@ def test_start_screen_check_skips_the_opening_after_new_game():
assert check.done
[email protected]("hebrew,layout", [(False, EN_OPENING), (True, HE_OPENING)])
+def test_end_turn_answers_the_raid_flight_and_card_after_the_opening_as_a_player_does(hebrew, layout, capsys):
+ """#3003: after the opening's Skip the raid flight's clear layer covers End turn. End turn's press ends the flight and
+ shows the raid card, which takes the release, so the click reaches root (the 0.4.1 nightly's pass 3). EndTurn presses
+ the card's OK, found with middle-button probes, then End turn again."""
+ game = FakeGame(hebrew=hebrew, opening=layout, raid=EN_RAID)
+ end_turn = wc.END_TURN_HE if hebrew else wc.END_TURN
+ assert _end_turn(game)() == 0 and game.opening is None and game.raid is None and not game.flight
+ clicks = [a for a in game.actions if a.startswith("click:")]
+ assert len(clicks) == 5 and clicks[0] == clicks[2] == clicks[4] == _clicks(end_turn)[0], \
+ "End turn, the opening's Skip, End turn (the flight takes it), OK, End turn"
+ x, y = (int(v) for v in clicks[3].split(":")[1].split(","))
+ assert next(name for (x0, x1, y0, y1), name in EN_RAID if x0 <= x <= x1 and y0 <= y <= y1) == "raid-ok"
+ assert game.tail.wait(wc.TURN_STATE, 0, 0) is not None
+ out = capsys.readouterr().out
+ assert "the click reached root (pressed raid-flight-layer)" in out and f"click raid-ok at ({x}, {y})" in out
+
+
+def test_end_turn_presses_ok_on_a_raid_card_shown_without_the_flight():
+ """With no flight (no Dakota to fly, or the flight already over) the card itself takes End turn's click."""
+ game = FakeGame(raid=EN_RAID, flight=False)
+ assert _end_turn(game)() == 0 and game.raid is None
+ clicks = [a for a in game.actions if a.startswith("click:")]
+ assert len(clicks) == 3 and clicks[0] == clicks[2] == _clicks(wc.END_TURN)[0], "End turn, OK, End turn"
+
+
+def test_end_turn_fails_on_a_raid_card_without_ok():
+ with pytest.raises(ValueError, match="RAID FAIL the raid card covers End turn, but no raid-ok"):
+ _end_turn(FakeGame(opening=EN_OPENING, raid=NO_OK_RAID))()
+
+
+def test_end_turn_fails_when_the_raid_card_is_still_there_after_ok():
+ game = FakeGame(raid=EN_RAID)
+
+ def stuck(action): # OK is pressed, but the card stays over End turn
+ layout = game.raid
+ game(action)
+ game.raid = layout
+ with pytest.raises(ValueError, match="END TURN FAIL the click at \\(1840, 45\\) did not press end-turn .*reached raid-layer"):
+ wc.EndTurn(stuck, game.tail, False, settle=lambda s: None, answer=0.05, turn_wait=0.05)()
+
+
+def test_end_turn_still_fails_a_click_that_reaches_root_off_the_raid_flight():
+ """Only a press the raid flight took explains a click that reached root; any other still fails."""
+ game = FakeGame()
+
+ def elsewhere(action):
+ game.actions.append(action)
+ game.nav("ui pointerdown id=0 at (1840, 45) target=top-bar path=top-bar < root.root modals=-")
+ game.nav("ui click count=1 target=root")
+ with pytest.raises(ValueError, match="END TURN FAIL the click at \\(1840, 45\\) did not press end-turn .*reached root\\)"):
+ wc.EndTurn(elsewhere, game.tail, False, settle=lambda s: None, answer=0.05, turn_wait=0.05)()
+
+
+def test_click_end_turn_told_no_raid_fails_on_the_raid_flight():
+ with pytest.raises(ValueError, match="END TURN FAIL the click at \\(1840, 45\\) did not press end-turn .*reached root"):
+ _end_turn(FakeGame(raid=EN_RAID)).click_end_turn(opening=False)
+
+
[email protected]("flight,reached", [(True, "root"), (False, "raid-layer")])
+def test_end_turn_answers_the_raid_only_on_its_first_turn(flight, reached):
+ """The game plays the raid only on New game (GameRoot.PlayNewGameIntro: "Never on Continue or a load"). One EndTurn
+ answers it on its first End turn; a raid on any later call of the same EndTurn (PersistenceCheck's End turn after
+ Continue) still fails."""
+ game = FakeGame(raid=EN_RAID, flight=flight)
+ end_turn = _end_turn(game)
+ assert end_turn() == 0 and game.raid is None
+ game.raid, game.flight = EN_RAID, flight # the raid shows again before the next End turn
+ missed = f"END TURN FAIL the click at \\(1840, 45\\) did not press end-turn .*reached {reached}\\)"
+ with pytest.raises(ValueError, match=missed):
+ end_turn()
+ assert game.raid is not None, "the second raid's OK was not pressed"
+
+
+def test_persistence_check_answers_the_raid_after_new_game_but_fails_one_after_continue():
+ """#3003 on the --persistence run: the raid after New game is answered; one replayed after Continue must fail."""
+ game = FakeGame()
+ new_game, cont = _clicks(AT["start-new-game"], AT["start-continue"])
+
+ def player(action):
+ game(action)
+ if action in (new_game, cont): # the raid flight covers the window once the map shows
+ game.raid, game.flight = EN_RAID, True
+ check = wc.PersistenceCheck(player, _buttons(), game.tail, lambda seconds: None)
+ _played_to_the_settled_reload(check)
+ assert game.raid is None, "the raid after New game was answered"
+ check.buttons.feed(LAID_OUT) # the reloaded page reports its own layout
+ missed = "END TURN FAIL the click at \\(1840, 45\\) did not press end-turn .*reached root\\)"
+ with pytest.raises(ValueError, match=missed):
+ check.feed("GAME OK 1948-06-15 turn 1 hash bb")
+
+
def test_a_click_that_does_not_press_skip_fails():
game = FakeGame(units=1)
probe_at = game.at
diff --git a/tools/web_check.py b/tools/web_check.py
index 6c2757d78..2cb1e76d8 100644
--- a/tools/web_check.py
+++ b/tools/web_check.py
@@ -600,6 +600,12 @@ SKIP = "info-skip"
# apart (a button is wider than that, the row's gaps narrower) to the row, then along it.
OPENING, OPENING_SKIP = "opening-", "opening-skip"
OPENING_ROW = {"opening-back", "opening-next", OPENING_SKIP}
+# The raid (#3003): after the opening, once raid-intro.yaml is reviewed, a player build with video on (CardVideo.ForcedOff)
+# flies the raid over a clear layer that covers the whole window (Statecraft.uss .raid-flight-layer; top bar hidden), then
+# shows the raid card (.raid-layer) until its only button, OK. Any press on the flight ends it and shows the card in that
+# same press (RaidFlightPresenter), so the card takes the release and End turn's click reaches their common ancestor, root
+# (the 0.4.1 nightly's pass 3, 11 Nov 2026). OK sits centred under the card's scrolling text, so it is found like Skip.
+RAID, RAID_FLIGHT, RAID_OK = "raid-", "raid-flight-layer", "raid-ok"
# Well over the units a turn has needing orders (8 on a new game, 9 on turn 2, 0.3.0 RC): a turn that never ends fails.
MAX_SKIPS = 40
@@ -610,9 +616,10 @@ class EndTurn:
most `max_skips` times (GameRoot.Smoke's loop, through the browser). The unit card's buttons move with its text, so
Skip is found where the game draws it: a middle-button probe reports the element under it (?navlog NAV_DOWN) and acts
on nothing (a left press on the card's text can move the unit, NAV_MAP), then a left click presses Skip. When the
- opening (#530) takes the first End turn click, its own Skip is pressed the same way and End turn clicked again. A
- missed End turn, a probe the map takes, a card or an opening with no Skip, or a turn that never ends fails at once.
- Returns the number of units Skipped."""
+ opening (#530) takes the first End turn click, its own Skip is pressed the same way and End turn clicked again; so is
+ the raid card's OK when the raid flight or card (#3003) takes it, on this EndTurn's first call only. A missed End
+ turn, a probe the map takes, a card or an opening with no Skip, a raid card with no OK, a raid on a later call, or a
+ turn that never ends fails at once. Returns the number of units Skipped."""
def __init__(self, action, tail: ConsoleTail, hebrew: bool, settle=time.sleep, max_skips=MAX_SKIPS, answer=5.0,
turn_wait=3.0, viewport=VIEWPORT):
@@ -621,10 +628,15 @@ class EndTurn:
self.point = END_TURN_HE if hebrew else END_TURN
self.viewport, self.bottom = viewport, viewport[1] - INFO_PANEL_BOTTOM
self.skip_at: tuple[int, int] | None = None # where Skip was last: cards of one kind keep it there
+ # The raid plays only on New game (GameRoot.PlayNewGameIntro: never on Continue or a load), and each driver's
+ # first End turn follows New game: so only this EndTurn's first call may answer it, once; a later raid fails.
+ self.raid_due = True
def __call__(self) -> int:
+ raid, self.raid_due = self.raid_due, False
for skips in range(self.max_skips + 1):
- since = self.click_end_turn(opening=skips == 0) # the opening shows only before a new game's first turn
+ since = self.click_end_turn(opening=skips == 0, # the opening shows only before a new game's first turn
+ raid=raid and skips == 0)
if self.tail.wait(TURN_STATE, since, self.turn_wait) is not None:
print(f"END TURN the turn ended after {skips} Skip(s)")
return skips
@@ -636,9 +648,11 @@ class EndTurn:
return skips
raise ValueError(f"END TURN FAIL End turn still selected a unit needing orders after {self.max_skips} Skips")
- def click_end_turn(self, opening: bool) -> int:
+ def click_end_turn(self, opening: bool, raid: bool | None = None) -> int:
"""Clicks End turn; the console mark before the click that pressed it. With `opening`, a click the opening takes is
- answered as a player does: its Skip (skip_opening), then End turn again."""
+ answered as a player does: its Skip (skip_opening), then End turn again. With `raid` (as `opening` unless given),
+ so is a click the raid flight or card takes: the card's OK (press_raid_ok), then End turn again."""
+ raid = opening if raid is None else raid
x, y = self.point
since = self.tail.mark()
print(f"click end-turn at ({x}, {y})")
@@ -650,34 +664,51 @@ class EndTurn:
if opening and other is not None and other.group(1).startswith(OPENING):
print(f"END TURN the click reached {other.group(1)}: the opening covers End turn, so press its Skip")
self.skip_opening()
+ self.settle(1) # the top bar shows again, or the raid flight covers it
+ return self.click_end_turn(opening=False, raid=raid)
+ down = self.tail.wait(NAV_DOWN, since, 0) # the press of this click: the flight's layer when the flight took it
+ flew = down is not None and down.group(1) == RAID_FLIGHT
+ if raid and other is not None and (flew or other.group(1).startswith(RAID)):
+ pressed = f" (pressed {RAID_FLIGHT})" if flew else ""
+ print(f"END TURN the click reached {other.group(1)}{pressed}: the raid covers End turn, so press the card's OK")
+ self.settle(1) # the card lays out
+ self.press_raid_ok()
self.settle(1) # the top bar shows again
- return self.click_end_turn(opening=False)
+ return self.click_end_turn(opening=False, raid=False)
raise ValueError(f"END TURN FAIL the click at ({x}, {y}) did not press end-turn within {self.answer:g} s{reached}")
def skip_opening(self) -> None:
"""Presses the opening's Skip where the game draws it (OPENING_ROW), found with middle-button probes."""
+ self.press_covering(OPENING_ROW, OPENING_SKIP, "OPENING", "the opening")
+
+ def press_raid_ok(self) -> None:
+ """Presses the raid card's OK where the game draws it, found with middle-button probes."""
+ self.press_covering({RAID_OK}, RAID_OK, "RAID", "the raid card")
+
+ def press_covering(self, row_names: set[str], button: str, what: str, cover: str) -> None:
+ """Presses `button` of a centred row of `row_names` on a layer that covers End turn: down two columns 30 px apart
+ to the row, then along it."""
cx, seen, row = self.viewport[0] // 2, [], None
for y in range(PROBE_INSET, self.viewport[1] - PROBE_INSET, 10):
for x in (cx, cx - 30):
target = self.press(x, y)
seen.append(target)
- if target in OPENING_ROW:
+ if target in row_names:
row = (x, y)
break
if row is not None:
break
points = [] if row is None else [row] + [(x, row[1]) for dx in range(10, cx, 10) for x in (cx + dx, cx - dx)]
for x, y in points:
- if (target := self.press(x, y)) == OPENING_SKIP:
+ if (target := self.press(x, y)) == button:
since = self.tail.mark()
- print(f"click {OPENING_SKIP} at ({x}, {y})")
+ print(f"click {button} at ({x}, {y})")
self.action(f"click:{x},{y}")
- if self.tail.wait(NAV_CLICK, since, self.answer, OPENING_SKIP) is None:
- raise ValueError(f"OPENING FAIL the click at ({x}, {y}) did not press {OPENING_SKIP} within "
- f"{self.answer:g} s")
+ if self.tail.wait(NAV_CLICK, since, self.answer, button) is None:
+ raise ValueError(f"{what} FAIL the click at ({x}, {y}) did not press {button} within {self.answer:g} s")
return
seen.append(target)
- raise ValueError(f"OPENING FAIL the opening covers End turn, but no {OPENING_SKIP} was found (its row at y "
+ raise ValueError(f"{what} FAIL {cover} covers End turn, but no {button} was found (its row at y "
f"{row[1] if row else 'none'}; pressed {', '.join(dict.fromkeys(seen))})")
def skip(self, since: int) -> bool: