- 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.
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""Common Shop (通常アイテム) daily task. Ported from baas-reference
|
|
module/shop/common_shop.py's implement() -- see shop_utils.py for the
|
|
shared checkbox-grid-then-bulk-buy control flow both shop tabs use."""
|
|
from ba_auto import navigation
|
|
from ba_auto.tasks import shop_utils
|
|
|
|
|
|
def run(driver, config):
|
|
driver.focus_game()
|
|
|
|
driver.click(*config.SHOP_ICON)
|
|
driver.wait(2)
|
|
if not navigation.is_on_subscreen(driver):
|
|
print("[shop_common] could not confirm shop opened, aborting without pressing further keys")
|
|
return
|
|
|
|
shop_utils.run_shop_tab(
|
|
driver, config,
|
|
tab_button=config.SHOP_TAB_COMMON,
|
|
targets=config.COMMON_SHOP_TARGETS,
|
|
balance_rect=config.CREDIT_BALANCE_OCR_RECT,
|
|
currency_label="credits",
|
|
select_fn=shop_utils.select_targets_by_name,
|
|
)
|
|
|
|
# navigation.return_to_home over a bare click -- verified + carries the
|
|
# XIGNCODE-overlay recovery escalation return_to_home has (see its
|
|
# docstring); an unverified click here was a real gap found in a
|
|
# 2026-07-12 audit of every direct BACK_BUTTON usage in this project.
|
|
if not navigation.return_to_home(driver):
|
|
print("[shop_common] warning: could not confirm return to home screen")
|
|
print("[shop_common] Done.")
|