"""Mission/task-menu AP+pyroxene claim. Ported from baas-reference module/collect_daily_task_power.py's claim-loop pattern (its rgb_in_range checks replaced with driver.color_at probes).""" from ba_auto import navigation OPEN_RETRIES = 3 # One claim-all round is normally enough (button goes grey right after), but # bound it in case multiple reward reveals need dismissing in sequence. CLAIM_MAX_ROUNDS = 5 # Yellow "one-click claim all" button vs. its own flat-grey disabled state -- # same background-pixel-probe idea as mailbox.CLAIM_ALL_PROBE/cafe.CLAIM_PROBE, # but distinguished by hue (yellow has a big r-b gap; grey doesn't) since the # button's grey isn't a single fixed RGB the way mailbox/cafe's are. CLAIM_ENABLED_MIN_R = 230 CLAIM_ENABLED_MIN_RB_GAP = 100 def _claim_enabled(driver, config): r, g, b = driver.color_at(*config.MISSION_CLAIM_PROBE) return r > CLAIM_ENABLED_MIN_R and (r - b) > CLAIM_ENABLED_MIN_RB_GAP def run(driver, config): driver.focus_game() opened = False for attempt in range(1, OPEN_RETRIES + 1): driver.focus_game() driver.click(*config.MISSION_ICON) driver.wait(2) if navigation.is_on_subscreen(driver): opened = True break print(f"[stamina] mission panel not detected after click (attempt {attempt}/{OPEN_RETRIES})") if not opened: print("[stamina] could not confirm mission panel is open, aborting without pressing further keys") return claimed_any = False for _ in range(CLAIM_MAX_ROUNDS): if not _claim_enabled(driver, config): break print("[stamina] claiming mission rewards") driver.keypress("Return") driver.wait(1.5) # dismiss the reward-reveal popup ("TOUCH" prompt); harmless no-op if # nothing is actually showing, same assumption as cafe's room-entry dismiss driver.keypress("Return") driver.wait(1.5) claimed_any = True if not claimed_any: print("[stamina] nothing to claim") if navigation.is_on_subscreen(driver): driver.keypress("Escape") driver.wait(1.5) print("[stamina] Done.")