Просмотр исходного кода

fix(DemonEncounter): 挑战次数OCR改为DigitCounter 模式

- 移除已不再使用的 import re
User 1 месяц назад
Родитель
Сommit
7738d5d57d

+ 1 - 1
tasks/DemonEncounter/assets.py

@@ -136,7 +136,7 @@ class DemonEncounterAssets:
 	# 计数已经开启多少的 
 	O_DE_COUNTER = RuleOcr(roi=(1204,685,48,34), area=(1204,685,48,34), mode="DigitCounter", method="Default", keyword="", name="de_counter")
 	# 现世逢魔顶部今日挑战次数X/1的最小识别区, 0/1表示已打过直接结束 
-	O_DE_CHALLENGE_COUNT = RuleOcr(roi=(705,68,45,36), area=(705,68,45,36), mode="Full", method="Default", keyword="", name="de_challenge_count")
+	O_DE_CHALLENGE_COUNT = RuleOcr(roi=(705,68,45,36), area=(705,68,45,36), mode="DigitCounter", method="Default", keyword="", name="de_challenge_count")
 
 
 	# Click Rule Assets

+ 1 - 1
tasks/DemonEncounter/demon/ocr.json

@@ -12,7 +12,7 @@
     "itemName": "de_challenge_count",
     "roiFront": "705,68,45,36",
     "roiBack": "705,68,45,36",
-    "mode": "Full",
+    "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
     "description": "现世逢魔顶部今日挑战次数X/1的最小识别区, 0/1表示已打过直接结束"

+ 9 - 10
tasks/DemonEncounter/script_task.py

@@ -3,7 +3,6 @@
 # github https://github.com/runhey
 import time
 from time import sleep
-import re
 
 from enum import Enum
 from cached_property import cached_property
@@ -61,16 +60,16 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
 
     def check_challenge_done(self) -> bool:
         """
-        OCR识别现世逢魔顶部"今日挑战次数:X/1"
-        :return: True表示0/1今日已打过
+        OCR识别现世逢魔顶部"今日挑战次数:剩余/总", 支持老号X/1与新号X/2
+        DigitCounter 返回 (current, remain, total), current 即剩余次数
+        :return: True表示剩余=0, 今日已打过
         """
-        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'
+        current, _remain, total = self.O_DE_CHALLENGE_COUNT.ocr(self.device.image)
+        if total > 0:
+            logger.info(f'Demon encounter challenge count: {current}/{total}')
+            return current == 0
+        logger.warning('Challenge count not recognized, assume attempts remain')
+        return False
 
     def checkout_soul(self):
         """