fix(task): 修复进入商店购买时无法自动关闭默认购买数量设置弹窗
This commit is contained in:
parent
fdf7dfce07
commit
18ac6af3f4
|
@ -37,10 +37,20 @@ def at_home() -> bool:
|
|||
with cropped(device, y1=0.7):
|
||||
return image.find(R.Daily.ButtonHomeCurrent) is not None
|
||||
|
||||
@action('检测是否位于商店页面')
|
||||
def at_shop() -> bool:
|
||||
with cropped(device, y2=0.3):
|
||||
return image.find(R.Daily.IconShopTitle) is not None
|
||||
@action('检测是否位于日常商店页面')
|
||||
def at_daily_shop() -> bool:
|
||||
icon = image.find(R.Daily.IconShopTitle)
|
||||
if icon is not None:
|
||||
return True
|
||||
else:
|
||||
# 调整默认购买数量的设置弹窗
|
||||
# [screenshots/contest/settings_popup.png]
|
||||
if image.find(R.Common.ButtonIconClose):
|
||||
device.click()
|
||||
sleep(1)
|
||||
return at_daily_shop()
|
||||
else:
|
||||
return False
|
||||
|
||||
@action('返回首页')
|
||||
def goto_home():
|
||||
|
@ -79,12 +89,12 @@ def goto_shop():
|
|||
if not at_home():
|
||||
goto_home()
|
||||
device.click(image.expect(R.Daily.ButtonShop))
|
||||
until(at_shop, critical=True)
|
||||
until(at_daily_shop, critical=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from kotonebot.backend.context import init_context
|
||||
init_context()
|
||||
print(at_home())
|
||||
print(at_shop())
|
||||
print(at_daily_shop())
|
||||
goto_shop()
|
||||
|
|
|
@ -5,7 +5,7 @@ from time import sleep
|
|||
from kotonebot import task
|
||||
from kotonebot import device, image, ocr, action
|
||||
from kotonebot.backend.util import cropped
|
||||
from .actions.scenes import goto_home, goto_shop, at_shop
|
||||
from .actions.scenes import goto_home, goto_shop, at_daily_shop
|
||||
from . import R
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -86,7 +86,7 @@ def purchase():
|
|||
"""
|
||||
从商店购买物品
|
||||
"""
|
||||
if not at_shop():
|
||||
if not at_daily_shop():
|
||||
goto_shop()
|
||||
# 进入每日商店 [screenshots\shop\shop.png]
|
||||
# [ap1.png]
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 366 KiB |
|
@ -5,7 +5,7 @@ from kotonebot.tasks.actions.scenes import (
|
|||
goto_home,
|
||||
goto_shop,
|
||||
at_home,
|
||||
at_shop,
|
||||
at_daily_shop,
|
||||
)
|
||||
img_assign = 'tests/images/scenes/assign.png'
|
||||
img_commu = 'tests/images/scenes/commu.png'
|
||||
|
|
Loading…
Reference in New Issue