76 Commits

Author SHA1 Message Date
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
68a7ed2529 feat: cafe lowest-affection invite for room 2, exit_game AP-left-unspent alert, login window-flicker fix
- cafe.py: room 2 now invites the lowest-affection candidate instead of
  highest (room 1 unchanged), plus OCR'd invited-student name logging
- exit_game.py: alert (AP_ALERT: log tag, picked up by ba_cron_run.sh's
  Discord alerting) if AP is still unspent above threshold when the game
  closes
- login.py: re-check window_exists() after the stabilization wait to catch
  a startup window-flicker race that could crash a run
- config.py/mapping.md: supporting constants and reference-mapping updates

Also rewrites plan.md: retires the phase-by-phase changelog (now fully
superseded by CLAUDE.md's own documentation) down to forward-looking
backlog items, and adds a performance-improvement plan from a cron-log
time analysis (lesson.py's per-cell screenshot redundancy, event_sweep's
multi-call design).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 19:28:59 +09:00
e0744fc799 feat: add timestamped log output for better task duration tracking 2026-08-06 23:23:41 +09:00
ff240cb104 feat: implement handling for pending-update download notice during login 2026-08-04 17:56:18 +09:00
a690e90478 Implement Scrimmage Automation (学園交流会)
- Added new task for Scrimmage (学園交流会) in `ba_auto/tasks/scrimmage.py`, allowing automated clearing of the hardest stage (D) in three areas (トリニティ, ゲヘナ, ミレニアム) based on date-ordinal rotation.
- Introduced AP cost verification to ensure sweeps only occur when the cost is confirmed as 0 due to the user's monthly pass.
- Updated `ba_daily.py` to include the new scrimmage task in the daily preset and task registry.
- Documented the implementation details and testing outcomes in `plan.md` and `mapping.md`.
- Conducted live tests confirming successful execution and correct handling of ticket and AP costs.
2026-08-02 11:12:25 +09:00
52b10eda3d feat: add Discord alerting for cron job start/end with alert-bridge integration 2026-08-01 23:31:00 +09:00
509fb27fd8 Refactor Common Shop item selection to use OCR-based name matching
- Updated `COMMON_SHOP_TARGETS` to use item names and expected prices instead of fixed grid positions.
- Introduced `SHOP_NAME_OCR_OFFSET` for accurate name recognition in the shop grid.
- Implemented `select_targets_by_name` function to handle item selection based on OCR'd names and prices, addressing issues with item position drift due to sold-out items.
- Enhanced the purchasable button check to rely on blue tint rather than brightness, ensuring accurate detection of available items.
- Adjusted `run_shop_tab` to utilize the new selection function for Common Shop tasks.
- Documented changes and rationale in `plan.md`, including live testing results confirming successful item purchases.
2026-08-01 22:49:09 +09:00
7f408c1ad1 feat: add cron setup instructions for unattended scheduling of ba_cron_run.sh 2026-08-01 21:49:02 +09:00
a15ac6111e feat: enhance navigation and shop utilities with improved visibility checks and price reading retries 2026-07-31 13:48:25 +09:00
ffcacc8738 feat: implement robust screenshot handling with retry logic for image decoding 2026-07-31 13:06:50 +09:00
6cdce8ccdd Fix handling of transient misreads and improve event page checks
- Updated `_scan_stage_rows_once` to return full labels list instead of a boolean, allowing for better validation of stage presence.
- Enhanced `_find_stage_row` to require consistent label readings across consecutive scans to avoid false positives from transient misreads.
- Corrected `EVENT_FINISHED_TEXT_RECT` coordinates to ensure accurate OCR readings for finished events.
- Modified `run()`'s retry logic to treat `stage_not_found` similarly to `wrong_page`, enabling retries for potentially misidentified pages.
- Confirmed fixes through live testing, ensuring robust navigation and accurate event identification.
2026-07-29 23:10:09 +09:00
3c02178b3d fix: update q4h preset to remove duplicate tasks and improve flow 2026-07-29 22:26:57 +09:00
8a96ea4ffa feat: implement Battle Pass reward claiming functionality and update configuration 2026-07-29 21:59:37 +09:00
8d3da6e6e1 Refactor gem shop task for UI redesign and improve dialog handling
- Recalibrated gem shop task after client UI update, replacing the old overlay dialog with a full subscreen.
- Removed custom dialog open/close checks in favor of shared navigation functions.
- Updated method names and logic to reflect new tab structure and improve clarity.
- Enhanced error handling for dialog closure and navigation return to home.
- Verified live against real account states to ensure functionality and correctness.
2026-07-29 21:23:49 +09:00
bf87a097c3 feat: add manual pause functionality to prevent automation during user play sessions 2026-07-29 17:21:31 +09:00
4ddd0d7fba feat: implement AP floor guard for story_sweep, story_sweep_hard, and event_sweep 2026-07-24 23:34:15 +09:00
62206494d5 fix(config): adjust story sweep rotation region and stage count 2026-07-24 12:30:12 +09:00
a5d70e5ec6 Refactor story_sweep.py to align with story_sweep_hard.py best practices and add campaign-active guard
- Rewrote story_sweep.py to incorporate fixes from story_sweep_hard.py's Phase 21, addressing latent bugs and improving functionality.
- Introduced a campaign-active guard for Normal mode, ensuring AP is only spent when the reward campaign banner is visible.
- Added explicit Normal-tab navigation and self-healing checks to maintain task screen integrity.
- Updated click functions for MAX and PLUS buttons to remove reliance on visible count increases, addressing false-negative issues.
- Implemented OCR verification for the sweep confirmation dialog to prevent misclicks on stacked buttons.
- Enhanced region reading with retry logic for transient OCR failures.
- Added force parameter to run function, allowing bypass of campaign checks via story_sweep_force command.
- Updated ba_daily.py to include new force commands for both story_sweep and story_sweep_hard.
- Documented changes and live-tested functionality to ensure reliability and correctness.
2026-07-22 23:07:43 +09:00
7f752d5422 feat: add story_sweep_hard to q4h preset 2026-07-21 00:12:43 +09:00
0e3f2d951c feat: Implement hard story AP sweep functionality
- Added `story_sweep_hard.py` to handle a fixed, priority-ordered list of Hard-mode story stages, gated by an active drop-rate/reward campaign.
- Introduced `HARD_STORY_SWEEP_TARGETS`, `HARD_TAB`, `HARD_STAGE_ROWS_Y`, and `HARD_CAMPAIGN_BADGE_RECT` in the config for managing Hard sweep settings.
- Integrated `story_sweep_hard` and `story_sweep_hard_force` commands into the daily task flow, allowing for optional bypass of the campaign check.
- Enhanced navigation and error handling in the sweep process, addressing multiple bugs found during live testing, including navigation-cascade issues and real-money hazards.
- Documented the implementation and testing results in `plan.md`, confirming successful live sweeps and robust error handling.
2026-07-21 00:09:10 +09:00
f2387958fb Update manifest.json with new file metadata and additional files
- Updated timestamps and hashes for existing files: ba_dailies.sh, CLAUDE.md, plan.md.
- Added new files under ba_auto and .claude directories with their respective metadata.
- Included new scripts and configuration files to enhance functionality and organization.
2026-07-20 22:26:40 +09:00
a3cea4d192 feat(login): implement faster stuck-loading detection with _loading_buffer_visible
- Added _loading_buffer_visible function to detect the loading spinner badge
- Updated _wait_for_home to utilize the new detection for early recovery
- Introduced configuration options for loading buffer detection parameters
- Improved handling of stuck loading state to reduce wait time

fix(cron): make ba_cron_run.sh executable

- Changed file mode of ba_cron_run.sh to 755 to ensure it is executable
- Verified that cron can now execute the script as intended

fix(navigation): prevent crash in return_to_home when window disappears

- Added guard to return_to_home to check if the game window exists before focusing
- Ensured robustness in cleanup path during game exit
2026-07-20 01:21:53 +09:00
b8ac8db01e feat(deployment): simplify runtime paths to run directly from the git checkout 2026-07-18 22:04:17 +09:00
976f0f7241 feat(exit_game): implement exit game functionality with confirmation dialog 2026-07-18 20:32:14 +09:00
0a6af51340 feat(exit_game): implement task to exit the Blue Archive client after daily/q4h runs 2026-07-18 20:25:32 +09:00
a30c3888d6 fix: address multiple bugs causing incorrect battle handling and result screen issues
- In arena.py, widened RESULT_MODAL_MAX_POLLS to 200 to accommodate real battle durations and added early exit check in _wait_for_result to prevent stuck screens.
- Updated _fight_one to properly handle _wait_for_result's return value, ensuring failures stop the fight loop.
- In bounty.py, implemented OCR verification in _confirm_dialog_is_sweep to ensure the correct confirmation dialog is displayed before proceeding with sweeps, preventing unintended battles.
- Documented hazards and fixes in plan.md, detailing incidents from 2026-07-17 that led to these changes.
2026-07-18 12:31:42 +09:00
7ccb28a1f9 fix(presets): add stamina task to q4h preset for improved automation 2026-07-17 21:24:47 +09:00
d21aadbde8 fix(login): enhance connectivity checks to prevent false positives in home detection
- Implemented `_connectivity_confirmed` to verify session validity by opening the Mission panel, addressing two failure modes:
  1. Bright full-screen transition frames that could falsely satisfy home checks.
  2. Dead sessions due to server resets or concurrent logins, which appear as normal home screens until navigation is attempted.

- Improved detection logic by requiring a second verification of `_true_home` after a short wait, reducing the likelihood of coincidental false positives.
- Confirmed live against real scenarios, ensuring robust handling of session states during login.
2026-07-17 20:07:48 +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
027e55f7a9 fix(cafe): Resolve timing gap causing rank-up cutscene to freeze game during cron run
feat(logs): Add script to pull cron run logs from remote for local reading
2026-07-16 23:31:33 +09:00
3c47fabd87 feat(stamina): Implement daily gem reward claiming logic and fix button detection 2026-07-16 14:07:12 +09:00
5a78e8ef11 feat(cron): Implement cron scheduling for daily and q4h presets with logging and locking 2026-07-16 13:29:25 +09:00
0946ce4f65 feat: Add new "q4h" preset for user-defined task sequences in daily automation 2026-07-16 13:16:02 +09:00
e3b1f1204b feat: Add named task presets for user-defined sequences in daily automation 2026-07-16 13:08:54 +09:00
a9f0bbe42f Implement login flow from title screen to home screen
- Added `login.py` to handle the login process, including detection of various states such as the title screen, network error notices, loading transitions, daily attendance cards, and the home screen.
- Integrated a recovery mechanism to relaunch the game if it gets stuck during loading.
- Updated `ba_daily.py` to include the login task in the default execution order, ensuring it runs first to navigate to the home screen before other tasks.
- Fixed a bug in the home detection logic to accurately identify when the user is on the true home screen.
- Live-tested and calibrated the login flow against real game states, confirming functionality and addressing any issues encountered during testing.
2026-07-16 11:07:43 +09:00
88cb1a933a feat(circle): Implement daily check-in for circle (guild) with reward handling 2026-07-16 00:14:38 +09:00
dc0e8403a1 feat: Implement gem shop daily free package automation
- Added `ba_auto/tasks/gem_shop.py` to automate claiming the daily free package from the gem shop.
- Integrated color probes for state detection instead of template matching.
- Updated `ba_daily.py` to include the new gem shop task in the default execution order.
- Documented the implementation and calibration process in `plan.md`, including live testing results and fixes for dialog handling.
- Addressed potential bugs related to dialog state verification and tab layout changes.
2026-07-15 18:22:33 +09:00
bb0215cb04 fix(cafe): resolve invite ticket cooldown handling and improve rank-up cutscene detection 2026-07-15 14:09:55 +09:00
a0e1965353 fix(cafe): resolve invite ticket cooldown misread as list opened, preventing cascading errors 2026-07-14 22:57:32 +09:00
e814b3d803 feat(cafe): implement student invitation and horizontal camera panning
- Added functionality to invite students into the cafe before farming, prioritizing the highest-affection candidates while skipping those that would cause costume swaps or move students from other rooms. This follows user direction from 2026-07-14.
- Introduced a new drag method for horizontal camera panning to reveal hidden content in the cafe, addressing user feedback regarding screen size limitations. The camera pans to both extremes before farming, ensuring all students are visible.
- Updated the cafe task logic to incorporate the new invitation and panning features, ensuring a seamless user experience with real-time confirmations and checks.
- Live-tested and confirmed the new features with real game-state changes, ensuring functionality aligns with user requirements and expectations.
2026-07-14 22:28:44 +09:00
fd9828a746 fix(event_sweep): improve event badge handling by removing dot-clicking and immediate badge clicks after home navigation 2026-07-14 21:04:34 +09:00
a86003cf66 fix(event_sweep): resolve overlapping button regions to prevent result page closure during sweeps 2026-07-14 20:49:10 +09:00
84790ecb27 refactor(navigation): enhance overlay handling and unify back navigation logic across tasks 2026-07-14 19:53:22 +09:00
c5873f4e58 Refactor arena and lesson tasks for improved efficiency and reliability
- Updated arena.py to allow multiple battles per invocation, looping until tickets are exhausted or a rank-1 condition is met. Introduced _fight_one function for single battle logic and added cooldown handling between fights.
- Enhanced lesson.py to implement a tiered priority system for scheduling lessons based on student slots available, replacing the previous highest affection value selection. Introduced functions for scanning all regions and building a priority queue for lesson scheduling.
- Centralized return-to-home logic in ba_daily.py to ensure the game returns to the home screen before and after each task, improving robustness against navigation issues.
- Added retry mechanism for returning to home, allowing for transient navigation issues to be handled gracefully without aborting tasks.
2026-07-13 10:32:53 +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
634d77d9d2 feat(clean_scratchpad): implement script for safe deletion of temporary files in scratchpad directory
fix(arena): resolve consecutive-invocation navigation issue by ensuring return to home before opening Tactical Challenge
docs(mapping): update Arena task description with navigation bug fix details
2026-07-11 00:20:04 +09:00
568e17d244 Refactor event sweep and arena tasks; enhance OCR and navigation reliability
- Updated `mapping.md` to reflect completed migration and testing status for event sweep and arena tasks.
- Improved `arena.py` to ensure a return to home screen before opening tactical challenges, preventing navigation errors.
- Enhanced `event_sweep.py` with robust handling for badge carousel navigation, including direct pagination dot clicks and extended wait times for cold-start scenarios.
- Implemented Japanese OCR support for finished event detection in `event_sweep.py`, adding a definitive check to avoid false positives on stale event pages.
- Adjusted retry logic and timeouts in `event_sweep.py` to accommodate longer loading times and ensure accurate stage row detection.
- Updated `setup.sh` to check for the presence of the Japanese OCR language pack, providing installation instructions if missing.
- Documented live testing results and fixes in `plan.md`, confirming successful sweeps and addressing previously reported bugs.
2026-07-11 00:04:50 +09:00