feat(task): 优化培育流程
1. 新增对“授業”的处理 2. 优化对考试结束的检测 3. 恢复对培育结束时是否关注租用支援卡的制作人 4. 修复 allowance_available 和 study_available 错误地使用了 expect
|
@ -131,7 +131,7 @@ def template_match(
|
|||
_template_name = os.path.relpath(template)
|
||||
else:
|
||||
_template_name = '<opencv Mat>'
|
||||
logger.debug(f'match template: {_template_name} threshold: {threshold} max_results: {max_results}')
|
||||
# logger.debug(f'match template: {_template_name} threshold: {threshold} max_results: {max_results}')
|
||||
# 统一参数
|
||||
template = _unify_image(template, transparent)
|
||||
image = _unify_image(image)
|
||||
|
|
|
@ -12,7 +12,7 @@ from .scenes import at_home
|
|||
from . import loading
|
||||
from .common import acquisitions
|
||||
from kotonebot.backend.util import AdaptiveWait, crop_y, cropper_y
|
||||
from .non_lesson_actions import enter_allowance, allowance_available
|
||||
from .non_lesson_actions import enter_allowance, allowance_available, study_available, enter_study
|
||||
from kotonebot import ocr, device, contains, image, regex, action, debug
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -81,7 +81,7 @@ def enter_recommended_action(final_week: bool = False) -> ActionType:
|
|||
R.InPurodyuusu.TextSenseiTipVisual,
|
||||
R.InPurodyuusu.TextSenseiTipRest,
|
||||
])
|
||||
logger.debug("ocr.wait_for: %s", result)
|
||||
logger.debug("image.find_multi: %s", result)
|
||||
if result is None:
|
||||
logger.debug("No recommended lesson found")
|
||||
return None
|
||||
|
@ -402,16 +402,11 @@ def practice():
|
|||
"""执行练习"""
|
||||
logger.info("Practice started")
|
||||
# 循环打出推荐卡
|
||||
no_card_count = 0
|
||||
MAX_NO_CARD_COUNT = 3
|
||||
while True:
|
||||
with device.pinned():
|
||||
count = skill_card_count()
|
||||
if count == 0:
|
||||
logger.info("No skill card found. Wait and retry...")
|
||||
# no_card_count += 1
|
||||
# if no_card_count >= MAX_NO_CARD_COUNT:
|
||||
# break
|
||||
if not image.find_multi([
|
||||
R.InPurodyuusu.TextPerfectUntil,
|
||||
R.InPurodyuusu.TextClearUntil
|
||||
|
@ -424,7 +419,7 @@ def practice():
|
|||
logger.info("Click recommended card failed. Retry...")
|
||||
continue
|
||||
logger.info("Wait for next turn...")
|
||||
sleep(9) # TODO: 采用更好的方式检测练习结束
|
||||
sleep(9)
|
||||
# 跳过动画
|
||||
logger.info("Recommend card not found. Practice finished.")
|
||||
ocr.expect_wait(contains("上昇"))
|
||||
|
@ -436,20 +431,20 @@ def exam():
|
|||
"""执行考试"""
|
||||
logger.info("Exam started")
|
||||
# 循环打出推荐卡
|
||||
no_card_count = 0
|
||||
MAX_NO_CARD_COUNT = 3
|
||||
while True:
|
||||
count = skill_card_count()
|
||||
if count == 0:
|
||||
logger.info("No skill card found. Wait and retry...")
|
||||
no_card_count += 1
|
||||
if no_card_count >= MAX_NO_CARD_COUNT:
|
||||
if not image.wait_for(R.InPurodyuusu.TextButtonExamSkipTurn, timeout=20):
|
||||
logger.info("Exam skip turn button not found. Exam finished.")
|
||||
break
|
||||
sleep(3)
|
||||
continue
|
||||
if click_recommended_card(card_count=count) == -1:
|
||||
break
|
||||
sleep(9) # TODO: 采用更好的方式检测练习结束
|
||||
logger.info("Click recommended card failed. Retry...")
|
||||
continue
|
||||
logger.info("Wait for next turn...")
|
||||
sleep(9)
|
||||
|
||||
# 点击“次へ”
|
||||
device.click(image.expect_wait(R.Common.ButtonNext))
|
||||
|
@ -460,38 +455,21 @@ def exam():
|
|||
def produce_end():
|
||||
"""执行考试结束流程"""
|
||||
bottom = (int(device.screen_size[0] / 2), int(device.screen_size[1] * 0.9))
|
||||
# 考试结束交流 [screenshots/produce/in_produce/final_exam_end_commu.png]
|
||||
# 然后是,考试结束对话 [screenshots\produce_end\step2.jpg]
|
||||
# while not image.find(R.InPurodyuusu.TextAsariProduceEnd):
|
||||
# check_and_skip_commu()
|
||||
# device.click(*bottom)
|
||||
# sleep(1)
|
||||
# # image.expect_wait(R.InPurodyuusu.TextAsariProduceEnd, timeout=30)
|
||||
# sleep(0.5)
|
||||
# device.click(*bottom)
|
||||
# # 对话第二句 [screenshots\produce_end\step3.jpg]
|
||||
# sleep(3)
|
||||
# device.click_center()
|
||||
# sleep(6)
|
||||
# device.click(*bottom)
|
||||
# sleep(3)
|
||||
# device.click(*bottom)
|
||||
# sleep(3)
|
||||
# 1. 考试结束交流 [screenshots/produce/in_produce/final_exam_end_commu.png]
|
||||
# 2. 然后是,考试结束对话 [screenshots\produce_end\step2.jpg]
|
||||
# 3. MV
|
||||
# 4. 培育结束交流
|
||||
# 上面这些全部一直点就可以
|
||||
|
||||
# MV
|
||||
# 等就可以了,反正又不要自己操作(
|
||||
|
||||
# 培育结束交流
|
||||
|
||||
# 结算
|
||||
# 最終プロデュース評価 R.InPurodyuusu.TextFinalProduceRating
|
||||
# 等待选择封面画面 [screenshots/produce_end/select_cover.jpg]
|
||||
# 次へ
|
||||
logger.info("Waiting for select cover screen...")
|
||||
wait = AdaptiveWait(timeout=60 * 5)
|
||||
wait = AdaptiveWait(timeout=60 * 5, max_interval=20)
|
||||
while not image.find(R.InPurodyuusu.ButtonNextNoIcon):
|
||||
wait()
|
||||
device.click(0, 0)
|
||||
# 选择封面
|
||||
logger.info("Use default cover.")
|
||||
sleep(3)
|
||||
logger.debug("Click next")
|
||||
|
@ -555,9 +533,11 @@ def produce_end():
|
|||
logger.debug("Click complete")
|
||||
device.click(image.expect_wait(R.InPurodyuusu.ButtonComplete))
|
||||
sleep(1.3)
|
||||
# 活动进度
|
||||
# 点击结束后可能还会弹出来:
|
||||
# 活动进度、关注提示
|
||||
# [screenshots/produce_end/end_activity.png]
|
||||
# [screenshots/produce_end/end_activity1.png]
|
||||
# [screenshots/produce_end/end_follow.png]
|
||||
while not at_home():
|
||||
if image.find(R.Common.ButtonClose):
|
||||
logger.info("Activity award claim dialog found. Click to close.")
|
||||
|
@ -565,6 +545,11 @@ def produce_end():
|
|||
elif image.find(R.Common.ButtonNextNoIcon):
|
||||
logger.debug("Click next")
|
||||
device.click(image.expect_wait(R.Common.ButtonNextNoIcon))
|
||||
elif image.find(R.InPurodyuusu.ButtonCancel):
|
||||
# CONFIG: 可选是否关注
|
||||
logger.info("Follow producer dialog found. Click to close.")
|
||||
device.click()
|
||||
# R.InPurodyuusu.ButtonFollowNoIcon
|
||||
else:
|
||||
device.click_center()
|
||||
sleep(1)
|
||||
|
@ -602,8 +587,10 @@ def hajime_regular(week: int = -1, start_from: int = 1):
|
|||
logger.info("Recommended action is rest.")
|
||||
elif allowance_available():
|
||||
enter_allowance()
|
||||
# elif study_available():
|
||||
# enter_study()
|
||||
elif study_available():
|
||||
enter_study()
|
||||
else:
|
||||
raise ValueError("No action available.")
|
||||
until_action_scene()
|
||||
|
||||
def week_final_lesson():
|
||||
|
@ -638,6 +625,7 @@ def hajime_regular(week: int = -1, start_from: int = 1):
|
|||
produce_end()
|
||||
|
||||
weeks = [
|
||||
# TODO: 似乎一部分选项是随机出现的
|
||||
week_lesson, # 1: Vo.レッスン、Da.レッスン、Vi.レッスン
|
||||
week_lesson, # 2: 授業
|
||||
week_lesson, # 3: Vo.レッスン、Da.レッスン、Vi.レッスン、授業
|
||||
|
@ -685,11 +673,15 @@ if __name__ == '__main__':
|
|||
getLogger(__name__).setLevel(logging.DEBUG)
|
||||
init_context()
|
||||
|
||||
exam()
|
||||
produce_end()
|
||||
# exam()
|
||||
# until_action_scene()
|
||||
|
||||
# exam()
|
||||
# produce_end()
|
||||
|
||||
# import cProfile
|
||||
# p = cProfile.Profile()
|
||||
# p = cProfile.Prof
|
||||
# ile()
|
||||
# p.enable()
|
||||
# acquisitions()
|
||||
# p.disable()
|
||||
|
@ -740,7 +732,7 @@ if __name__ == '__main__':
|
|||
# acquisitions()
|
||||
# acquire_pdorinku(0)
|
||||
# image.wait_for(R.InPurodyuusu.InPractice.PDorinkuIcon)
|
||||
# hajime_regular(start_from=12)
|
||||
hajime_regular(start_from=8)
|
||||
# until_practice_scene()
|
||||
# device.click(image.expect_wait_any([
|
||||
# R.InPurodyuusu.PSkillCardIconBlue,
|
||||
|
|
|
@ -10,6 +10,7 @@ from kotonebot import device, image, ocr, debug, action
|
|||
from kotonebot.tasks import R
|
||||
from ..actions.loading import wait_loading_end, wait_loading_start
|
||||
from .common import acquisitions, AcquisitionType
|
||||
from .commu import check_and_skip_commu
|
||||
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
@ -18,21 +19,43 @@ def allowance_available():
|
|||
"""
|
||||
判断是否可以执行活動支給。
|
||||
"""
|
||||
return image.expect(R.InPurodyuusu.ButtonTextAllowance) is not None
|
||||
return image.find(R.InPurodyuusu.ButtonTextAllowance) is not None
|
||||
|
||||
@action('检测是否可以执行授業')
|
||||
def study_available():
|
||||
"""
|
||||
判断是否可以执行授業。
|
||||
"""
|
||||
return image.expect(R.InPurodyuusu.ButtonTextStudy) is not None
|
||||
# [screenshots/produce/action_study1.png]
|
||||
return image.find(R.InPurodyuusu.ButtonIconStudy) is not None
|
||||
|
||||
@action('执行授業')
|
||||
def enter_study():
|
||||
"""
|
||||
执行授業。
|
||||
|
||||
前置条件:位于行动页面,且所有行动按钮清晰可见 \n
|
||||
结束状态:选择选项后可能会出现的,比如领取奖励、加载画面等。
|
||||
"""
|
||||
raise NotImplementedError("授業功能未实现")
|
||||
logger.info("Executing 授業.")
|
||||
# [screenshots/produce/action_study1.png]
|
||||
logger.debug("Double clicking on 授業.")
|
||||
device.double_click(image.expect_wait(R.InPurodyuusu.ButtonIconStudy))
|
||||
sleep(1.3)
|
||||
# 等待进入页面。中间可能会出现未读交流
|
||||
# [screenshots/produce/action_study2.png]
|
||||
while not image.find(R.InPurodyuusu.IconTitleStudy):
|
||||
logger.debug("Waiting for 授業 screen.")
|
||||
check_and_skip_commu()
|
||||
sleep(1)
|
||||
# 固定点击 Vi. 选项
|
||||
logger.debug("Clicking on Vi. option.")
|
||||
device.double_click(image.expect_wait(R.InPurodyuusu.ButtonIconStudyVisual))
|
||||
while acquisitions() is None:
|
||||
logger.info("Waiting for acquisitions finished.")
|
||||
sleep(1)
|
||||
logger.info("授業 completed.")
|
||||
|
||||
|
||||
@action('执行活動支給')
|
||||
def enter_allowance():
|
||||
|
|
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 572 KiB |
After Width: | Height: | Size: 315 KiB |