|
|
@@ -2,7 +2,7 @@
|
|
|
# @author runhey
|
|
|
# github https://github.com/runhey
|
|
|
from time import sleep
|
|
|
-from datetime import datetime, time
|
|
|
+from datetime import datetime
|
|
|
|
|
|
from module.logger import logger
|
|
|
from module.exception import TaskEnd, GameStuckError
|
|
|
@@ -16,6 +16,7 @@ from tasks.Orochi.script_task import ScriptTask as OrochiScriptTask
|
|
|
from tasks.Orochi.config import Layer
|
|
|
from tasks.Orochi.page import page_orochi
|
|
|
from tasks.GameUi.page import page_main, page_shikigami_records
|
|
|
+from tasks.Exploration.page import page_gameplay
|
|
|
from tasks.TrueOrochi.assets import TrueOrochiAssets
|
|
|
|
|
|
|
|
|
@@ -25,9 +26,10 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
|
|
|
|
|
|
conf = self.config.true_orochi.true_orochi_config
|
|
|
|
|
|
- if conf.current_success >= 2:
|
|
|
- # 超过两次就说明这周打完了没有必要再打了
|
|
|
- logger.warning('This week is full')
|
|
|
+ # 玩法tab的八岐大蛇模块在场说明本周还有次数,消失说明本周已打完
|
|
|
+ self.goto_page(page_gameplay)
|
|
|
+ if not self.appear(self.I_ST_MODULE):
|
|
|
+ logger.warning('True orochi module absent, no attempts left this week')
|
|
|
self.check_times(True)
|
|
|
raise TaskEnd('TrueOrochi')
|
|
|
|
|
|
@@ -91,7 +93,7 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
|
|
|
# 检查是否还有真蛇入口,支持存储两次
|
|
|
self.goto_page(page_orochi)
|
|
|
sleep(0.5)
|
|
|
- if conf.current_success < 2 and self.check_true_orochi(True):
|
|
|
+ if self.check_true_orochi(True):
|
|
|
battle = True
|
|
|
logger.info('Find another true orochi entry, continue')
|
|
|
self.run_true_orochi_battle()
|
|
|
@@ -110,13 +112,6 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
|
|
|
if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
|
|
|
continue
|
|
|
if self.appear_then_click(self.I_ST_FIRE, interval=4):
|
|
|
- # 修正已经挑战的次数, 注意这个是战斗开始之前的次数
|
|
|
- current, current_success, total = self.O_TIMES.ocr(self.device.image)
|
|
|
- if current_success < 0 or current_success > 2:
|
|
|
- continue
|
|
|
- logger.info(f'current: {current}, current_success: {current_success}, total: {total}')
|
|
|
- conf.current_success = current_success
|
|
|
- self.config.save()
|
|
|
continue
|
|
|
if self.appear_then_click(self.I_FIND_TS, interval=1):
|
|
|
continue
|
|
|
@@ -192,31 +187,13 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
|
|
|
|
|
|
def check_times(self, battle: bool):
|
|
|
"""
|
|
|
- 后续的次数和时间设置
|
|
|
- :param battle: 本次是否挑战了真蛇
|
|
|
- :param current_success: 这周的成功次数
|
|
|
+ 根据是否有战斗结果设置下次运行时间
|
|
|
+ :param battle:
|
|
|
:return:
|
|
|
"""
|
|
|
- now = datetime.now()
|
|
|
- now_year, now_week_number, now_weekday = now.isocalendar()
|
|
|
- if battle:
|
|
|
- # 只有真正打过才加一次数
|
|
|
- logger.info('Add current_success by 1')
|
|
|
- self.config.true_orochi.true_orochi_config.current_success += 1
|
|
|
- self.config.true_orochi.true_orochi_config.current_success = min(2, self.config.true_orochi.true_orochi_config.current_success)
|
|
|
- next_run = now + self.config.true_orochi.scheduler.success_interval
|
|
|
- else:
|
|
|
- logger.info('Battle skipped or not found True Orochi')
|
|
|
- next_run = now + self.config.true_orochi.scheduler.failure_interval
|
|
|
- next_run_year, next_run_week_number, next_run_weekday = next_run.isocalendar()
|
|
|
- # 如果下次运行的时间是下一周,那么就重置成功次数
|
|
|
- if now_week_number != next_run_week_number:
|
|
|
- logger.info('Reset current_success')
|
|
|
- self.config.true_orochi.true_orochi_config.current_success = 0
|
|
|
-
|
|
|
- self.config.save()
|
|
|
- self.set_next_run(task='TrueOrochi', target=next_run)
|
|
|
- # self.set_next_run('TrueOrochi', finish=True, success=True)
|
|
|
+ interval = self.config.true_orochi.scheduler.success_interval if battle \
|
|
|
+ else self.config.true_orochi.scheduler.failure_interval
|
|
|
+ self.set_next_run(task='TrueOrochi', target=datetime.now() + interval)
|
|
|
|
|
|
def run_true_orochi(self) -> bool:
|
|
|
pass
|