16 Commits

Author SHA1 Message Date
19e39ec8b2 feat: detect Steam sign-out during login, stop cascading crashes after a missing game window
Root-caused 3 consecutive real cron failures (one q4h, two daily, all
2026-09-20) to Steam itself sitting signed out on its own account
sign-in dialog -- not a Blue Archive client issue, and not something any
amount of retrying/relaunching the game can fix.

login._steam_needs_sign_in (new detector.read_text_white_on_dark, since
the dialog's own light-on-dark text is the opposite OCR polarity this
project usually assumes) recognizes that exact state and turns the
generic "game window never appeared" warning into a specific, actionable
one instead of requiring a fresh screenshot investigation every time it
recurs.

ba_daily.py's _run_sequence now checks driver.window_exists() after every
task (except the last, and except exit_game) and aborts the whole run
immediately with one clear message if the window is gone, instead of
letting every remaining task independently rediscover this via its own
doomed pre-task retry cycle before crashing two tasks deep in a stack
trace. Still propagates as a real FAILED exit code -- this project
deliberately never swallows a genuine crash.

Confirmed live: reproduced the original failure via a real
./ba_cron_run.sh q4h run while Steam was still genuinely signed out, then
verified the new diagnostic fired correctly and the sequence aborted
immediately. After the user signed back into Steam, ran the actual daily
recovery preset end-to-end (all 17 tasks, ~24 minutes, exit 0) to catch
up the account's daily claims.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 08:51:06 +09:00
6a800f731b feat: batch cafe sparkle patting, add diagnostic capture, verify shop purchases via balance delta
Cafe: find_cafe_sparkles (replacing find_cafe_sparkle) matches every
sparkle in one screenshot instead of the single best one; _pat_current_view
now pats a whole batch per frame and stops after two consecutive empty
rounds instead of a fixed 15-click budget. Cuts an empty room's farming
time from ~100s to ~14s in live testing. _dismiss_rank_up_if_shown also
saves a diagnostic screenshot on its own final failure, since the real
"screen not confirmed" cron failures (100% reproducible in logs, 0%
reproducible live across several debugging sessions) need hard evidence
from the next real occurrence.

