fix: handle unexpected modal dialog during shop target selection to prevent false unavailability reports
This commit is contained in:
parent
80c1a645b8
commit
b8b25541b7
File diff suppressed because one or more lines are too long
@ -283,13 +283,46 @@ def select_targets_by_name(driver, config, targets):
|
||||
re-reads every cell fresh, so a reflow can't leave a stale match
|
||||
unnoticed. Scrolling only happens once a full pass finds nothing left
|
||||
to buy on the current screen.
|
||||
|
||||
**Real live false-unavailable, 2026-09-22**: a real cron run logged all
|
||||
8 targets as "not found available" within 3 seconds of opening the tab
|
||||
-- far too fast for a real multi-row OCR scan, and a stark outlier
|
||||
against every other run's 5-10+ second scan time. Root-caused live by
|
||||
reproducing the same account state interactively: an in-game "network
|
||||
access problem" dialog (a real, first-party modal, distinct from
|
||||
anything this project's own code triggers) can appear over the shop
|
||||
grid at essentially any point -- confirmed live when one appeared while
|
||||
manually replaying this exact function's own logic step by step. Once
|
||||
up, it dims the whole grid behind it, so every fixed-offset OCR/color
|
||||
read comes back empty or garbled, and a STATIC dialog doesn't animate
|
||||
frame to frame -- so the very next iteration's "screenshot unchanged"
|
||||
check fires almost immediately, misreporting every remaining target as
|
||||
genuinely unavailable in a couple of seconds flat, exactly matching the
|
||||
live log. Fixed by checking `navigation.is_modal_open` (the same
|
||||
screen-dimming probe used throughout this project, e.g.
|
||||
`navigation.return_to_home`'s own `_not_home` check) at the top of each
|
||||
scan pass, before trusting anything read from that frame. Deliberately
|
||||
does NOT try to dismiss the dialog itself: this specific dialog's own
|
||||
"OK" button logs all the way out to the title screen, and a different
|
||||
unrecognized modal could hide something worse (e.g. a real-currency
|
||||
confirm) -- guessing a keypress here trades a loud, honest stop for a
|
||||
silent misreport, or worse, an unintended action. Skipped targets get a
|
||||
distinct 'blocked_by_modal' reason instead of the normal "not found
|
||||
available", so a run cut short this way is never confused with the
|
||||
genuinely-benign sold-out/escalated-price case in the log or by anyone
|
||||
reading it later.
|
||||
"""
|
||||
remaining = {name: price for name, price in targets}
|
||||
selected = []
|
||||
prev_shot = None
|
||||
blocked_by_modal = False
|
||||
for _ in range(config.SHOP_NAME_SCAN_MAX_STEPS):
|
||||
if not remaining:
|
||||
break
|
||||
if navigation.is_modal_open(driver):
|
||||
print("[shop] an unexpected dialog is covering the shop grid -- stopping scan rather than reading a blocked frame as 'nothing available' (not dismissed automatically: this project doesn't guess how to close an unrecognized modal, since the wrong keypress here can log out or spend real currency)")
|
||||
blocked_by_modal = True
|
||||
break
|
||||
shot = driver.read_screenshot(detector.OCR_SHOT_PATH)
|
||||
if prev_shot is not None and (shot == prev_shot).all():
|
||||
print("[shop] grid stopped scrolling -- reached the real bottom of the list")
|
||||
@ -310,6 +343,10 @@ def select_targets_by_name(driver, config, targets):
|
||||
break
|
||||
skipped = []
|
||||
for name in remaining:
|
||||
if blocked_by_modal:
|
||||
print(f"[shop] '{name}' scan aborted by a blocking dialog -- NOT confirmed unavailable, check the game manually")
|
||||
skipped.append((name, "blocked_by_modal"))
|
||||
else:
|
||||
print(f"[shop] '{name}' not found available at its expected price {remaining[name]} -- skipping (sold out this cycle, or catalog changed)")
|
||||
skipped.append((name, "not_available"))
|
||||
return selected, skipped
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user