|
|
@@ -3,6 +3,7 @@
|
|
|
# github https://github.com/runhey
|
|
|
import time
|
|
|
from time import sleep
|
|
|
+import re
|
|
|
|
|
|
from enum import Enum
|
|
|
from cached_property import cached_property
|
|
|
@@ -48,12 +49,30 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
|
|
|
self.ui_goto(page_shikigami_records)
|
|
|
self.checkout_soul()
|
|
|
self.ui_goto(page_demon_encounter_realworld)
|
|
|
+ # 顶部"今日挑战次数:X/1"检测, 0/1表示今日已打过, 直接结束
|
|
|
+ if self.check_challenge_done():
|
|
|
+ logger.info('Challenge count 0/1, already challenged today')
|
|
|
+ self.set_next_run(task='DemonEncounter', success=True, finish=False)
|
|
|
+ raise TaskEnd('DemonEncounter')
|
|
|
self.execute_lantern()
|
|
|
self.execute_boss()
|
|
|
|
|
|
self.set_next_run(task='DemonEncounter', success=True, finish=False)
|
|
|
raise TaskEnd('DemonEncounter')
|
|
|
|
|
|
+ def check_challenge_done(self) -> bool:
|
|
|
+ """
|
|
|
+ OCR识别现世逢魔顶部"今日挑战次数:X/1"
|
|
|
+ :return: True表示0/1今日已打过
|
|
|
+ """
|
|
|
+ results = self.O_DE_CHALLENGE_COUNT.detect_and_ocr(self.device.image)
|
|
|
+ text = ''.join(r.ocr_text for r in results)
|
|
|
+ m = re.search(r'([01])\s*/\s*1', text)
|
|
|
+ if not m:
|
|
|
+ logger.warning(f'Challenge count not recognized: [{text}], continue by default')
|
|
|
+ return False
|
|
|
+ return m.group(1) == '0'
|
|
|
+
|
|
|
def checkout_soul(self):
|
|
|
"""
|
|
|
切换御魂
|