shop_utils.confirm_purchase now requires the currency balance to have
actually dropped by the expected spend before reporting success, instead
of trusting a single post-click overlay read -- closes a real false
positive caught live where a cron run logged a successful purchase that
never actually happened.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-19 18:18:51 +09:00
0ff3dca0b9 Implement dynamic OCR for gem shop sidebar navigation and free card status
- Added `read_lines` function to `detector.py` for OCR of multiple text lines in a specified region, improving the ability to dynamically locate text in the UI.
- Rewrote the gem shop task in `gem_shop.py` to utilize OCR for sidebar navigation and free card status checks, replacing fixed coordinates with dynamic text detection.
- Introduced helper functions `_find_sidebar_label`, `_on_general_products_tab`, `_ensure_general_products_tab`, `_read_card_lines`, `_read_free_card_status`, and `_find_buy_button` to streamline the OCR process and improve reliability against UI changes.
- Removed outdated color probe methods for checking the free card status, enhancing the robustness of the gem shop interaction flow.
- Live-calibrated the new OCR functionality to ensure accurate detection of UI elements and their states.
2026-09-17 10:37:24 +09:00
b10824d978 feat: optimize image handling by adding optional image parameter for screenshot functions 2026-08-21 23:53:57 +09:00
d266b47e58 feat: optimize screenshot handling for batch processing in lesson tasks 2026-08-21 18:20:30 +09:00
ffcacc8738 feat: implement robust screenshot handling with retry logic for image decoding 2026-07-31 13:06:50 +09:00
4857bd5f8f fix(detector): Recalibrate SPARKLE_CLICK_OFFSET to prevent overshooting into neighboring students 2026-07-17 00:17:19 +09:00
b4bad17813 fix(detector): Recalibrate sparkle click offset to resolve targeting issue with overlapping students 2026-07-17 00:14:00 +09:00
e67d28513e Implement Bounty Task (指名手配) - Ported from module/rewarded_task.py
- Created ba_auto/tasks/bounty.py to handle the Bounty task, simplifying the original reference's per-call loop to a single area sweep based on date-ordinal-modulo rotation.
- Live-calibrated against nik-gpu on 2026-07-11, ensuring zero real tickets were spent during testing.
- Adjusted entry point to directly access the Work-hub card for Bounty, eliminating unnecessary navigation steps.
- Implemented logic to confirm the latest stage available in each area, ensuring all stages are SSS-cleared.
- Fixed bugs related to ticket count handling and result button detection, preventing unintended real-currency prompts.
- Updated ba_daily.py to include the new bounty task in the task flow.
- Documented the implementation and testing process in plan.md, detailing live tests and fixes applied.
2026-07-11 23:19:57 +09:00
166a34825a fix(event_sweep): resolve OCR misreads for stages 08/09 and improve result button detection logic 2026-07-11 12:07:21 +09:00
511010b6d6 feat: Implement arena task with OCR and auto-fight capabilities
- Added `find_template` and `template_visible` functions for template matching in screenshots.
- Introduced `read_int_white_on_dark` for OCR of bright text on dark backgrounds.
- Ported arena functionality from reference, including ticket management, opponent selection, and reward collection.
- Implemented safety checks for modal visibility and result confirmation to prevent unintended ticket spends.
- Live-tested the arena task, confirming functionality across multiple tickets with real fight outcomes.
- Updated mapping documentation to reflect new arena task implementation and its unique navigation requirements.
2026-07-09 02:38:41 +09:00
51ad297f69 feat: Implement Lesson/Schedule task
- Added `lesson.py` to handle the scheduling of lessons based on affection values.
- Integrated OCR functionality to read affection counts from heart badges.
- Updated `README.md` to include the new lesson task in the task status section.
- Enhanced `config.py` with necessary configurations for the lesson task.
- Modified `detector.py` to include a new function for reading heart badge values accurately.
- Updated `mapping.md` to reflect the new lesson task implementation.
- Adjusted `ba_daily.py` to include the lesson task in the command dispatch.
- Updated `plan.md` to document the completion of the lesson task and its testing outcomes.
- Modified `setup.sh` to include the lesson task in the run command instructions.
2026-07-08 23:45:18 +09:00
a8ff95d6f5 feat: Implement OCR-driven story AP sweep with deterministic stage targeting
- Added `wait_for_state` function in `navigation.py` for state monitoring and reaction handling.
- Updated `mapping.md` to reflect changes in story sweep implementation and OCR usage.
- Refactored `story_sweep.py` to utilize OCR for region and stage identification, replacing random selection with configured targets.
- Enhanced modal handling and confirmation checks for AP usage in `story_sweep.py`.
- Updated setup script to require `tesseract` for OCR functionality and included installation instructions.
- Revised `plan.md` to document the transition from heuristic to OCR-based stage targeting and the associated findings from live testing.
2026-07-06 01:41:58 +09:00
a04ef5d0c5 Refactor scratchpad directory references and update Phase 6 follow-up report
- Changed references from './scratchpad' to '.scratchpad/' in graph.json and plan.md for consistency.
- Expanded Phase 6 follow-up section in plan.md to clarify changes made to the pat detection logic:
  - Updated `find_cafe_sparkle()` to utilize multiple template scales for improved detection.
  - Modified `_pat_room` to allow polling for maximum clicks instead of breaking on the first miss.
  - Added mouse movement after each pat to prevent cursor occlusion of sparkles.
- Verified that room entry and modal state checks function correctly, but end-to-end pat success remains untested due to lack of available interactions.
2026-07-05 17:57:26 +09:00
3a4534f205 Migrate cafe and mailbox tasks to Python: replace legacy Bash scripts, implement state verification, and integrate sparkle detection. 2026-07-05 16:31:26 +09:00
398b936c64 Migrate to Python-first architecture: implement mailbox and cafe tasks, replace Bash scripts with Python CLI, and establish configuration and driver modules. 2026-07-05 16:02:02 +09:00