Skip to content

Commit 7738d5d

Browse files
committed
fix(DemonEncounter): 挑战次数OCR改为DigitCounter 模式
- 移除已不再使用的 import re
1 parent 194a3ed commit 7738d5d

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎tasks/DemonEncounter/assets.py‎

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

141141

142142
# Click Rule Assets

‎tasks/DemonEncounter/demon/ocr.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"itemName": "de_challenge_count",
1313
"roiFront": "705,68,45,36",
1414
"roiBack": "705,68,45,36",
15-
"mode": "Full",
15+
"mode": "DigitCounter",
1616
"method": "Default",
1717
"keyword": "",
1818
"description": "现世逢魔顶部今日挑战次数X/1的最小识别区, 0/1表示已打过直接结束"

‎tasks/DemonEncounter/script_task.py‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# github https://github.com/runhey
44
import time
55
from time import sleep
6-
import re
76

87
from enum import Enum
98
from cached_property import cached_property
@@ -61,16 +60,16 @@ def run(self):
6160

6261
def check_challenge_done(self) -> bool:
6362
"""
64-
OCR识别现世逢魔顶部"今日挑战次数:X/1"
65-
:return: True表示0/1今日已打过
63+
OCR识别现世逢魔顶部"今日挑战次数:剩余/总", 支持老号X/1与新号X/2
64+
DigitCounter 返回 (current, remain, total), current 即剩余次数
65+
:return: True表示剩余=0, 今日已打过
6666
"""
67-
results = self.O_DE_CHALLENGE_COUNT.detect_and_ocr(self.device.image)
68-
text = ''.join(r.ocr_text for r in results)
69-
m = re.search(r'([01])\s*/\s*1', text)
70-
if not m:
71-
logger.warning(f'Challenge count not recognized: [{text}], continue by default')
72-
return False
73-
return m.group(1) == '0'
67+
current, _remain, total = self.O_DE_CHALLENGE_COUNT.ocr(self.device.image)
68+
if total > 0:
69+
logger.info(f'Demon encounter challenge count: {current}/{total}')
70+
return current == 0
71+
logger.warning('Challenge count not recognized, assume attempts remain')
72+
return False
7473

7574
def checkout_soul(self):
7675
"""

0 commit comments

Comments
 (0)